Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
feb4d7af66 | ||
|
|
5cfcd24657 | ||
|
|
712118556b | ||
|
|
d75ab1ed5f | ||
|
|
4496619eeb | ||
|
|
c85b400a94 | ||
|
|
94c99e3444 | ||
|
|
44c2095d77 | ||
|
|
a501eb7443 | ||
|
|
35ec38ed9c | ||
|
|
2b5be16ad7 | ||
|
|
d747a0fdae | ||
|
|
9f884e2b74 | ||
|
|
0239697a2b | ||
|
|
2b11bdf65e | ||
|
|
19941d9480 | ||
|
|
81933d4e61 | ||
|
|
43d76040d8 | ||
|
|
cd3d522d4f | ||
|
|
8de739cbb7 |
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
<groupId>com.imyeyu.timiserverapi</groupId>
|
<groupId>com.imyeyu.timiserverapi</groupId>
|
||||||
<artifactId>TimiServerAPI</artifactId>
|
<artifactId>TimiServerAPI</artifactId>
|
||||||
<version>1.0.23</version>
|
<version>1.0.28</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>TimiServerAPI</name>
|
<name>TimiServerAPI</name>
|
||||||
<description>imyeyu.com API</description>
|
<description>imyeyu.com API</description>
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import com.imyeyu.api.modules.common.entity.NotifyDetail;
|
|||||||
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.common.service.SmsService;
|
import com.imyeyu.api.modules.common.service.SmsService;
|
||||||
|
import com.imyeyu.api.modules.common.vo.NotifyManagementItem;
|
||||||
import com.imyeyu.api.modules.user.entity.User;
|
import com.imyeyu.api.modules.user.entity.User;
|
||||||
import com.imyeyu.api.modules.user.service.UserLoginService;
|
import com.imyeyu.api.modules.user.service.UserLoginService;
|
||||||
import com.imyeyu.api.modules.user.service.UserService;
|
import com.imyeyu.api.modules.user.service.UserService;
|
||||||
@@ -70,25 +71,31 @@ public class NotifyController {
|
|||||||
@RequiredToken
|
@RequiredToken
|
||||||
@RequestMapping("/detail")
|
@RequestMapping("/detail")
|
||||||
public Notify detail(@RequestParam String id) {
|
public Notify detail(@RequestParam String id) {
|
||||||
Notify notify = service.get(id);
|
return fillDetailList(service.get(id));
|
||||||
{
|
|
||||||
List<NotifyDetail> detailList = detailService.listByNotifyId(id);
|
|
||||||
Set<String> userIdSet = detailList.stream()
|
|
||||||
.filter(item -> item.getMsgType() == NotifyDetail.MsgType.INTERNAL)
|
|
||||||
.flatMap(item -> Stream.of(item.getSendFrom(), item.getSendTo()))
|
|
||||||
.collect(Collectors.toSet());
|
|
||||||
Map<String, User> userMap = userService.mapByIdList(userIdSet);
|
|
||||||
for (NotifyDetail detail : detailList) {
|
|
||||||
if (TimiJava.isNotEmpty(detail.getSendFrom())) {
|
|
||||||
detail.setFromUser(userMap.get(detail.getSendFrom()));
|
|
||||||
}
|
}
|
||||||
if (TimiJava.isNotEmpty(detail.getSendTo())) {
|
|
||||||
detail.setToUser(userMap.get(detail.getSendTo()));
|
/// 查询管理端通知列表
|
||||||
|
///
|
||||||
|
/// @param page 分页参数
|
||||||
|
/// @return 管理端通知列表
|
||||||
|
@JsonView(ResponseView.Admin.class)
|
||||||
|
@RequireCorePermission(CorePermissionCode.NOTIFY_READ)
|
||||||
|
@RequiredToken
|
||||||
|
@PostMapping("/management/list")
|
||||||
|
public PageResult<NotifyManagementItem> managementList(@RequestBody(required = false) Page<Notify> page) {
|
||||||
|
return service.pageManagement(page, userLoginService.getRequireLoginUserId());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
notify.setDetailList(detailList);
|
/// 查询管理端通知详情及收件人
|
||||||
}
|
///
|
||||||
return notify;
|
/// @param id 通知 ID
|
||||||
|
/// @return 通知详情及收件人
|
||||||
|
@JsonView(ResponseView.Admin.class)
|
||||||
|
@RequireCorePermission(CorePermissionCode.NOTIFY_READ)
|
||||||
|
@RequiredToken
|
||||||
|
@PostMapping("/management/detail")
|
||||||
|
public Notify managementDetail(@RequestParam String id) {
|
||||||
|
return fillDetailList(service.getManagement(id, userLoginService.getRequireLoginUserId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 删除通知及其通知详情
|
/// 删除通知及其通知详情
|
||||||
@@ -111,6 +118,26 @@ public class NotifyController {
|
|||||||
service.cancel(id);
|
service.cancel(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 删除管理端通知及其通知详情
|
||||||
|
///
|
||||||
|
/// @param id 通知 ID
|
||||||
|
@RequireCorePermission(CorePermissionCode.NOTIFY_DELETE)
|
||||||
|
@RequiredToken
|
||||||
|
@PostMapping("/management/delete")
|
||||||
|
public void managementDelete(@RequestParam String id) {
|
||||||
|
service.deleteManagement(id, userLoginService.getRequireLoginUserId());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 取消管理端尚未成功发送的通知
|
||||||
|
///
|
||||||
|
/// @param id 通知 ID
|
||||||
|
@RequireCorePermission(CorePermissionCode.NOTIFY_CANCEL)
|
||||||
|
@RequiredToken
|
||||||
|
@PostMapping("/management/cancel")
|
||||||
|
public void managementCancel(@RequestParam String id) {
|
||||||
|
service.cancelManagement(id, userLoginService.getRequireLoginUserId());
|
||||||
|
}
|
||||||
|
|
||||||
@AOPLog
|
@AOPLog
|
||||||
@CaptchaValid
|
@CaptchaValid
|
||||||
@RequestRateLimit(value = 1, inSeconds = 59)
|
@RequestRateLimit(value = 1, inSeconds = 59)
|
||||||
@@ -149,14 +176,14 @@ public class NotifyController {
|
|||||||
return detail;
|
return detail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 删除当前用户的一条站内通知
|
/// 隐藏当前用户的一条站内通知
|
||||||
///
|
///
|
||||||
/// @param id 通知详情 ID
|
/// @param id 通知详情 ID
|
||||||
@RequireCorePermission(CorePermissionCode.NOTIFY_READ)
|
@RequireCorePermission(CorePermissionCode.NOTIFY_READ)
|
||||||
@RequiredToken
|
@RequiredToken
|
||||||
@PostMapping("/internal/delete")
|
@PostMapping("/internal/delete")
|
||||||
public void deleteInternal(@RequestParam String id) {
|
public void deleteInternal(@RequestParam String id) {
|
||||||
detailService.deleteInternalByUserId(id, userLoginService.getRequireLoginUserId());
|
detailService.hideInternalByUserId(id, userLoginService.getRequireLoginUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 查询当前用户未读通知数量
|
/// 查询当前用户未读通知数量
|
||||||
@@ -186,4 +213,30 @@ public class NotifyController {
|
|||||||
public void markAllSiteRead() {
|
public void markAllSiteRead() {
|
||||||
detailService.markAllSiteRead(userLoginService.getRequireLoginUserId());
|
detailService.markAllSiteRead(userLoginService.getRequireLoginUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 回填通知详情中的用户信息
|
||||||
|
///
|
||||||
|
/// @param notify 通知
|
||||||
|
/// @return 已回填用户信息的通知
|
||||||
|
private Notify fillDetailList(Notify notify) {
|
||||||
|
if (notify == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
List<NotifyDetail> detailList = detailService.listByNotifyId(notify.getId());
|
||||||
|
Set<String> userIdSet = detailList.stream()
|
||||||
|
.filter(item -> item.getMsgType() == NotifyDetail.MsgType.INTERNAL)
|
||||||
|
.flatMap(item -> Stream.of(item.getSendFrom(), item.getSendTo()))
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
Map<String, User> userMap = userService.mapByIdList(userIdSet);
|
||||||
|
for (NotifyDetail detail : detailList) {
|
||||||
|
if (TimiJava.isNotEmpty(detail.getSendFrom())) {
|
||||||
|
detail.setFromUser(userMap.get(detail.getSendFrom()));
|
||||||
|
}
|
||||||
|
if (TimiJava.isNotEmpty(detail.getSendTo())) {
|
||||||
|
detail.setToUser(userMap.get(detail.getSendTo()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
notify.setDetailList(detailList);
|
||||||
|
return notify;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ public class Attachment extends UUIDEntity {
|
|||||||
|
|
||||||
ARTICLE,
|
ARTICLE,
|
||||||
|
|
||||||
|
NOTIFY_DETAIL,
|
||||||
|
|
||||||
USER,
|
USER,
|
||||||
|
|
||||||
GAO_CUSTOMER,
|
GAO_CUSTOMER,
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public class BaseQueueEntity implements IDEntity<String>, Creatable, Destroyable
|
|||||||
protected String notifyDetailId;
|
protected String notifyDetailId;
|
||||||
|
|
||||||
/** 内容 */
|
/** 内容 */
|
||||||
protected String data;
|
protected String content;
|
||||||
|
|
||||||
/** 参数 */
|
/** 参数 */
|
||||||
protected JsonNode args;
|
protected JsonNode args;
|
||||||
@@ -51,7 +51,7 @@ public class BaseQueueEntity implements IDEntity<String>, Creatable, Destroyable
|
|||||||
/// @param detail 通知详情
|
/// @param detail 通知详情
|
||||||
public BaseQueueEntity(NotifyDetail detail) {
|
public BaseQueueEntity(NotifyDetail detail) {
|
||||||
notifyDetailId = detail.getId();
|
notifyDetailId = detail.getId();
|
||||||
data = detail.getData();
|
content = detail.getContent();
|
||||||
args = detail.getArgs();
|
args = detail.getArgs();
|
||||||
sendTo = detail.getSendTo();
|
sendTo = detail.getSendTo();
|
||||||
sendAt = detail.getSendAt();
|
sendAt = detail.getSendAt();
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.imyeyu.api.modules.common.entity;
|
package com.imyeyu.api.modules.common.entity;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonView;
|
import com.fasterxml.jackson.annotation.JsonView;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.imyeyu.api.TimiServerAPI;
|
import com.imyeyu.api.TimiServerAPI;
|
||||||
@@ -16,6 +17,8 @@ import lombok.AllArgsConstructor;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通知详情
|
* 通知详情
|
||||||
*
|
*
|
||||||
@@ -82,6 +85,19 @@ public class NotifyDetail extends UUIDEntity {
|
|||||||
FAIL
|
FAIL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 内容类型
|
||||||
|
///
|
||||||
|
/// @author 夜雨
|
||||||
|
/// @since 2026-08-24
|
||||||
|
public enum ContentType {
|
||||||
|
|
||||||
|
/** 纯文本 */
|
||||||
|
TEXT,
|
||||||
|
|
||||||
|
/** TipTap 富文本 */
|
||||||
|
TIP_TAP
|
||||||
|
}
|
||||||
|
|
||||||
/** 所属通知 ID */
|
/** 所属通知 ID */
|
||||||
@JsonView(ResponseView.Public.class)
|
@JsonView(ResponseView.Public.class)
|
||||||
private String notifyId;
|
private String notifyId;
|
||||||
@@ -100,7 +116,11 @@ public class NotifyDetail extends UUIDEntity {
|
|||||||
|
|
||||||
/** 内容 */
|
/** 内容 */
|
||||||
@JsonView(ResponseView.Public.class)
|
@JsonView(ResponseView.Public.class)
|
||||||
private String data;
|
private String content;
|
||||||
|
|
||||||
|
/// 内容类型
|
||||||
|
@JsonView(ResponseView.Public.class)
|
||||||
|
private ContentType contentType;
|
||||||
|
|
||||||
/** 参数 */
|
/** 参数 */
|
||||||
@JsonView(ResponseView.Public.class)
|
@JsonView(ResponseView.Public.class)
|
||||||
@@ -138,6 +158,10 @@ public class NotifyDetail extends UUIDEntity {
|
|||||||
@JsonView(ResponseView.Public.class)
|
@JsonView(ResponseView.Public.class)
|
||||||
private Long readAt;
|
private Long readAt;
|
||||||
|
|
||||||
|
/// 收件人隐藏时间,仅站内通知生效
|
||||||
|
@JsonIgnore
|
||||||
|
private Long hiddenAt;
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
protected Notify notify;
|
protected Notify notify;
|
||||||
|
|
||||||
@@ -146,4 +170,9 @@ public class NotifyDetail extends UUIDEntity {
|
|||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
protected User toUser;
|
protected User toUser;
|
||||||
|
|
||||||
|
/// 媒体附件列表
|
||||||
|
@JsonView(ResponseView.Public.class)
|
||||||
|
@Transient
|
||||||
|
protected List<Attachment> attachmentList;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,6 +71,14 @@ public interface AttachmentVariantMapper {
|
|||||||
/// @param variant 变体
|
/// @param variant 变体
|
||||||
void insert(AttachmentVariant variant);
|
void insert(AttachmentVariant variant);
|
||||||
|
|
||||||
|
/// 延长缩略图变体的过期时间
|
||||||
|
///
|
||||||
|
/// @param id 变体 ID
|
||||||
|
/// @param now 当前时间
|
||||||
|
/// @param expireAt 新的过期时间
|
||||||
|
/// @return 更新记录数
|
||||||
|
int updateExpireAt(@Param("id") String id, @Param("now") long now, @Param("expireAt") long expireAt);
|
||||||
|
|
||||||
/// 删除变体
|
/// 删除变体
|
||||||
///
|
///
|
||||||
/// @param id 变体 ID
|
/// @param id 变体 ID
|
||||||
|
|||||||
@@ -16,35 +16,37 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public interface NotifyDetailMapper extends BaseMapper<NotifyDetail, String> {
|
public interface NotifyDetailMapper extends BaseMapper<NotifyDetail, String> {
|
||||||
|
|
||||||
|
String NOT_HIDDEN = " AND `hidden_at` IS NULL";
|
||||||
|
|
||||||
/** 查询用户的站内通知 */
|
/** 查询用户的站内通知 */
|
||||||
@Select("SELECT * FROM `notify_detail` WHERE `msg_type` = 'INTERNAL' AND `send_to` = #{userId} " + NOT_DELETE + " ORDER BY `created_at` DESC LIMIT #{offset}, #{limit}")
|
@Select("SELECT * FROM `notify_detail` WHERE `msg_type` = 'INTERNAL' AND `send_to` = #{userId} AND `send_at` < " + UNIX_TIME + NOT_HIDDEN + NOT_DELETE + " ORDER BY `created_at` DESC LIMIT #{offset}, #{limit}")
|
||||||
List<NotifyDetail> selectSiteByUserId(@Param("userId") String userId, @Param("offset") long offset, @Param("limit") long limit);
|
List<NotifyDetail> selectSiteByUserId(@Param("userId") String userId, @Param("offset") long offset, @Param("limit") long limit);
|
||||||
|
|
||||||
/** 查询用户的未读站内通知 */
|
/** 查询用户的未读站内通知 */
|
||||||
@Select("SELECT * FROM `notify_detail` WHERE `msg_type` = 'INTERNAL' AND `send_to` = #{userId} AND `read_at` IS NULL " + NOT_DELETE + " ORDER BY `created_at` DESC LIMIT #{offset}, #{limit}")
|
@Select("SELECT * FROM `notify_detail` WHERE `msg_type` = 'INTERNAL' AND `send_to` = #{userId} AND `send_at` < " + UNIX_TIME + " AND `read_at` IS NULL " + NOT_HIDDEN + NOT_DELETE + " ORDER BY `created_at` DESC LIMIT #{offset}, #{limit}")
|
||||||
List<NotifyDetail> selectUnreadSiteByUserId(@Param("userId") String userId, @Param("offset") long offset, @Param("limit") long limit);
|
List<NotifyDetail> selectUnreadSiteByUserId(@Param("userId") String userId, @Param("offset") long offset, @Param("limit") long limit);
|
||||||
|
|
||||||
/** 统计用户的站内通知数量 */
|
/** 统计用户的站内通知数量 */
|
||||||
@Select("SELECT COUNT(*) FROM `notify_detail` WHERE `msg_type` = 'INTERNAL' AND `send_to` = #{userId} " + NOT_DELETE)
|
@Select("SELECT COUNT(*) FROM `notify_detail` WHERE `msg_type` = 'INTERNAL' AND `send_to` = #{userId} AND `send_at` < " + UNIX_TIME + NOT_HIDDEN + NOT_DELETE)
|
||||||
long countSiteByUserId(@Param("userId") String userId);
|
long countSiteByUserId(@Param("userId") String userId);
|
||||||
|
|
||||||
/** 统计用户的未读站内通知数量 */
|
/** 统计用户的未读站内通知数量 */
|
||||||
@Select("SELECT COUNT(*) FROM `notify_detail` WHERE `msg_type` = 'INTERNAL' AND `send_to` = #{userId} AND `read_at` IS NULL " + NOT_DELETE)
|
@Select("SELECT COUNT(*) FROM `notify_detail` WHERE `msg_type` = 'INTERNAL' AND `send_to` = #{userId} AND `send_at` < " + UNIX_TIME + " AND `read_at` IS NULL " + NOT_HIDDEN + NOT_DELETE)
|
||||||
long countUnreadSiteByUserId(@Param("userId") String userId);
|
long countUnreadSiteByUserId(@Param("userId") String userId);
|
||||||
|
|
||||||
/** 查询用户拥有的站内通知 */
|
/** 查询用户拥有的站内通知 */
|
||||||
@Select("SELECT * FROM `notify_detail` WHERE `id` = #{detailId} AND `msg_type` = 'INTERNAL' AND `send_to` = #{userId} " + NOT_DELETE + " LIMIT 1")
|
@Select("SELECT * FROM `notify_detail` WHERE `id` = #{detailId} AND `msg_type` = 'INTERNAL' AND `send_to` = #{userId} AND `send_at` < " + UNIX_TIME + NOT_HIDDEN + NOT_DELETE + " LIMIT 1")
|
||||||
NotifyDetail selectSiteByIdAndUserId(@Param("detailId") String detailId, @Param("userId") String userId);
|
NotifyDetail selectSiteByIdAndUserId(@Param("detailId") String detailId, @Param("userId") String userId);
|
||||||
|
|
||||||
/** 删除用户的站内通知 */
|
/** 隐藏用户的站内通知 */
|
||||||
@Update("UPDATE `notify_detail` SET `deleted_at` = " + UNIX_TIME + ", `updated_at` = " + UNIX_TIME + " WHERE `id` = #{detailId} AND `msg_type` = 'INTERNAL' AND `send_to` = #{userId} " + NOT_DELETE)
|
@Update("UPDATE `notify_detail` SET `hidden_at` = " + UNIX_TIME + ", `updated_at` = " + UNIX_TIME + " WHERE `id` = #{detailId} AND `msg_type` = 'INTERNAL' AND `send_to` = #{userId} AND `send_at` < " + UNIX_TIME + NOT_HIDDEN + NOT_DELETE)
|
||||||
int deleteSiteByIdAndUserId(@Param("detailId") String detailId, @Param("userId") String userId);
|
int hideSiteByIdAndUserId(@Param("detailId") String detailId, @Param("userId") String userId);
|
||||||
|
|
||||||
/** 标记站内通知已读 */
|
/** 标记站内通知已读 */
|
||||||
@Update("UPDATE `notify_detail` SET `read_at` = #{readAt}, `updated_at` = " + UNIX_TIME + " WHERE `id` = #{detailId} AND `msg_type` = 'INTERNAL' AND `send_to` = #{userId} AND `read_at` IS NULL " + NOT_DELETE)
|
@Update("UPDATE `notify_detail` SET `read_at` = #{readAt}, `updated_at` = " + UNIX_TIME + " WHERE `id` = #{detailId} AND `msg_type` = 'INTERNAL' AND `send_to` = #{userId} AND `send_at` < " + UNIX_TIME + " AND `read_at` IS NULL " + NOT_HIDDEN + NOT_DELETE)
|
||||||
int markSiteRead(@Param("detailId") String detailId, @Param("userId") String userId, @Param("readAt") long readAt);
|
int markSiteRead(@Param("detailId") String detailId, @Param("userId") String userId, @Param("readAt") long readAt);
|
||||||
|
|
||||||
/** 标记用户全部站内通知已读 */
|
/** 标记用户全部站内通知已读 */
|
||||||
@Update("UPDATE `notify_detail` SET `read_at` = #{readAt}, `updated_at` = " + UNIX_TIME + " WHERE `msg_type` = 'INTERNAL' AND `send_to` = #{userId} AND `read_at` IS NULL " + NOT_DELETE)
|
@Update("UPDATE `notify_detail` SET `read_at` = #{readAt}, `updated_at` = " + UNIX_TIME + " WHERE `msg_type` = 'INTERNAL' AND `send_to` = #{userId} AND `send_at` < " + UNIX_TIME + " AND `read_at` IS NULL " + NOT_HIDDEN + NOT_DELETE)
|
||||||
int markAllSiteRead(@Param("userId") String userId, @Param("readAt") long readAt);
|
int markAllSiteRead(@Param("userId") String userId, @Param("readAt") long readAt);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
package com.imyeyu.api.modules.common.mapper;
|
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 org.apache.ibatis.annotations.Param;
|
||||||
import com.imyeyu.spring.mapper.BaseMapper;
|
import com.imyeyu.spring.mapper.BaseMapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通知 Mapper
|
* 通知 Mapper
|
||||||
*
|
*
|
||||||
@@ -10,4 +14,25 @@ import com.imyeyu.spring.mapper.BaseMapper;
|
|||||||
* @since 2026-05-13 14:46
|
* @since 2026-05-13 14:46
|
||||||
*/
|
*/
|
||||||
public interface NotifyMapper extends BaseMapper<Notify, String> {
|
public interface NotifyMapper extends BaseMapper<Notify, String> {
|
||||||
|
|
||||||
|
/// 分页查询管理端通知
|
||||||
|
///
|
||||||
|
/// @param userId 管理员用户 ID
|
||||||
|
/// @param offset 分页偏移量
|
||||||
|
/// @param limit 分页大小
|
||||||
|
/// @return 通知列表
|
||||||
|
List<NotifyManagementItem> selectManagementPage(@Param("userId") String userId, @Param("offset") long offset, @Param("limit") long limit);
|
||||||
|
|
||||||
|
/// 统计管理端通知数量
|
||||||
|
///
|
||||||
|
/// @param userId 管理员用户 ID
|
||||||
|
/// @return 通知数量
|
||||||
|
long countManagement(@Param("userId") String userId);
|
||||||
|
|
||||||
|
/// 查询管理员可管理的通知
|
||||||
|
///
|
||||||
|
/// @param notifyId 通知 ID
|
||||||
|
/// @param userId 管理员用户 ID
|
||||||
|
/// @return 通知
|
||||||
|
Notify selectManagement(@Param("notifyId") String notifyId, @Param("userId") String userId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,11 +41,11 @@ public interface NotifyDetailService extends BaseService<NotifyDetail, String> {
|
|||||||
/// @return 通知详情
|
/// @return 通知详情
|
||||||
NotifyDetail getInternalByUserId(String detailId, String userId);
|
NotifyDetail getInternalByUserId(String detailId, String userId);
|
||||||
|
|
||||||
/// 删除当前用户拥有的站内通知详情
|
/// 隐藏当前用户拥有的站内通知详情
|
||||||
///
|
///
|
||||||
/// @param detailId 通知详情 ID
|
/// @param detailId 通知详情 ID
|
||||||
/// @param userId 用户 ID
|
/// @param userId 用户 ID
|
||||||
void deleteInternalByUserId(String detailId, String userId);
|
void hideInternalByUserId(String detailId, String userId);
|
||||||
|
|
||||||
/// 查询用户未读站内通知数量
|
/// 查询用户未读站内通知数量
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
package com.imyeyu.api.modules.common.service;
|
package com.imyeyu.api.modules.common.service;
|
||||||
|
|
||||||
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.spring.bean.Page;
|
||||||
|
import com.imyeyu.spring.bean.PageResult;
|
||||||
import com.imyeyu.spring.service.BaseService;
|
import com.imyeyu.spring.service.BaseService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -11,6 +14,32 @@ import com.imyeyu.spring.service.BaseService;
|
|||||||
*/
|
*/
|
||||||
public interface NotifyService extends BaseService<Notify, String> {
|
public interface NotifyService extends BaseService<Notify, String> {
|
||||||
|
|
||||||
|
/// 分页查询当前用户创建的通知
|
||||||
|
///
|
||||||
|
/// @param page 分页参数
|
||||||
|
/// @param userId 用户 ID
|
||||||
|
/// @return 管理端通知列表
|
||||||
|
PageResult<NotifyManagementItem> pageManagement(Page<Notify> page, String userId);
|
||||||
|
|
||||||
|
/// 查询当前用户可管理的通知
|
||||||
|
///
|
||||||
|
/// @param notifyId 通知 ID
|
||||||
|
/// @param userId 用户 ID
|
||||||
|
/// @return 通知
|
||||||
|
Notify getManagement(String notifyId, String userId);
|
||||||
|
|
||||||
|
/// 删除当前用户创建的通知
|
||||||
|
///
|
||||||
|
/// @param notifyId 通知 ID
|
||||||
|
/// @param userId 用户 ID
|
||||||
|
void deleteManagement(String notifyId, String userId);
|
||||||
|
|
||||||
|
/// 取消当前用户创建的通知
|
||||||
|
///
|
||||||
|
/// @param notifyId 通知 ID
|
||||||
|
/// @param userId 用户 ID
|
||||||
|
void cancelManagement(String notifyId, String userId);
|
||||||
|
|
||||||
/// 取消通知中尚未成功发送的通知详情
|
/// 取消通知中尚未成功发送的通知详情
|
||||||
///
|
///
|
||||||
/// @param notifyId 通知 ID
|
/// @param notifyId 通知 ID
|
||||||
|
|||||||
+26
-3
@@ -112,7 +112,10 @@ public class AttachmentVariantServiceImplement implements AttachmentVariantServi
|
|||||||
now
|
now
|
||||||
);
|
);
|
||||||
if (cached != null) {
|
if (cached != null) {
|
||||||
return cached;
|
Attachment refreshed = refreshCachedThumb(cached);
|
||||||
|
if (refreshed != null) {
|
||||||
|
return refreshed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String lockKey = buildThumbLockKey(source, width, height, fitMode);
|
String lockKey = buildThumbLockKey(source, width, height, fitMode);
|
||||||
@@ -131,7 +134,10 @@ public class AttachmentVariantServiceImplement implements AttachmentVariantServi
|
|||||||
Time.now()
|
Time.now()
|
||||||
);
|
);
|
||||||
if (cached != null) {
|
if (cached != null) {
|
||||||
return cached;
|
Attachment refreshed = refreshCachedThumb(cached);
|
||||||
|
if (refreshed != null) {
|
||||||
|
return refreshed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
AttachmentVariant oldVariant = variantMapper.selectByKey(
|
AttachmentVariant oldVariant = variantMapper.selectByKey(
|
||||||
source.getId(),
|
source.getId(),
|
||||||
@@ -197,7 +203,10 @@ public class AttachmentVariantServiceImplement implements AttachmentVariantServi
|
|||||||
Time.now()
|
Time.now()
|
||||||
);
|
);
|
||||||
if (concurrent != null) {
|
if (concurrent != null) {
|
||||||
return concurrent;
|
Attachment refreshed = refreshCachedThumb(concurrent);
|
||||||
|
if (refreshed != null) {
|
||||||
|
return refreshed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
@@ -223,6 +232,20 @@ public class AttachmentVariantServiceImplement implements AttachmentVariantServi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 延长已命中缩略图缓存的有效期
|
||||||
|
///
|
||||||
|
/// @param cached 已命中的缩略图
|
||||||
|
/// @return 更新成功时返回刷新后的缩略图,记录已不存在或已过期时返回 `null`
|
||||||
|
private Attachment refreshCachedThumb(Attachment cached) {
|
||||||
|
long now = Time.now();
|
||||||
|
long expireAt = now + THUMB_CACHE_TTL;
|
||||||
|
if (!(0 < variantMapper.updateExpireAt(cached.getId(), now, expireAt))) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
cached.setDestroyAt(expireAt);
|
||||||
|
return cached;
|
||||||
|
}
|
||||||
|
|
||||||
private String buildThumbLockKey(Attachment source, int width, int height, ThumbnailFitMode fitMode) {
|
private String buildThumbLockKey(Attachment source, int width, int height, ThumbnailFitMode fitMode) {
|
||||||
return "%s%s:%s:%s:%s:%s".formatted(
|
return "%s%s:%s:%s:%s:%s".formatted(
|
||||||
THUMB_LOCK_KEY_PREFIX,
|
THUMB_LOCK_KEY_PREFIX,
|
||||||
|
|||||||
+1
-1
@@ -60,7 +60,7 @@ public class MailQueueServiceImplement extends AbstractQueueService<MailQueue, N
|
|||||||
message.setFrom(queue.getSendFrom());
|
message.setFrom(queue.getSendFrom());
|
||||||
message.setTo(queue.getSendTo());
|
message.setTo(queue.getSendTo());
|
||||||
message.setSubject(queue.getSubject());
|
message.setSubject(queue.getSubject());
|
||||||
message.setText(queue.getData());
|
message.setText(queue.getContent());
|
||||||
mailSender.send(message);
|
mailSender.send(message);
|
||||||
log.info("邮件发送成功,目标:{}", queue.getSendTo());
|
log.info("邮件发送成功,目标:{}", queue.getSendTo());
|
||||||
}
|
}
|
||||||
|
|||||||
+55
-8
@@ -1,10 +1,12 @@
|
|||||||
package com.imyeyu.api.modules.common.service.implement;
|
package com.imyeyu.api.modules.common.service.implement;
|
||||||
|
|
||||||
import com.imyeyu.api.config.dbsource.TimiServerDBConfig;
|
import com.imyeyu.api.config.dbsource.TimiServerDBConfig;
|
||||||
import com.imyeyu.api.modules.common.entity.NotifyDetail;
|
import com.imyeyu.api.modules.common.entity.Attachment;
|
||||||
import com.imyeyu.api.modules.common.entity.Notify;
|
import com.imyeyu.api.modules.common.entity.Notify;
|
||||||
|
import com.imyeyu.api.modules.common.entity.NotifyDetail;
|
||||||
import com.imyeyu.api.modules.common.mapper.NotifyDetailMapper;
|
import com.imyeyu.api.modules.common.mapper.NotifyDetailMapper;
|
||||||
import com.imyeyu.api.modules.common.mapper.NotifyMapper;
|
import com.imyeyu.api.modules.common.mapper.NotifyMapper;
|
||||||
|
import com.imyeyu.api.modules.common.service.AttachmentService;
|
||||||
import com.imyeyu.api.modules.common.service.NotifyDetailService;
|
import com.imyeyu.api.modules.common.service.NotifyDetailService;
|
||||||
import com.imyeyu.java.TimiJava;
|
import com.imyeyu.java.TimiJava;
|
||||||
import com.imyeyu.java.bean.timi.TimiCode;
|
import com.imyeyu.java.bean.timi.TimiCode;
|
||||||
@@ -19,6 +21,7 @@ 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.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通知详情服务实现
|
* 通知详情服务实现
|
||||||
@@ -31,6 +34,7 @@ import java.util.List;
|
|||||||
public class NotifyDetailServiceImplement extends AbstractEntityService<NotifyDetail, String> implements NotifyDetailService {
|
public class NotifyDetailServiceImplement extends AbstractEntityService<NotifyDetail, String> implements NotifyDetailService {
|
||||||
|
|
||||||
private final NotifyMapper notifyMapper;
|
private final NotifyMapper notifyMapper;
|
||||||
|
private final AttachmentService attachmentService;
|
||||||
|
|
||||||
private final NotifyDetailMapper mapper;
|
private final NotifyDetailMapper mapper;
|
||||||
|
|
||||||
@@ -53,15 +57,22 @@ public class NotifyDetailServiceImplement extends AbstractEntityService<NotifyDe
|
|||||||
if (detail.getMsgType() == NotifyDetail.MsgType.INTERNAL) {
|
if (detail.getMsgType() == NotifyDetail.MsgType.INTERNAL) {
|
||||||
TimiException.required(detail.getSendTo(), "未找到站内通知接收用户 ID");
|
TimiException.required(detail.getSendTo(), "未找到站内通知接收用户 ID");
|
||||||
}
|
}
|
||||||
|
detail.setContentType(TimiJava.defaultIfNull(detail.getContentType(), detail.getMsgType() == NotifyDetail.MsgType.INTERNAL
|
||||||
|
? NotifyDetail.ContentType.TIP_TAP
|
||||||
|
: NotifyDetail.ContentType.TEXT));
|
||||||
|
|
||||||
detail.setRetry(TimiJava.defaultIfNull(detail.getRetry(), 1));
|
detail.setRetry(TimiJava.defaultIfNull(detail.getRetry(), 1));
|
||||||
detail.setSendAt(TimiJava.defaultIfNull(detail.getSendAt(), Time.now()));
|
detail.setSendAt(TimiJava.defaultIfNull(detail.getSendAt(), Time.now()));
|
||||||
detail.setTimeoutAt(TimiJava.defaultIfNull(detail.getTimeoutAt(), detail.getSendAt() + Time.D));
|
detail.setTimeoutAt(TimiJava.defaultIfNull(detail.getTimeoutAt(), detail.getSendAt() + Time.D));
|
||||||
detail.setStatus(detail.getMsgType() == NotifyDetail.MsgType.INTERNAL
|
boolean scheduled = Time.now() < detail.getSendAt();
|
||||||
|
detail.setStatus(detail.getMsgType() == NotifyDetail.MsgType.INTERNAL && !scheduled
|
||||||
? NotifyDetail.Status.REMINDED
|
? NotifyDetail.Status.REMINDED
|
||||||
: NotifyDetail.Status.WAITING);
|
: NotifyDetail.Status.WAITING);
|
||||||
detail.setReadAt(null);
|
detail.setReadAt(null);
|
||||||
super.create(detail);
|
super.create(detail);
|
||||||
|
if (detail.getMsgType() == NotifyDetail.MsgType.INTERNAL) {
|
||||||
|
attachmentService.updateByBizId(Attachment.BizType.NOTIFY_DETAIL, detail.getId(), detail.getAttachmentList());
|
||||||
|
}
|
||||||
|
|
||||||
if (detail.getMsgType().isQueue()) {
|
if (detail.getMsgType().isQueue()) {
|
||||||
// 加入外部消息队列
|
// 加入外部消息队列
|
||||||
@@ -77,7 +88,9 @@ public class NotifyDetailServiceImplement extends AbstractEntityService<NotifyDe
|
|||||||
public List<NotifyDetail> listByNotifyId(String notifyId) {
|
public List<NotifyDetail> listByNotifyId(String notifyId) {
|
||||||
NotifyDetail example = new NotifyDetail();
|
NotifyDetail example = new NotifyDetail();
|
||||||
example.setNotifyId(notifyId);
|
example.setNotifyId(notifyId);
|
||||||
return mapper.selectAllByExample(example);
|
List<NotifyDetail> detailList = mapper.selectAllByExample(example);
|
||||||
|
loadAttachments(detailList);
|
||||||
|
return detailList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 删除通知详情
|
/// 删除通知详情
|
||||||
@@ -135,9 +148,11 @@ public class NotifyDetailServiceImplement extends AbstractEntityService<NotifyDe
|
|||||||
result.setTotal(unreadOnly
|
result.setTotal(unreadOnly
|
||||||
? mapper.countUnreadSiteByUserId(userId)
|
? mapper.countUnreadSiteByUserId(userId)
|
||||||
: mapper.countSiteByUserId(userId));
|
: mapper.countSiteByUserId(userId));
|
||||||
result.setList(unreadOnly
|
List<NotifyDetail> detailList = unreadOnly
|
||||||
? mapper.selectUnreadSiteByUserId(userId, validPage.getOffset(), validPage.getLimit())
|
? mapper.selectUnreadSiteByUserId(userId, validPage.getOffset(), validPage.getLimit())
|
||||||
: mapper.selectSiteByUserId(userId, validPage.getOffset(), validPage.getLimit()));
|
: mapper.selectSiteByUserId(userId, validPage.getOffset(), validPage.getLimit());
|
||||||
|
loadAttachments(detailList);
|
||||||
|
result.setList(detailList);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,19 +167,51 @@ public class NotifyDetailServiceImplement extends AbstractEntityService<NotifyDe
|
|||||||
TimiException.required(userId, "未找到用户 ID");
|
TimiException.required(userId, "未找到用户 ID");
|
||||||
NotifyDetail detail = mapper.selectSiteByIdAndUserId(detailId, userId);
|
NotifyDetail detail = mapper.selectSiteByIdAndUserId(detailId, userId);
|
||||||
TimiException.required(detail, "未找到站内通知");
|
TimiException.required(detail, "未找到站内通知");
|
||||||
|
loadAttachments(detail);
|
||||||
return detail;
|
return detail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 删除当前用户拥有的站内通知详情
|
/// 回填通知详情的媒体附件
|
||||||
|
///
|
||||||
|
/// @param detailList 通知详情列表
|
||||||
|
private void loadAttachments(List<NotifyDetail> detailList) {
|
||||||
|
List<String> detailIdList = detailList.stream()
|
||||||
|
.filter(detail -> detail.getMsgType() == NotifyDetail.MsgType.INTERNAL)
|
||||||
|
.map(NotifyDetail::getId)
|
||||||
|
.toList();
|
||||||
|
if (detailIdList.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Map<String, List<Attachment>> attachmentMap = attachmentService.mapByBizIdList(
|
||||||
|
Attachment.BizType.NOTIFY_DETAIL,
|
||||||
|
detailIdList
|
||||||
|
);
|
||||||
|
for (NotifyDetail detail : detailList) {
|
||||||
|
if (detail.getMsgType() == NotifyDetail.MsgType.INTERNAL) {
|
||||||
|
detail.setAttachmentList(attachmentMap.getOrDefault(detail.getId(), List.of()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 回填通知详情的媒体附件
|
||||||
|
///
|
||||||
|
/// @param detail 通知详情
|
||||||
|
private void loadAttachments(NotifyDetail detail) {
|
||||||
|
if (detail.getMsgType() == NotifyDetail.MsgType.INTERNAL) {
|
||||||
|
detail.setAttachmentList(attachmentService.listByBizId(Attachment.BizType.NOTIFY_DETAIL, detail.getId()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 隐藏当前用户拥有的站内通知详情
|
||||||
///
|
///
|
||||||
/// @param detailId 通知详情 ID
|
/// @param detailId 通知详情 ID
|
||||||
/// @param userId 用户 ID
|
/// @param userId 用户 ID
|
||||||
@Override
|
@Override
|
||||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||||
public void deleteInternalByUserId(String detailId, String userId) {
|
public void hideInternalByUserId(String detailId, String userId) {
|
||||||
TimiException.required(detailId, "未找到通知详情 ID");
|
TimiException.required(detailId, "未找到通知详情 ID");
|
||||||
TimiException.required(userId, "未找到用户 ID");
|
TimiException.required(userId, "未找到用户 ID");
|
||||||
int affected = mapper.deleteSiteByIdAndUserId(detailId, userId);
|
int affected = mapper.hideSiteByIdAndUserId(detailId, userId);
|
||||||
TimiException.requiredTrue(0 < affected, "未找到站内通知");
|
TimiException.requiredTrue(0 < affected, "未找到站内通知");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+54
-4
@@ -8,10 +8,13 @@ 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.entity.Logger;
|
||||||
import com.imyeyu.api.modules.system.service.LoggerService;
|
import com.imyeyu.api.modules.system.service.LoggerService;
|
||||||
|
import com.imyeyu.api.modules.common.vo.NotifyManagementItem;
|
||||||
import com.imyeyu.api.modules.user.service.UserLoginService;
|
import com.imyeyu.api.modules.user.service.UserLoginService;
|
||||||
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;
|
||||||
|
import com.imyeyu.spring.bean.Page;
|
||||||
|
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 lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@@ -53,12 +56,10 @@ public class NotifyServiceImplement extends AbstractEntityService<Notify, String
|
|||||||
try {
|
try {
|
||||||
TimiException.required(notify, "未找到通知");
|
TimiException.required(notify, "未找到通知");
|
||||||
TimiException.required(notify.getDetailList(), "未找到通知详情列表");
|
TimiException.required(notify.getDetailList(), "未找到通知详情列表");
|
||||||
|
String sendFrom = userLoginService.isLogged() ? userLoginService.getRequireLoginUserId() : null;
|
||||||
|
notify.setCreatedBy(sendFrom);
|
||||||
super.create(notify);
|
super.create(notify);
|
||||||
|
|
||||||
String sendFrom = null;
|
|
||||||
if (userLoginService.isLogged()) {
|
|
||||||
sendFrom = userLoginService.getRequireLoginUserId();
|
|
||||||
}
|
|
||||||
for (NotifyDetail detail : notify.getDetailList()) {
|
for (NotifyDetail detail : notify.getDetailList()) {
|
||||||
detail.setNotifyId(notify.getId());
|
detail.setNotifyId(notify.getId());
|
||||||
if (TimiJava.isNotEmpty(sendFrom)) {
|
if (TimiJava.isNotEmpty(sendFrom)) {
|
||||||
@@ -82,6 +83,55 @@ public class NotifyServiceImplement extends AbstractEntityService<Notify, String
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 分页查询当前用户创建的通知
|
||||||
|
///
|
||||||
|
/// @param page 分页参数
|
||||||
|
/// @param userId 用户 ID
|
||||||
|
/// @return 管理端通知列表
|
||||||
|
@Override
|
||||||
|
public PageResult<NotifyManagementItem> pageManagement(Page<Notify> page, String userId) {
|
||||||
|
TimiException.required(userId, "未找到用户 ID");
|
||||||
|
Page<Notify> validPage = TimiJava.defaultIfNull(page, new Page<>());
|
||||||
|
PageResult<NotifyManagementItem> result = new PageResult<>();
|
||||||
|
result.setTotal(mapper.countManagement(userId));
|
||||||
|
result.setList(mapper.selectManagementPage(userId, validPage.getOffset(), validPage.getLimit()));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 查询当前用户可管理的通知
|
||||||
|
///
|
||||||
|
/// @param notifyId 通知 ID
|
||||||
|
/// @param userId 用户 ID
|
||||||
|
/// @return 通知
|
||||||
|
@Override
|
||||||
|
public Notify getManagement(String notifyId, String userId) {
|
||||||
|
TimiException.required(notifyId, "未找到通知 ID");
|
||||||
|
TimiException.required(userId, "未找到用户 ID");
|
||||||
|
Notify notify = mapper.selectManagement(notifyId, userId);
|
||||||
|
TimiException.required(notify, "未找到可管理的通知");
|
||||||
|
return notify;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 删除当前用户创建的通知
|
||||||
|
///
|
||||||
|
/// @param notifyId 通知 ID
|
||||||
|
/// @param userId 用户 ID
|
||||||
|
@Override
|
||||||
|
public void deleteManagement(String notifyId, String userId) {
|
||||||
|
getManagement(notifyId, userId);
|
||||||
|
delete(notifyId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 取消当前用户创建的通知
|
||||||
|
///
|
||||||
|
/// @param notifyId 通知 ID
|
||||||
|
/// @param userId 用户 ID
|
||||||
|
@Override
|
||||||
|
public void cancelManagement(String notifyId, String userId) {
|
||||||
|
getManagement(notifyId, userId);
|
||||||
|
cancel(notifyId);
|
||||||
|
}
|
||||||
|
|
||||||
/// 删除通知并级联软删除通知详情
|
/// 删除通知并级联软删除通知详情
|
||||||
///
|
///
|
||||||
/// @param notifyId 通知 ID
|
/// @param notifyId 通知 ID
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
package com.imyeyu.api.modules.common.vo;
|
||||||
|
|
||||||
|
import com.imyeyu.api.modules.common.entity.NotifyDetail;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/// 管理端通知列表项
|
||||||
|
///
|
||||||
|
/// @author 夜雨
|
||||||
|
/// @since 2026-08-25
|
||||||
|
@Data
|
||||||
|
public class NotifyManagementItem {
|
||||||
|
|
||||||
|
/// 通知 ID
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
/// 创建者用户 ID
|
||||||
|
private String createdBy;
|
||||||
|
|
||||||
|
/// 创建时间
|
||||||
|
private Long createdAt;
|
||||||
|
|
||||||
|
/// 更新时间
|
||||||
|
private Long updatedAt;
|
||||||
|
|
||||||
|
/// 通知标题
|
||||||
|
private String subject;
|
||||||
|
|
||||||
|
/// 通知内容
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
/// 内容类型
|
||||||
|
private NotifyDetail.ContentType contentType;
|
||||||
|
|
||||||
|
/// 发送时间
|
||||||
|
private Long sendAt;
|
||||||
|
|
||||||
|
/// 接收用户数量
|
||||||
|
private Long recipientCount;
|
||||||
|
|
||||||
|
/// 已读用户数量
|
||||||
|
private Long readCount;
|
||||||
|
|
||||||
|
/// 等待发送数量
|
||||||
|
private Long waitingCount;
|
||||||
|
|
||||||
|
/// 已发送数量
|
||||||
|
private Long remindedCount;
|
||||||
|
|
||||||
|
/// 超时数量
|
||||||
|
private Long timeoutCount;
|
||||||
|
|
||||||
|
/// 已取消数量
|
||||||
|
private Long cancelCount;
|
||||||
|
|
||||||
|
/// 失败数量
|
||||||
|
private Long failCount;
|
||||||
|
}
|
||||||
@@ -43,6 +43,8 @@ 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),
|
||||||
|
|||||||
@@ -3,9 +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.service.GaoCustomerChartService;
|
import com.imyeyu.api.modules.gao.service.GaoCustomerChartService;
|
||||||
|
import com.imyeyu.api.modules.gao.service.GaoStoreScopeService;
|
||||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerChartReq;
|
import com.imyeyu.api.modules.gao.vo.GaoCustomerChartReq;
|
||||||
import com.imyeyu.api.modules.gao.vo.GaoEventRecordCalendarView;
|
import com.imyeyu.api.modules.gao.vo.GaoEventRecordCalendarView;
|
||||||
import com.imyeyu.api.modules.gao.vo.GaoEventRecordDailyStatView;
|
import com.imyeyu.api.modules.gao.vo.GaoEventRecordDailyStatView;
|
||||||
|
import com.imyeyu.java.bean.timi.TimiException;
|
||||||
import com.imyeyu.spring.annotation.AOPLog;
|
import com.imyeyu.spring.annotation.AOPLog;
|
||||||
import com.imyeyu.spring.annotation.RequestRateLimit;
|
import com.imyeyu.spring.annotation.RequestRateLimit;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@@ -26,6 +28,7 @@ import java.util.List;
|
|||||||
public class GaoCustomerChartController {
|
public class GaoCustomerChartController {
|
||||||
|
|
||||||
private final GaoCustomerChartService service;
|
private final GaoCustomerChartService service;
|
||||||
|
private final GaoStoreScopeService storeScopeService;
|
||||||
|
|
||||||
/// 查询客户登记每日统计,可同时支撑登记趋势和登记事件结构图表
|
/// 查询客户登记每日统计,可同时支撑登记趋势和登记事件结构图表
|
||||||
@AOPLog
|
@AOPLog
|
||||||
@@ -33,6 +36,8 @@ public class GaoCustomerChartController {
|
|||||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||||
@PostMapping("/event/record/daily")
|
@PostMapping("/event/record/daily")
|
||||||
public List<GaoEventRecordDailyStatView> eventRecordDaily(@RequestBody GaoCustomerChartReq req) {
|
public List<GaoEventRecordDailyStatView> eventRecordDaily(@RequestBody GaoCustomerChartReq req) {
|
||||||
|
TimiException.required(req, "not found req");
|
||||||
|
req.setStoreId(storeScopeService.resolveStoreId(req.getStoreId()));
|
||||||
return service.eventRecordDailyStat(req);
|
return service.eventRecordDailyStat(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,6 +47,8 @@ public class GaoCustomerChartController {
|
|||||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||||
@PostMapping("/event/record/calendar")
|
@PostMapping("/event/record/calendar")
|
||||||
public List<GaoEventRecordCalendarView> eventRecordCalendar(@RequestBody GaoCustomerChartReq req) {
|
public List<GaoEventRecordCalendarView> eventRecordCalendar(@RequestBody GaoCustomerChartReq req) {
|
||||||
|
TimiException.required(req, "not found req");
|
||||||
|
req.setStoreId(storeScopeService.resolveStoreId(req.getStoreId()));
|
||||||
return service.eventRecordCalendar(req);
|
return service.eventRecordCalendar(req);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,17 @@
|
|||||||
package com.imyeyu.api.modules.gao.controller;
|
package com.imyeyu.api.modules.gao.controller;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonView;
|
import com.fasterxml.jackson.annotation.JsonView;
|
||||||
import com.imyeyu.api.bean.ModuleCode;
|
|
||||||
import com.imyeyu.api.modules.common.entity.Attachment;
|
import com.imyeyu.api.modules.common.entity.Attachment;
|
||||||
import com.imyeyu.api.modules.common.service.AttachmentService;
|
import com.imyeyu.api.modules.common.service.AttachmentService;
|
||||||
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.bean.GaoRoleCode;
|
|
||||||
import com.imyeyu.api.modules.gao.entity.GaoCustomer;
|
import com.imyeyu.api.modules.gao.entity.GaoCustomer;
|
||||||
import com.imyeyu.api.modules.gao.service.GaoCustomerService;
|
import com.imyeyu.api.modules.gao.service.GaoCustomerService;
|
||||||
import com.imyeyu.api.modules.gao.service.GaoStoreService;
|
import com.imyeyu.api.modules.gao.service.GaoStoreScopeService;
|
||||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerDailyStateView;
|
import com.imyeyu.api.modules.gao.vo.GaoCustomerDailyStateView;
|
||||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerGenderStatView;
|
import com.imyeyu.api.modules.gao.vo.GaoCustomerGenderStatView;
|
||||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerPage;
|
import com.imyeyu.api.modules.gao.vo.GaoCustomerPage;
|
||||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerTrendStateReq;
|
import com.imyeyu.api.modules.gao.vo.GaoCustomerTrendStateReq;
|
||||||
import com.imyeyu.api.modules.user.service.RoleChecker;
|
|
||||||
import com.imyeyu.api.modules.user.service.UserLoginService;
|
|
||||||
import com.imyeyu.api.modules.user.service.UserService;
|
import com.imyeyu.api.modules.user.service.UserService;
|
||||||
import com.imyeyu.java.TimiJava;
|
import com.imyeyu.java.TimiJava;
|
||||||
import com.imyeyu.java.bean.timi.TimiException;
|
import com.imyeyu.java.bean.timi.TimiException;
|
||||||
@@ -50,11 +46,9 @@ import java.util.Map;
|
|||||||
public class GaoCustomerController {
|
public class GaoCustomerController {
|
||||||
|
|
||||||
private final UserService userService;
|
private final UserService userService;
|
||||||
private final RoleChecker roleChecker;
|
|
||||||
private final AttachmentService attachmentService;
|
private final AttachmentService attachmentService;
|
||||||
private final GaoCustomerService service;
|
private final GaoCustomerService service;
|
||||||
private final GaoStoreService gaoStoreService;
|
private final GaoStoreScopeService storeScopeService;
|
||||||
private final UserLoginService userLoginService;
|
|
||||||
|
|
||||||
@AOPLog
|
@AOPLog
|
||||||
@RequestRateLimit
|
@RequestRateLimit
|
||||||
@@ -62,6 +56,8 @@ public class GaoCustomerController {
|
|||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
@JsonView(ResponseView.Public.class)
|
@JsonView(ResponseView.Public.class)
|
||||||
public PageResult<GaoCustomer> list(@RequestBody GaoCustomerPage page) {
|
public PageResult<GaoCustomer> list(@RequestBody GaoCustomerPage page) {
|
||||||
|
TimiException.required(page, "not found page");
|
||||||
|
page.setStoreId(storeScopeService.resolveStoreId(page.getStoreId()));
|
||||||
PageResult<GaoCustomer> result = service.pageByQuery(page);
|
PageResult<GaoCustomer> result = service.pageByQuery(page);
|
||||||
|
|
||||||
List<String> idList = result.getList().stream().map(GaoCustomer::getId).distinct().toList();
|
List<String> idList = result.getList().stream().map(GaoCustomer::getId).distinct().toList();
|
||||||
@@ -79,6 +75,8 @@ public class GaoCustomerController {
|
|||||||
@JsonView(ResponseView.Public.class)
|
@JsonView(ResponseView.Public.class)
|
||||||
public GaoCustomer detail(@RequestParam String id) {
|
public GaoCustomer detail(@RequestParam String id) {
|
||||||
GaoCustomer customer = service.get(id);
|
GaoCustomer customer = service.get(id);
|
||||||
|
TimiException.required(customer, "not found customer");
|
||||||
|
storeScopeService.checkStoreId(customer.getStoreId());
|
||||||
if (TimiJava.isNotEmpty(customer.getIntroducerCustomerId())) {
|
if (TimiJava.isNotEmpty(customer.getIntroducerCustomerId())) {
|
||||||
GaoCustomer introducerCustomer = service.get(customer.getIntroducerCustomerId());
|
GaoCustomer introducerCustomer = service.get(customer.getIntroducerCustomerId());
|
||||||
introducerCustomer.setAttachmentList(attachmentService.listByBizId(Attachment.BizType.GAO_CUSTOMER, introducerCustomer.getId()));
|
introducerCustomer.setAttachmentList(attachmentService.listByBizId(Attachment.BizType.GAO_CUSTOMER, introducerCustomer.getId()));
|
||||||
@@ -97,9 +95,7 @@ public class GaoCustomerController {
|
|||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@JsonView(ResponseView.Public.class)
|
@JsonView(ResponseView.Public.class)
|
||||||
public String create(@RequestBody GaoCustomer customer) {
|
public String create(@RequestBody GaoCustomer customer) {
|
||||||
if (!roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name())) {
|
customer.setStoreId(storeScopeService.resolveStoreId(customer.getStoreId()));
|
||||||
customer.setStoreId(gaoStoreService.getByUserId(userLoginService.getRequireLoginUserId()).getId());
|
|
||||||
}
|
|
||||||
service.create(customer);
|
service.create(customer);
|
||||||
return customer.getId();
|
return customer.getId();
|
||||||
}
|
}
|
||||||
@@ -109,9 +105,12 @@ public class GaoCustomerController {
|
|||||||
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_UPDATE)
|
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_UPDATE)
|
||||||
@PostMapping("/update")
|
@PostMapping("/update")
|
||||||
public void update(@RequestBody GaoCustomer customer) {
|
public void update(@RequestBody GaoCustomer customer) {
|
||||||
if (!roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name())) {
|
TimiException.required(customer, "not found customer");
|
||||||
customer.setStoreId(gaoStoreService.getByUserId(userLoginService.getRequireLoginUserId()).getId());
|
TimiException.required(customer.getId(), "not found customer.id");
|
||||||
}
|
GaoCustomer dbCustomer = service.get(customer.getId());
|
||||||
|
TimiException.required(dbCustomer, "not found customer");
|
||||||
|
storeScopeService.checkStoreId(dbCustomer.getStoreId());
|
||||||
|
customer.setStoreId(dbCustomer.getStoreId());
|
||||||
service.updateWithAttachment(customer);
|
service.updateWithAttachment(customer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,6 +119,9 @@ public class GaoCustomerController {
|
|||||||
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_DELETE)
|
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_DELETE)
|
||||||
@PostMapping("/delete")
|
@PostMapping("/delete")
|
||||||
public void delete(@RequestParam String id) {
|
public void delete(@RequestParam String id) {
|
||||||
|
GaoCustomer customer = service.get(id);
|
||||||
|
TimiException.required(customer, "not found customer");
|
||||||
|
storeScopeService.checkStoreId(customer.getStoreId());
|
||||||
service.delete(id);
|
service.delete(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,6 +133,7 @@ public class GaoCustomerController {
|
|||||||
public GaoCustomer findById(@RequestParam String id) {
|
public GaoCustomer findById(@RequestParam String id) {
|
||||||
GaoCustomer customer = service.get(id);
|
GaoCustomer customer = service.get(id);
|
||||||
TimiException.required(customer, "not found customer");
|
TimiException.required(customer, "not found customer");
|
||||||
|
storeScopeService.checkStoreId(customer.getStoreId());
|
||||||
customer.setAttachmentList(attachmentService.listByBizId(Attachment.BizType.GAO_CUSTOMER, customer.getId()));
|
customer.setAttachmentList(attachmentService.listByBizId(Attachment.BizType.GAO_CUSTOMER, customer.getId()));
|
||||||
return customer;
|
return customer;
|
||||||
}
|
}
|
||||||
@@ -141,7 +144,7 @@ public class GaoCustomerController {
|
|||||||
@PostMapping("/find/code")
|
@PostMapping("/find/code")
|
||||||
@JsonView(ResponseView.Public.class)
|
@JsonView(ResponseView.Public.class)
|
||||||
public GaoCustomer findByCode(@RequestParam String storeId, @RequestParam String code) {
|
public GaoCustomer findByCode(@RequestParam String storeId, @RequestParam String code) {
|
||||||
GaoCustomer customer = service.getByCode(storeId, code);
|
GaoCustomer customer = service.getByCode(storeScopeService.resolveStoreId(storeId), code);
|
||||||
if (customer == null) {
|
if (customer == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -155,7 +158,7 @@ public class GaoCustomerController {
|
|||||||
@PostMapping("/find/name")
|
@PostMapping("/find/name")
|
||||||
@JsonView(ResponseView.Public.class)
|
@JsonView(ResponseView.Public.class)
|
||||||
public GaoCustomer findByName(@RequestParam String storeId, @RequestParam String name) {
|
public GaoCustomer findByName(@RequestParam String storeId, @RequestParam String name) {
|
||||||
GaoCustomer customer = service.getByName(storeId, name);
|
GaoCustomer customer = service.getByName(storeScopeService.resolveStoreId(storeId), name);
|
||||||
if (customer == null) {
|
if (customer == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -169,6 +172,12 @@ public class GaoCustomerController {
|
|||||||
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_EXPORT)
|
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_EXPORT)
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(@RequestBody Page<GaoCustomer> page) throws IOException {
|
public void export(@RequestBody Page<GaoCustomer> page) throws IOException {
|
||||||
|
TimiException.required(page, "not found page");
|
||||||
|
if (!storeScopeService.hasGlobalScope()) {
|
||||||
|
GaoCustomer example = TimiJava.defaultIfNull(page.getEqualsExample(), new GaoCustomer());
|
||||||
|
example.setStoreId(storeScopeService.resolveStoreId(example.getStoreId()));
|
||||||
|
page.setEqualsExample(example);
|
||||||
|
}
|
||||||
HttpServletResponse resp = TimiSpring.getResponse();
|
HttpServletResponse resp = TimiSpring.getResponse();
|
||||||
String contentDisposition = Network.getFileDownloadHeader("客户列表-%s.xlsx".formatted(Time.serialize.format(Time.now())));
|
String contentDisposition = Network.getFileDownloadHeader("客户列表-%s.xlsx".formatted(Time.serialize.format(Time.now())));
|
||||||
resp.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
resp.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||||
@@ -182,6 +191,9 @@ public class GaoCustomerController {
|
|||||||
@PostMapping("/invited/list")
|
@PostMapping("/invited/list")
|
||||||
@JsonView(ResponseView.Public.class)
|
@JsonView(ResponseView.Public.class)
|
||||||
public List<GaoCustomer> listInvited(@RequestParam String introducerCustomerId) {
|
public List<GaoCustomer> listInvited(@RequestParam String introducerCustomerId) {
|
||||||
|
GaoCustomer introducerCustomer = service.get(introducerCustomerId);
|
||||||
|
TimiException.required(introducerCustomer, "not found introducerCustomer");
|
||||||
|
storeScopeService.checkStoreId(introducerCustomer.getStoreId());
|
||||||
List<GaoCustomer> result = service.listInvited(introducerCustomerId);
|
List<GaoCustomer> result = service.listInvited(introducerCustomerId);
|
||||||
List<String> idList = result.stream().map(GaoCustomer::getId).distinct().toList();
|
List<String> idList = result.stream().map(GaoCustomer::getId).distinct().toList();
|
||||||
Map<String, List<Attachment>> attachMap = attachmentService.mapByBizIdList(Attachment.BizType.GAO_CUSTOMER, idList);
|
Map<String, List<Attachment>> attachMap = attachmentService.mapByBizIdList(Attachment.BizType.GAO_CUSTOMER, idList);
|
||||||
@@ -196,6 +208,9 @@ public class GaoCustomerController {
|
|||||||
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_UPDATE)
|
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_UPDATE)
|
||||||
@PostMapping("/invite/save")
|
@PostMapping("/invite/save")
|
||||||
public void saveInvite(@RequestParam String introducerCustomerId, @RequestParam String customerId) {
|
public void saveInvite(@RequestParam String introducerCustomerId, @RequestParam String customerId) {
|
||||||
|
GaoCustomer customer = service.get(customerId);
|
||||||
|
TimiException.required(customer, "not found customer");
|
||||||
|
storeScopeService.checkStoreId(customer.getStoreId());
|
||||||
service.saveInviteRelation(introducerCustomerId, customerId);
|
service.saveInviteRelation(introducerCustomerId, customerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,6 +219,9 @@ public class GaoCustomerController {
|
|||||||
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_UPDATE)
|
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_UPDATE)
|
||||||
@PostMapping("/invite/delete")
|
@PostMapping("/invite/delete")
|
||||||
public void deleteInvite(@RequestParam String customerId) {
|
public void deleteInvite(@RequestParam String customerId) {
|
||||||
|
GaoCustomer customer = service.get(customerId);
|
||||||
|
TimiException.required(customer, "not found customer");
|
||||||
|
storeScopeService.checkStoreId(customer.getStoreId());
|
||||||
service.deleteInviteRelation(customerId);
|
service.deleteInviteRelation(customerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,6 +231,8 @@ public class GaoCustomerController {
|
|||||||
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_READ)
|
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_READ)
|
||||||
@PostMapping("/state/daily")
|
@PostMapping("/state/daily")
|
||||||
public List<GaoCustomerDailyStateView> dailyStat(@RequestBody GaoCustomerTrendStateReq req) {
|
public List<GaoCustomerDailyStateView> dailyStat(@RequestBody GaoCustomerTrendStateReq req) {
|
||||||
|
TimiException.required(req, "not found req");
|
||||||
|
req.setStoreId(storeScopeService.resolveStoreId(req.getStoreId()));
|
||||||
return service.stateDailyTrend(req);
|
return service.stateDailyTrend(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,6 +242,6 @@ public class GaoCustomerController {
|
|||||||
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_READ)
|
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_READ)
|
||||||
@PostMapping("/state/gender")
|
@PostMapping("/state/gender")
|
||||||
public List<GaoCustomerGenderStatView> genderStat(@RequestParam String storeId) {
|
public List<GaoCustomerGenderStatView> genderStat(@RequestParam String storeId) {
|
||||||
return service.stateGender(storeId);
|
return service.stateGender(storeScopeService.resolveStoreId(storeId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
package com.imyeyu.api.modules.gao.controller;
|
package com.imyeyu.api.modules.gao.controller;
|
||||||
|
|
||||||
import com.imyeyu.api.bean.ModuleCode;
|
|
||||||
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.bean.GaoRoleCode;
|
|
||||||
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.service.GaoEventService;
|
import com.imyeyu.api.modules.gao.service.GaoEventService;
|
||||||
import com.imyeyu.api.modules.gao.service.GaoStoreService;
|
import com.imyeyu.api.modules.gao.service.GaoStoreScopeService;
|
||||||
import com.imyeyu.api.modules.user.service.RoleChecker;
|
import com.imyeyu.java.TimiJava;
|
||||||
import com.imyeyu.api.modules.user.service.UserLoginService;
|
import com.imyeyu.java.bean.timi.TimiException;
|
||||||
import com.imyeyu.spring.annotation.AOPLog;
|
import com.imyeyu.spring.annotation.AOPLog;
|
||||||
import com.imyeyu.spring.annotation.RequestRateLimit;
|
import com.imyeyu.spring.annotation.RequestRateLimit;
|
||||||
import com.imyeyu.spring.bean.Page;
|
import com.imyeyu.spring.bean.Page;
|
||||||
@@ -33,28 +32,34 @@ import java.util.Map;
|
|||||||
public class GaoEventController {
|
public class GaoEventController {
|
||||||
|
|
||||||
private final GaoEventService service;
|
private final GaoEventService service;
|
||||||
private final RoleChecker roleChecker;
|
private final GaoStoreScopeService storeScopeService;
|
||||||
private final GaoStoreService gaoStoreService;
|
|
||||||
private final UserLoginService userLoginService;
|
|
||||||
|
|
||||||
@AOPLog
|
@AOPLog
|
||||||
@RequestRateLimit
|
@RequestRateLimit
|
||||||
@RequireGaoPermission(GaoPermissionCode.EVENT_READ)
|
@RequireGaoPermission(GaoPermissionCode.EVENT_READ)
|
||||||
@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");
|
||||||
|
if (!storeScopeService.hasGlobalScope()) {
|
||||||
|
GaoEvent example = TimiJava.defaultIfNull(page.getEqualsExample(), new GaoEvent());
|
||||||
|
example.setStoreId(storeScopeService.resolveStoreId(example.getStoreId()));
|
||||||
|
page.setEqualsExample(example);
|
||||||
|
}
|
||||||
PageResult<GaoEvent> result = service.page(page);
|
PageResult<GaoEvent> result = service.page(page);
|
||||||
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());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@AOPLog
|
@AOPLog
|
||||||
@RequestRateLimit
|
@RequestRateLimit
|
||||||
|
@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(storeId);
|
return service.listValid(storeScopeService.resolveStoreId(storeId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@AOPLog
|
@AOPLog
|
||||||
@@ -63,7 +68,10 @@ public class GaoEventController {
|
|||||||
@PostMapping("/detail")
|
@PostMapping("/detail")
|
||||||
public GaoEvent detail(@RequestParam String id) {
|
public GaoEvent detail(@RequestParam String id) {
|
||||||
GaoEvent event = service.get(id);
|
GaoEvent event = service.get(id);
|
||||||
|
TimiException.required(event, "not found event");
|
||||||
|
storeScopeService.checkStoreId(event.getStoreId());
|
||||||
event.setRoleCodeList(service.listRoleCode(event.getId()));
|
event.setRoleCodeList(service.listRoleCode(event.getId()));
|
||||||
|
service.attachOptionGroupList(List.of(event));
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,9 +80,7 @@ public class GaoEventController {
|
|||||||
@RequireGaoPermission(GaoPermissionCode.EVENT_CREATE)
|
@RequireGaoPermission(GaoPermissionCode.EVENT_CREATE)
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
public void create(@RequestBody GaoEvent event) {
|
public void create(@RequestBody GaoEvent event) {
|
||||||
if (!roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name())) {
|
event.setStoreId(storeScopeService.resolveStoreId(event.getStoreId()));
|
||||||
event.setStoreId(gaoStoreService.getByUserId(userLoginService.getRequireLoginUserId()).getId());
|
|
||||||
}
|
|
||||||
service.create(event);
|
service.create(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,17 +89,36 @@ public class GaoEventController {
|
|||||||
@RequireGaoPermission(GaoPermissionCode.EVENT_UPDATE)
|
@RequireGaoPermission(GaoPermissionCode.EVENT_UPDATE)
|
||||||
@PostMapping("/update")
|
@PostMapping("/update")
|
||||||
public void update(@RequestBody GaoEvent event) {
|
public void update(@RequestBody GaoEvent event) {
|
||||||
if (!roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name())) {
|
TimiException.required(event, "not found event");
|
||||||
event.setStoreId(gaoStoreService.getByUserId(userLoginService.getRequireLoginUserId()).getId());
|
TimiException.required(event.getId(), "not found event.id");
|
||||||
}
|
GaoEvent dbEvent = service.get(event.getId());
|
||||||
|
TimiException.required(dbEvent, "not found event");
|
||||||
|
storeScopeService.checkStoreId(dbEvent.getStoreId());
|
||||||
|
event.setStoreId(dbEvent.getStoreId());
|
||||||
service.update(event);
|
service.update(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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)
|
||||||
@PostMapping("/sort")
|
@PostMapping("/sort")
|
||||||
public void sort(@RequestBody List<String> idList) {
|
public void sort(@RequestBody List<String> idList) {
|
||||||
|
for (String id : TimiJava.safeIterable(idList)) {
|
||||||
|
GaoEvent event = service.get(id);
|
||||||
|
TimiException.required(event, "not found event");
|
||||||
|
storeScopeService.checkStoreId(event.getStoreId());
|
||||||
|
}
|
||||||
service.sort(idList);
|
service.sort(idList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,6 +127,9 @@ public class GaoEventController {
|
|||||||
@RequireGaoPermission(GaoPermissionCode.EVENT_DELETE)
|
@RequireGaoPermission(GaoPermissionCode.EVENT_DELETE)
|
||||||
@PostMapping("/delete")
|
@PostMapping("/delete")
|
||||||
public void delete(@RequestParam String id) {
|
public void delete(@RequestParam String id) {
|
||||||
|
GaoEvent event = service.get(id);
|
||||||
|
TimiException.required(event, "not found event");
|
||||||
|
storeScopeService.checkStoreId(event.getStoreId());
|
||||||
service.delete(id);
|
service.delete(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,27 +1,25 @@
|
|||||||
package com.imyeyu.api.modules.gao.controller;
|
package com.imyeyu.api.modules.gao.controller;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonView;
|
import com.fasterxml.jackson.annotation.JsonView;
|
||||||
import com.imyeyu.api.bean.ModuleCode;
|
|
||||||
import com.imyeyu.api.modules.common.entity.Attachment;
|
import com.imyeyu.api.modules.common.entity.Attachment;
|
||||||
import com.imyeyu.api.modules.common.service.AttachmentService;
|
import com.imyeyu.api.modules.common.service.AttachmentService;
|
||||||
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.bean.GaoRoleCode;
|
|
||||||
import com.imyeyu.api.modules.gao.entity.GaoCustomer;
|
import com.imyeyu.api.modules.gao.entity.GaoCustomer;
|
||||||
import com.imyeyu.api.modules.gao.entity.GaoEvent;
|
import com.imyeyu.api.modules.gao.entity.GaoEvent;
|
||||||
import com.imyeyu.api.modules.gao.entity.GaoEventRecord;
|
import com.imyeyu.api.modules.gao.entity.GaoEventRecord;
|
||||||
import com.imyeyu.api.modules.gao.service.GaoCustomerService;
|
import com.imyeyu.api.modules.gao.service.GaoCustomerService;
|
||||||
import com.imyeyu.api.modules.gao.service.GaoEventRecordService;
|
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.GaoStoreService;
|
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.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;
|
||||||
import com.imyeyu.api.modules.user.service.RoleChecker;
|
import com.imyeyu.api.modules.gao.vo.GaoEventOptionStatView;
|
||||||
import com.imyeyu.api.modules.user.service.UserLoginService;
|
|
||||||
import com.imyeyu.api.modules.user.service.UserService;
|
import com.imyeyu.api.modules.user.service.UserService;
|
||||||
import com.imyeyu.java.TimiJava;
|
import com.imyeyu.java.TimiJava;
|
||||||
|
import com.imyeyu.java.bean.timi.TimiException;
|
||||||
import com.imyeyu.network.Network;
|
import com.imyeyu.network.Network;
|
||||||
import com.imyeyu.spring.TimiSpring;
|
import com.imyeyu.spring.TimiSpring;
|
||||||
import com.imyeyu.spring.annotation.AOPLog;
|
import com.imyeyu.spring.annotation.AOPLog;
|
||||||
@@ -52,13 +50,11 @@ import java.util.Map;
|
|||||||
public class GaoEventRecordController {
|
public class GaoEventRecordController {
|
||||||
|
|
||||||
private final UserService userService;
|
private final UserService userService;
|
||||||
private final RoleChecker roleChecker;
|
|
||||||
private final GaoEventService eventService;
|
private final GaoEventService eventService;
|
||||||
private final AttachmentService attachmentService;
|
private final AttachmentService attachmentService;
|
||||||
private final GaoCustomerService customerService;
|
private final GaoCustomerService customerService;
|
||||||
private final GaoStoreService gaoStoreService;
|
private final GaoStoreScopeService storeScopeService;
|
||||||
private final GaoEventRecordService service;
|
private final GaoEventRecordService service;
|
||||||
private final UserLoginService userLoginService;
|
|
||||||
|
|
||||||
@AOPLog
|
@AOPLog
|
||||||
@RequestRateLimit
|
@RequestRateLimit
|
||||||
@@ -66,6 +62,8 @@ public class GaoEventRecordController {
|
|||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
@JsonView(ResponseView.Public.class)
|
@JsonView(ResponseView.Public.class)
|
||||||
public GaoEventRecordPageResult list(@RequestBody GaoEventRecordPage page) {
|
public GaoEventRecordPageResult list(@RequestBody GaoEventRecordPage page) {
|
||||||
|
TimiException.required(page, "not found page");
|
||||||
|
page.setStoreId(storeScopeService.resolveStoreId(page.getStoreId()));
|
||||||
PageResult<GaoEventRecord> pageResult = service.pageByRange(page);
|
PageResult<GaoEventRecord> pageResult = service.pageByRange(page);
|
||||||
GaoEventRecordPageResult result = new GaoEventRecordPageResult();
|
GaoEventRecordPageResult result = new GaoEventRecordPageResult();
|
||||||
result.setTotal(pageResult.getTotal());
|
result.setTotal(pageResult.getTotal());
|
||||||
@@ -81,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;
|
||||||
}
|
}
|
||||||
@@ -108,22 +107,38 @@ public class GaoEventRecordController {
|
|||||||
@JsonView(ResponseView.Public.class)
|
@JsonView(ResponseView.Public.class)
|
||||||
public GaoEventRecord detail(@RequestParam String id) {
|
public GaoEventRecord detail(@RequestParam String id) {
|
||||||
GaoEventRecord record = service.get(id);
|
GaoEventRecord record = service.get(id);
|
||||||
|
TimiException.required(record, "not found event record");
|
||||||
|
storeScopeService.checkStoreId(record.getStoreId());
|
||||||
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()));
|
||||||
|
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)
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
public void create(@RequestBody GaoEventRecord record) {
|
public void create(@RequestBody GaoEventRecord record) {
|
||||||
if (!roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name())) {
|
resolveCreateRecordStore(record);
|
||||||
record.setStoreId(gaoStoreService.getByUserId(userLoginService.getRequireLoginUserId()).getId());
|
|
||||||
}
|
|
||||||
service.create(record);
|
service.create(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,11 +147,8 @@ public class GaoEventRecordController {
|
|||||||
@RequireGaoPermission(GaoPermissionCode.EVENT_RECORD_CREATE)
|
@RequireGaoPermission(GaoPermissionCode.EVENT_RECORD_CREATE)
|
||||||
@PostMapping("/create/batch")
|
@PostMapping("/create/batch")
|
||||||
public void createBatch(@RequestBody List<GaoEventRecord> recordList) {
|
public void createBatch(@RequestBody List<GaoEventRecord> recordList) {
|
||||||
if (!roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name())) {
|
for (GaoEventRecord record : TimiJava.safeIterable(recordList)) {
|
||||||
String storeId = gaoStoreService.getBelongIdByRequiredLoginUserId();
|
resolveCreateRecordStore(record);
|
||||||
for (GaoEventRecord record : recordList) {
|
|
||||||
record.setStoreId(storeId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
service.createBatch(recordList);
|
service.createBatch(recordList);
|
||||||
}
|
}
|
||||||
@@ -146,11 +158,17 @@ public class GaoEventRecordController {
|
|||||||
@RequireGaoPermission(GaoPermissionCode.EVENT_RECORD_CREATE)
|
@RequireGaoPermission(GaoPermissionCode.EVENT_RECORD_CREATE)
|
||||||
@PostMapping("/create/customer")
|
@PostMapping("/create/customer")
|
||||||
public void createWithCustomer(@RequestBody GaoCustomer customer) {
|
public void createWithCustomer(@RequestBody GaoCustomer customer) {
|
||||||
if (!roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name())) {
|
TimiException.required(customer, "not found customer");
|
||||||
String storeId = gaoStoreService.getBelongIdByRequiredLoginUserId();
|
if (TimiJava.isNotEmpty(customer.getId())) {
|
||||||
for (GaoEventRecord record : TimiJava.safeIterable(customer.getEventRecordList())) {
|
GaoCustomer dbCustomer = customerService.get(customer.getId());
|
||||||
record.setStoreId(storeId);
|
TimiException.required(dbCustomer, "not found customer");
|
||||||
|
storeScopeService.checkStoreId(dbCustomer.getStoreId());
|
||||||
|
customer.setStoreId(dbCustomer.getStoreId());
|
||||||
|
} else {
|
||||||
|
customer.setStoreId(storeScopeService.resolveStoreId(customer.getStoreId()));
|
||||||
}
|
}
|
||||||
|
for (GaoEventRecord record : TimiJava.safeIterable(customer.getEventRecordList())) {
|
||||||
|
resolveCreateRecordStore(record);
|
||||||
}
|
}
|
||||||
service.createWithCustomer(customer);
|
service.createWithCustomer(customer);
|
||||||
}
|
}
|
||||||
@@ -160,9 +178,12 @@ public class GaoEventRecordController {
|
|||||||
@RequireGaoPermission(GaoPermissionCode.EVENT_RECORD_UPDATE)
|
@RequireGaoPermission(GaoPermissionCode.EVENT_RECORD_UPDATE)
|
||||||
@PostMapping("/update")
|
@PostMapping("/update")
|
||||||
public void update(@RequestBody GaoEventRecord record) {
|
public void update(@RequestBody GaoEventRecord record) {
|
||||||
if (!roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name())) {
|
TimiException.required(record, "not found event record");
|
||||||
record.setStoreId(gaoStoreService.getBelongIdByRequiredLoginUserId());
|
TimiException.required(record.getId(), "not found event record.id");
|
||||||
}
|
GaoEventRecord dbRecord = service.get(record.getId());
|
||||||
|
TimiException.required(dbRecord, "not found event record");
|
||||||
|
storeScopeService.checkStoreId(dbRecord.getStoreId());
|
||||||
|
record.setStoreId(dbRecord.getStoreId());
|
||||||
service.update(record);
|
service.update(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,6 +192,9 @@ public class GaoEventRecordController {
|
|||||||
@RequireGaoPermission(GaoPermissionCode.EVENT_RECORD_DELETE)
|
@RequireGaoPermission(GaoPermissionCode.EVENT_RECORD_DELETE)
|
||||||
@PostMapping("/delete")
|
@PostMapping("/delete")
|
||||||
public void delete(@RequestParam String id) {
|
public void delete(@RequestParam String id) {
|
||||||
|
GaoEventRecord record = service.get(id);
|
||||||
|
TimiException.required(record, "not found event record");
|
||||||
|
storeScopeService.checkStoreId(record.getStoreId());
|
||||||
service.delete(id);
|
service.delete(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,6 +204,8 @@ public class GaoEventRecordController {
|
|||||||
@RequireGaoPermission(GaoPermissionCode.EVENT_RECORD_EXPORT)
|
@RequireGaoPermission(GaoPermissionCode.EVENT_RECORD_EXPORT)
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(@RequestBody GaoEventRecordPage page) throws IOException {
|
public void export(@RequestBody GaoEventRecordPage page) throws IOException {
|
||||||
|
TimiException.required(page, "not found page");
|
||||||
|
page.setStoreId(storeScopeService.resolveStoreId(page.getStoreId()));
|
||||||
HttpServletResponse resp = TimiSpring.getResponse();
|
HttpServletResponse resp = TimiSpring.getResponse();
|
||||||
String contentDisposition = Network.getFileDownloadHeader("登记事件记录-%s.xlsx".formatted(Time.serialize.format(Time.now())));
|
String contentDisposition = Network.getFileDownloadHeader("登记事件记录-%s.xlsx".formatted(Time.serialize.format(Time.now())));
|
||||||
resp.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
resp.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||||
@@ -193,6 +219,8 @@ public class GaoEventRecordController {
|
|||||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||||
@PostMapping("/rank")
|
@PostMapping("/rank")
|
||||||
public PageResult<GaoCustomerEventRankView> eventRank(@RequestBody GaoEventRecordRankPage page) {
|
public PageResult<GaoCustomerEventRankView> eventRank(@RequestBody GaoEventRecordRankPage page) {
|
||||||
|
TimiException.required(page, "not found page");
|
||||||
|
page.setStoreId(storeScopeService.resolveStoreId(page.getStoreId()));
|
||||||
PageResult<GaoCustomerEventRankView> result = service.pageRankByRange(page);
|
PageResult<GaoCustomerEventRankView> result = service.pageRankByRange(page);
|
||||||
List<String> customerIdList = result.getList().stream().map(GaoCustomerEventRankView::getCustomerId).distinct().toList();
|
List<String> customerIdList = result.getList().stream().map(GaoCustomerEventRankView::getCustomerId).distinct().toList();
|
||||||
if (customerIdList.isEmpty()) {
|
if (customerIdList.isEmpty()) {
|
||||||
@@ -209,4 +237,22 @@ 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) {
|
||||||
|
TimiException.required(record, "not found event record");
|
||||||
|
GaoEvent event = eventService.get(record.getEventId());
|
||||||
|
TimiException.required(event, "not found event");
|
||||||
|
storeScopeService.checkStoreId(event.getStoreId());
|
||||||
|
record.setStoreId(event.getStoreId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,158 @@
|
|||||||
|
package com.imyeyu.api.modules.gao.controller;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonView;
|
||||||
|
import com.imyeyu.api.annotation.RequireCorePermission;
|
||||||
|
import com.imyeyu.api.bean.CorePermissionCode;
|
||||||
|
import com.imyeyu.api.bean.PermissionMatchMode;
|
||||||
|
import com.imyeyu.api.modules.common.entity.Attachment;
|
||||||
|
import com.imyeyu.api.modules.common.entity.Notify;
|
||||||
|
import com.imyeyu.api.modules.common.entity.NotifyDetail;
|
||||||
|
import com.imyeyu.api.modules.common.service.AttachmentService;
|
||||||
|
import com.imyeyu.api.modules.common.service.NotifyService;
|
||||||
|
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission;
|
||||||
|
import com.imyeyu.api.modules.gao.bean.GaoPermissionCode;
|
||||||
|
import com.imyeyu.api.modules.gao.entity.GaoUser;
|
||||||
|
import com.imyeyu.api.modules.gao.service.GaoStoreScopeService;
|
||||||
|
import com.imyeyu.api.modules.gao.service.GaoUserService;
|
||||||
|
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.RequestRateLimit;
|
||||||
|
import com.imyeyu.spring.annotation.RequiredToken;
|
||||||
|
import com.imyeyu.spring.bean.Page;
|
||||||
|
import com.imyeyu.spring.bean.PageResult;
|
||||||
|
import com.imyeyu.spring.util.ResponseView;
|
||||||
|
import com.imyeyu.utils.Time;
|
||||||
|
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;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/// GAO 通知接口
|
||||||
|
///
|
||||||
|
/// 这里的通知接收用户必须属于当前操作人的 GAO 用户范围,当前登录用户本人除外。
|
||||||
|
///
|
||||||
|
/// @author Codex
|
||||||
|
/// @since 2026-08-25
|
||||||
|
@RestController
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RequestMapping("/gao/notify")
|
||||||
|
public class GaoNotifyController {
|
||||||
|
|
||||||
|
private final GaoUserService gaoUserService;
|
||||||
|
private final GaoStoreScopeService storeScopeService;
|
||||||
|
private final NotifyService notifyService;
|
||||||
|
private final UserLoginService userLoginService;
|
||||||
|
private final UserService userService;
|
||||||
|
private final AttachmentService attachmentService;
|
||||||
|
|
||||||
|
/// 查询可作为通知接收人的 GAO 用户
|
||||||
|
///
|
||||||
|
/// 门店管理范围可以查询全部门店或指定门店,店长只能查询当前门店。
|
||||||
|
///
|
||||||
|
/// @param page 分页参数
|
||||||
|
/// @return 可发送用户分页结果
|
||||||
|
@JsonView(ResponseView.Public.class)
|
||||||
|
@RequiredToken
|
||||||
|
@RequestRateLimit
|
||||||
|
@RequireCorePermission(CorePermissionCode.NOTIFY_CREATE)
|
||||||
|
@RequireGaoPermission(value = {GaoPermissionCode.USER_READ, GaoPermissionCode.STORE_READ}, mode = PermissionMatchMode.ANY)
|
||||||
|
@PostMapping("/recipient/list")
|
||||||
|
public PageResult<GaoUser> recipientList(@RequestBody Page<GaoUser> page) {
|
||||||
|
TimiException.required(page, "未找到分页参数");
|
||||||
|
GaoUser example = TimiJava.defaultIfNull(page.getEqualsExample(), new GaoUser());
|
||||||
|
if (storeScopeService.hasGlobalScope()) {
|
||||||
|
if (TimiJava.isNotEmpty(example.getStoreId())) {
|
||||||
|
storeScopeService.checkStoreId(example.getStoreId());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
example.setStoreId(storeScopeService.resolveStoreId(example.getStoreId()));
|
||||||
|
}
|
||||||
|
page.setEqualsExample(example);
|
||||||
|
|
||||||
|
PageResult<GaoUser> result = gaoUserService.pageRecipients(page);
|
||||||
|
fillUser(result.getList());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 创建 GAO 站内通知
|
||||||
|
///
|
||||||
|
/// 只允许发送站内通知,并逐个校验接收用户是否属于当前操作人的门店范围;当前用户可以接收自己发送的通知。
|
||||||
|
///
|
||||||
|
/// @param notify 通知及通知详情
|
||||||
|
/// @return 创建后的通知
|
||||||
|
@RequiredToken
|
||||||
|
@RequestRateLimit
|
||||||
|
@RequireCorePermission(CorePermissionCode.NOTIFY_CREATE)
|
||||||
|
@RequireGaoPermission(value = {GaoPermissionCode.USER_READ, GaoPermissionCode.STORE_READ}, mode = PermissionMatchMode.ANY)
|
||||||
|
@PostMapping("/create")
|
||||||
|
public Notify create(@RequestBody Notify notify) {
|
||||||
|
checkRecipientBoundary(notify);
|
||||||
|
notifyService.create(notify);
|
||||||
|
return notify;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 校验通知接收用户边界
|
||||||
|
///
|
||||||
|
/// @param notify 通知
|
||||||
|
private void checkRecipientBoundary(Notify notify) {
|
||||||
|
TimiException.required(notify, "未找到通知");
|
||||||
|
List<NotifyDetail> detailList = notify.getDetailList();
|
||||||
|
TimiException.required(detailList, "未找到通知详情列表");
|
||||||
|
TimiException.requiredTrue(!detailList.isEmpty(), "通知详情列表不能为空");
|
||||||
|
|
||||||
|
Set<String> recipientIdSet = detailList.stream().map(detail -> {
|
||||||
|
TimiException.required(detail, "未找到通知详情");
|
||||||
|
TimiException.requiredTrue(detail.getMsgType() == NotifyDetail.MsgType.INTERNAL, "GAO 通知仅支持站内通知");
|
||||||
|
TimiException.required(detail.getSendTo(), "未找到通知接收用户 ID");
|
||||||
|
if (detail.getSendAt() != null) {
|
||||||
|
TimiException.requiredTrue(Time.now() < detail.getSendAt(), "定时发送时间必须晚于当前时间");
|
||||||
|
}
|
||||||
|
return detail.getSendTo();
|
||||||
|
}).collect(Collectors.toSet());
|
||||||
|
TimiException.requiredTrue(recipientIdSet.size() == detailList.size(), "通知接收用户不能重复");
|
||||||
|
|
||||||
|
String loginUserId = userLoginService.getRequireLoginUserId();
|
||||||
|
Set<String> gaoRecipientIdSet = recipientIdSet.stream()
|
||||||
|
.filter(recipientId -> !loginUserId.equals(recipientId))
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
Map<String, GaoUser> gaoUserMap = gaoUserService.mapByUserIdList(gaoRecipientIdSet);
|
||||||
|
TimiException.requiredTrue(gaoUserMap.size() == gaoRecipientIdSet.size(), "包含无效的通知接收用户");
|
||||||
|
for (GaoUser gaoUser : gaoUserMap.values()) {
|
||||||
|
TimiException.requiredTrue(Boolean.TRUE.equals(gaoUser.getEnabled()), "通知接收用户已停用");
|
||||||
|
storeScopeService.checkStoreId(gaoUser.getStoreId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 回填 GAO 用户的核心用户资料
|
||||||
|
///
|
||||||
|
/// @param gaoUserList GAO 用户列表
|
||||||
|
private void fillUser(List<GaoUser> gaoUserList) {
|
||||||
|
if (TimiJava.isEmpty(gaoUserList)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<String> userIdList = gaoUserList.stream().map(GaoUser::getUserId).toList();
|
||||||
|
Map<String, User> userMap = userService.mapByIdList(userIdList);
|
||||||
|
Map<String, List<Attachment>> attachmentMap = attachmentService.mapByBizIdList(
|
||||||
|
Attachment.BizType.USER,
|
||||||
|
userIdList,
|
||||||
|
User.AttachType.AVATAR.toString()
|
||||||
|
);
|
||||||
|
for (GaoUser gaoUser : gaoUserList) {
|
||||||
|
User user = userMap.get(gaoUser.getUserId());
|
||||||
|
if (user == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
user.setAttachmentList(attachmentMap.getOrDefault(user.getId(), List.of()));
|
||||||
|
gaoUser.setUser(user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,14 +1,11 @@
|
|||||||
package com.imyeyu.api.modules.gao.controller;
|
package com.imyeyu.api.modules.gao.controller;
|
||||||
|
|
||||||
import com.imyeyu.api.bean.ModuleCode;
|
|
||||||
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.bean.GaoRoleCode;
|
|
||||||
import com.imyeyu.api.modules.gao.entity.GaoPointAccount;
|
import com.imyeyu.api.modules.gao.entity.GaoPointAccount;
|
||||||
import com.imyeyu.api.modules.gao.service.GaoPointAccountService;
|
import com.imyeyu.api.modules.gao.service.GaoPointAccountService;
|
||||||
import com.imyeyu.api.modules.gao.service.GaoStoreService;
|
import com.imyeyu.api.modules.gao.service.GaoStoreScopeService;
|
||||||
import com.imyeyu.api.modules.gao.vo.GaoPointAccountPage;
|
import com.imyeyu.api.modules.gao.vo.GaoPointAccountPage;
|
||||||
import com.imyeyu.api.modules.user.service.RoleChecker;
|
|
||||||
import com.imyeyu.java.bean.timi.TimiException;
|
import com.imyeyu.java.bean.timi.TimiException;
|
||||||
import com.imyeyu.spring.annotation.AOPLog;
|
import com.imyeyu.spring.annotation.AOPLog;
|
||||||
import com.imyeyu.spring.annotation.RequestRateLimit;
|
import com.imyeyu.spring.annotation.RequestRateLimit;
|
||||||
@@ -29,8 +26,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
@RequestMapping("/gao/customer/point")
|
@RequestMapping("/gao/customer/point")
|
||||||
public class GaoPointAccountController {
|
public class GaoPointAccountController {
|
||||||
|
|
||||||
private final RoleChecker roleChecker;
|
private final GaoStoreScopeService storeScopeService;
|
||||||
private final GaoStoreService storeService;
|
|
||||||
private final GaoPointAccountService accountService;
|
private final GaoPointAccountService accountService;
|
||||||
|
|
||||||
@AOPLog
|
@AOPLog
|
||||||
@@ -39,7 +35,7 @@ public class GaoPointAccountController {
|
|||||||
@PostMapping("/account/list")
|
@PostMapping("/account/list")
|
||||||
public PageResult<GaoPointAccount> list(@RequestBody GaoPointAccountPage page) {
|
public PageResult<GaoPointAccount> list(@RequestBody GaoPointAccountPage page) {
|
||||||
TimiException.required(page, "not found page");
|
TimiException.required(page, "not found page");
|
||||||
page.setStoreId(resolveStoreId(page.getStoreId()));
|
page.setStoreId(storeScopeService.resolveStoreId(page.getStoreId()));
|
||||||
return accountService.pageByQuery(page);
|
return accountService.pageByQuery(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,7 +44,7 @@ public class GaoPointAccountController {
|
|||||||
@RequireGaoPermission(GaoPermissionCode.POINT_ACCOUNT_READ)
|
@RequireGaoPermission(GaoPermissionCode.POINT_ACCOUNT_READ)
|
||||||
@PostMapping("/account/detail/customer")
|
@PostMapping("/account/detail/customer")
|
||||||
public GaoPointAccount detail(@RequestParam String customerId, @RequestParam(required = false) String storeId) {
|
public GaoPointAccount detail(@RequestParam String customerId, @RequestParam(required = false) String storeId) {
|
||||||
storeId = resolveStoreId(storeId);
|
storeId = storeScopeService.resolveStoreId(storeId);
|
||||||
return accountService.getByCustomerId(storeId, customerId);
|
return accountService.getByCustomerId(storeId, customerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,13 +53,6 @@ public class GaoPointAccountController {
|
|||||||
@RequireGaoPermission(GaoPermissionCode.POINT_ACCOUNT_READ)
|
@RequireGaoPermission(GaoPermissionCode.POINT_ACCOUNT_READ)
|
||||||
@PostMapping("/account/detail")
|
@PostMapping("/account/detail")
|
||||||
public GaoPointAccount detailById(@RequestParam String id, @RequestParam(required = false) String storeId) {
|
public GaoPointAccount detailById(@RequestParam String id, @RequestParam(required = false) String storeId) {
|
||||||
return accountService.getByIdAndStoreId(resolveStoreId(storeId), id);
|
return accountService.getByIdAndStoreId(storeScopeService.resolveStoreId(storeId), id);
|
||||||
}
|
|
||||||
|
|
||||||
private String resolveStoreId(String requestedStoreId) {
|
|
||||||
if (roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name())) {
|
|
||||||
return requestedStoreId;
|
|
||||||
}
|
|
||||||
return storeService.getBelongIdByRequiredLoginUserId();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,13 @@
|
|||||||
package com.imyeyu.api.modules.gao.controller;
|
package com.imyeyu.api.modules.gao.controller;
|
||||||
|
|
||||||
import com.imyeyu.api.bean.ModuleCode;
|
|
||||||
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.bean.GaoRoleCode;
|
|
||||||
import com.imyeyu.api.modules.gao.entity.GaoPointLedger;
|
import com.imyeyu.api.modules.gao.entity.GaoPointLedger;
|
||||||
import com.imyeyu.api.modules.gao.service.GaoPointLedgerService;
|
import com.imyeyu.api.modules.gao.service.GaoPointLedgerService;
|
||||||
import com.imyeyu.api.modules.gao.service.GaoPointTriggerService;
|
import com.imyeyu.api.modules.gao.service.GaoPointTriggerService;
|
||||||
import com.imyeyu.api.modules.gao.service.GaoStoreService;
|
import com.imyeyu.api.modules.gao.service.GaoStoreScopeService;
|
||||||
import com.imyeyu.api.modules.gao.vo.GaoPointAdjustRequest;
|
import com.imyeyu.api.modules.gao.vo.GaoPointAdjustRequest;
|
||||||
import com.imyeyu.api.modules.gao.vo.GaoPointLedgerPage;
|
import com.imyeyu.api.modules.gao.vo.GaoPointLedgerPage;
|
||||||
import com.imyeyu.api.modules.user.service.RoleChecker;
|
|
||||||
import com.imyeyu.java.bean.timi.TimiException;
|
import com.imyeyu.java.bean.timi.TimiException;
|
||||||
import com.imyeyu.spring.annotation.AOPLog;
|
import com.imyeyu.spring.annotation.AOPLog;
|
||||||
import com.imyeyu.spring.annotation.RequestRateLimit;
|
import com.imyeyu.spring.annotation.RequestRateLimit;
|
||||||
@@ -30,8 +27,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
@RequestMapping("/gao/customer/point")
|
@RequestMapping("/gao/customer/point")
|
||||||
public class GaoPointLedgerController {
|
public class GaoPointLedgerController {
|
||||||
|
|
||||||
private final RoleChecker roleChecker;
|
private final GaoStoreScopeService storeScopeService;
|
||||||
private final GaoStoreService storeService;
|
|
||||||
private final GaoPointLedgerService ledgerService;
|
private final GaoPointLedgerService ledgerService;
|
||||||
private final GaoPointTriggerService triggerService;
|
private final GaoPointTriggerService triggerService;
|
||||||
|
|
||||||
@@ -41,7 +37,7 @@ public class GaoPointLedgerController {
|
|||||||
@PostMapping("/ledger/list")
|
@PostMapping("/ledger/list")
|
||||||
public PageResult<GaoPointLedger> list(@RequestBody GaoPointLedgerPage page) {
|
public PageResult<GaoPointLedger> list(@RequestBody GaoPointLedgerPage page) {
|
||||||
TimiException.required(page, "not found page");
|
TimiException.required(page, "not found page");
|
||||||
page.setStoreId(resolveStoreId(page.getStoreId()));
|
page.setStoreId(storeScopeService.resolveStoreId(page.getStoreId()));
|
||||||
return ledgerService.pageByQuery(page);
|
return ledgerService.pageByQuery(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,14 +46,7 @@ public class GaoPointLedgerController {
|
|||||||
@RequireGaoPermission(GaoPermissionCode.POINT_ADJUST)
|
@RequireGaoPermission(GaoPermissionCode.POINT_ADJUST)
|
||||||
@PostMapping("/adjust")
|
@PostMapping("/adjust")
|
||||||
public void adjust(@RequestBody GaoPointAdjustRequest request) {
|
public void adjust(@RequestBody GaoPointAdjustRequest request) {
|
||||||
request.setStoreId(resolveStoreId(request.getStoreId()));
|
request.setStoreId(storeScopeService.resolveStoreId(request.getStoreId()));
|
||||||
triggerService.adjust(request);
|
triggerService.adjust(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String resolveStoreId(String requestedStoreId) {
|
|
||||||
if (roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name())) {
|
|
||||||
return requestedStoreId;
|
|
||||||
}
|
|
||||||
return storeService.getBelongIdByRequiredLoginUserId();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
package com.imyeyu.api.modules.gao.controller;
|
package com.imyeyu.api.modules.gao.controller;
|
||||||
|
|
||||||
import com.imyeyu.api.bean.ModuleCode;
|
|
||||||
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.bean.GaoRoleCode;
|
|
||||||
import com.imyeyu.api.modules.gao.entity.GaoPointRule;
|
import com.imyeyu.api.modules.gao.entity.GaoPointRule;
|
||||||
import com.imyeyu.api.modules.gao.service.GaoPointRuleService;
|
import com.imyeyu.api.modules.gao.service.GaoPointRuleService;
|
||||||
import com.imyeyu.api.modules.gao.service.GaoStoreService;
|
import com.imyeyu.api.modules.gao.service.GaoStoreScopeService;
|
||||||
import com.imyeyu.api.modules.user.service.RoleChecker;
|
|
||||||
import com.imyeyu.java.TimiJava;
|
import com.imyeyu.java.TimiJava;
|
||||||
import com.imyeyu.java.bean.timi.TimiException;
|
import com.imyeyu.java.bean.timi.TimiException;
|
||||||
import com.imyeyu.spring.annotation.AOPLog;
|
import com.imyeyu.spring.annotation.AOPLog;
|
||||||
@@ -32,8 +29,7 @@ import java.util.List;
|
|||||||
@RequestMapping("/gao/customer/point")
|
@RequestMapping("/gao/customer/point")
|
||||||
public class GaoPointRuleController {
|
public class GaoPointRuleController {
|
||||||
|
|
||||||
private final RoleChecker roleChecker;
|
private final GaoStoreScopeService storeScopeService;
|
||||||
private final GaoStoreService storeService;
|
|
||||||
private final GaoPointRuleService ruleService;
|
private final GaoPointRuleService ruleService;
|
||||||
|
|
||||||
@AOPLog
|
@AOPLog
|
||||||
@@ -42,9 +38,9 @@ public class GaoPointRuleController {
|
|||||||
@PostMapping("/rule/list")
|
@PostMapping("/rule/list")
|
||||||
public PageResult<GaoPointRule> list(@RequestBody Page<GaoPointRule> page) {
|
public PageResult<GaoPointRule> list(@RequestBody Page<GaoPointRule> page) {
|
||||||
TimiException.required(page, "not found page");
|
TimiException.required(page, "not found page");
|
||||||
if (!isGlobalManager()) {
|
if (!storeScopeService.hasGlobalScope()) {
|
||||||
GaoPointRule example = TimiJava.defaultIfNull(page.getEqualsExample(), new GaoPointRule());
|
GaoPointRule example = TimiJava.defaultIfNull(page.getEqualsExample(), new GaoPointRule());
|
||||||
example.setStoreId(resolveStoreId(null));
|
example.setStoreId(storeScopeService.resolveStoreId(example.getStoreId()));
|
||||||
page.setEqualsExample(example);
|
page.setEqualsExample(example);
|
||||||
}
|
}
|
||||||
return ruleService.page(page);
|
return ruleService.page(page);
|
||||||
@@ -57,7 +53,7 @@ public class GaoPointRuleController {
|
|||||||
public GaoPointRule detail(@RequestParam String id) {
|
public GaoPointRule detail(@RequestParam String id) {
|
||||||
GaoPointRule rule = ruleService.get(id);
|
GaoPointRule rule = ruleService.get(id);
|
||||||
TimiException.required(rule, "not found point rule");
|
TimiException.required(rule, "not found point rule");
|
||||||
checkStore(rule.getStoreId());
|
storeScopeService.checkStoreId(rule.getStoreId());
|
||||||
return rule;
|
return rule;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,7 +62,7 @@ public class GaoPointRuleController {
|
|||||||
@RequireGaoPermission(GaoPermissionCode.POINT_RULE_CREATE)
|
@RequireGaoPermission(GaoPermissionCode.POINT_RULE_CREATE)
|
||||||
@PostMapping("/rule/create")
|
@PostMapping("/rule/create")
|
||||||
public String create(@RequestBody GaoPointRule rule) {
|
public String create(@RequestBody GaoPointRule rule) {
|
||||||
rule.setStoreId(resolveStoreId(rule.getStoreId()));
|
rule.setStoreId(storeScopeService.resolveStoreId(rule.getStoreId()));
|
||||||
ruleService.create(rule);
|
ruleService.create(rule);
|
||||||
return rule.getId();
|
return rule.getId();
|
||||||
}
|
}
|
||||||
@@ -76,7 +72,7 @@ public class GaoPointRuleController {
|
|||||||
@RequireGaoPermission(GaoPermissionCode.POINT_RULE_UPDATE)
|
@RequireGaoPermission(GaoPermissionCode.POINT_RULE_UPDATE)
|
||||||
@PostMapping("/rule/update")
|
@PostMapping("/rule/update")
|
||||||
public void update(@RequestBody GaoPointRule rule) {
|
public void update(@RequestBody GaoPointRule rule) {
|
||||||
rule.setStoreId(resolveStoreId(rule.getStoreId()));
|
rule.setStoreId(storeScopeService.resolveStoreId(rule.getStoreId()));
|
||||||
ruleService.update(rule);
|
ruleService.update(rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,7 +83,7 @@ public class GaoPointRuleController {
|
|||||||
public void sort(@RequestBody List<String> idList) {
|
public void sort(@RequestBody List<String> idList) {
|
||||||
if (idList != null) {
|
if (idList != null) {
|
||||||
for (GaoPointRule rule : ruleService.listByIdList(idList)) {
|
for (GaoPointRule rule : ruleService.listByIdList(idList)) {
|
||||||
checkStore(rule.getStoreId());
|
storeScopeService.checkStoreId(rule.getStoreId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ruleService.sort(idList);
|
ruleService.sort(idList);
|
||||||
@@ -100,24 +96,7 @@ public class GaoPointRuleController {
|
|||||||
public void delete(@RequestParam String id) {
|
public void delete(@RequestParam String id) {
|
||||||
GaoPointRule rule = ruleService.get(id);
|
GaoPointRule rule = ruleService.get(id);
|
||||||
TimiException.required(rule, "not found point rule");
|
TimiException.required(rule, "not found point rule");
|
||||||
checkStore(rule.getStoreId());
|
storeScopeService.checkStoreId(rule.getStoreId());
|
||||||
ruleService.delete(id);
|
ruleService.delete(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String resolveStoreId(String requestedStoreId) {
|
|
||||||
if (isGlobalManager()) {
|
|
||||||
return requestedStoreId;
|
|
||||||
}
|
|
||||||
return storeService.getBelongIdByRequiredLoginUserId();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkStore(String storeId) {
|
|
||||||
if (!isGlobalManager()) {
|
|
||||||
TimiException.requiredTrue(resolveStoreId(null).equals(storeId), "无权操作其他门店数据");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isGlobalManager() {
|
|
||||||
return roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+23
-2
@@ -4,6 +4,9 @@ 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.GaoStoreBusinessDay;
|
import com.imyeyu.api.modules.gao.entity.GaoStoreBusinessDay;
|
||||||
import com.imyeyu.api.modules.gao.service.GaoStoreBusinessDayService;
|
import com.imyeyu.api.modules.gao.service.GaoStoreBusinessDayService;
|
||||||
|
import com.imyeyu.api.modules.gao.service.GaoStoreScopeService;
|
||||||
|
import com.imyeyu.java.TimiJava;
|
||||||
|
import com.imyeyu.java.bean.timi.TimiException;
|
||||||
import com.imyeyu.spring.annotation.AOPLog;
|
import com.imyeyu.spring.annotation.AOPLog;
|
||||||
import com.imyeyu.spring.annotation.RequestRateLimit;
|
import com.imyeyu.spring.annotation.RequestRateLimit;
|
||||||
import com.imyeyu.spring.bean.Page;
|
import com.imyeyu.spring.bean.Page;
|
||||||
@@ -27,12 +30,17 @@ import java.util.List;
|
|||||||
public class GaoStoreBusinessDayController {
|
public class GaoStoreBusinessDayController {
|
||||||
|
|
||||||
private final GaoStoreBusinessDayService service;
|
private final GaoStoreBusinessDayService service;
|
||||||
|
private final GaoStoreScopeService storeScopeService;
|
||||||
|
|
||||||
@AOPLog
|
@AOPLog
|
||||||
@RequestRateLimit
|
@RequestRateLimit
|
||||||
@RequireGaoPermission(GaoPermissionCode.STORE_READ)
|
@RequireGaoPermission(GaoPermissionCode.STORE_READ)
|
||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
public PageResult<GaoStoreBusinessDay> list(@RequestBody Page<GaoStoreBusinessDay> page) {
|
public PageResult<GaoStoreBusinessDay> list(@RequestBody Page<GaoStoreBusinessDay> page) {
|
||||||
|
TimiException.required(page, "not found page");
|
||||||
|
GaoStoreBusinessDay example = TimiJava.defaultIfNull(page.getEqualsExample(), new GaoStoreBusinessDay());
|
||||||
|
example.setStoreId(storeScopeService.resolveStoreId(example.getStoreId()));
|
||||||
|
page.setEqualsExample(example);
|
||||||
return service.page(page);
|
return service.page(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,7 +49,7 @@ public class GaoStoreBusinessDayController {
|
|||||||
@RequireGaoPermission(GaoPermissionCode.STORE_READ)
|
@RequireGaoPermission(GaoPermissionCode.STORE_READ)
|
||||||
@PostMapping("/calendar")
|
@PostMapping("/calendar")
|
||||||
public List<GaoStoreBusinessDay> calendar(@RequestParam String storeId, @RequestParam Integer beginDateValue, @RequestParam Integer endDateValue) {
|
public List<GaoStoreBusinessDay> calendar(@RequestParam String storeId, @RequestParam Integer beginDateValue, @RequestParam Integer endDateValue) {
|
||||||
return service.listByDateRange(storeId, beginDateValue, endDateValue);
|
return service.listByDateRange(storeScopeService.resolveStoreId(storeId), beginDateValue, endDateValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AOPLog
|
@AOPLog
|
||||||
@@ -49,7 +57,10 @@ public class GaoStoreBusinessDayController {
|
|||||||
@RequireGaoPermission(GaoPermissionCode.STORE_READ)
|
@RequireGaoPermission(GaoPermissionCode.STORE_READ)
|
||||||
@PostMapping("/detail")
|
@PostMapping("/detail")
|
||||||
public GaoStoreBusinessDay detail(@RequestParam String id) {
|
public GaoStoreBusinessDay detail(@RequestParam String id) {
|
||||||
return service.get(id);
|
GaoStoreBusinessDay businessDay = service.get(id);
|
||||||
|
TimiException.required(businessDay, "not found businessDay");
|
||||||
|
storeScopeService.checkStoreId(businessDay.getStoreId());
|
||||||
|
return businessDay;
|
||||||
}
|
}
|
||||||
|
|
||||||
@AOPLog
|
@AOPLog
|
||||||
@@ -57,6 +68,7 @@ public class GaoStoreBusinessDayController {
|
|||||||
@RequireGaoPermission(GaoPermissionCode.STORE_UPDATE)
|
@RequireGaoPermission(GaoPermissionCode.STORE_UPDATE)
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
public String create(@RequestBody GaoStoreBusinessDay businessDay) {
|
public String create(@RequestBody GaoStoreBusinessDay businessDay) {
|
||||||
|
businessDay.setStoreId(storeScopeService.resolveStoreId(businessDay.getStoreId()));
|
||||||
service.create(businessDay);
|
service.create(businessDay);
|
||||||
return businessDay.getId();
|
return businessDay.getId();
|
||||||
}
|
}
|
||||||
@@ -66,6 +78,12 @@ public class GaoStoreBusinessDayController {
|
|||||||
@RequireGaoPermission(GaoPermissionCode.STORE_UPDATE)
|
@RequireGaoPermission(GaoPermissionCode.STORE_UPDATE)
|
||||||
@PostMapping("/update")
|
@PostMapping("/update")
|
||||||
public void update(@RequestBody GaoStoreBusinessDay businessDay) {
|
public void update(@RequestBody GaoStoreBusinessDay businessDay) {
|
||||||
|
TimiException.required(businessDay, "not found businessDay");
|
||||||
|
TimiException.required(businessDay.getId(), "not found businessDay.id");
|
||||||
|
GaoStoreBusinessDay dbBusinessDay = service.get(businessDay.getId());
|
||||||
|
TimiException.required(dbBusinessDay, "not found businessDay");
|
||||||
|
storeScopeService.checkStoreId(dbBusinessDay.getStoreId());
|
||||||
|
businessDay.setStoreId(dbBusinessDay.getStoreId());
|
||||||
service.update(businessDay);
|
service.update(businessDay);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,6 +92,9 @@ public class GaoStoreBusinessDayController {
|
|||||||
@RequireGaoPermission(GaoPermissionCode.STORE_DELETE)
|
@RequireGaoPermission(GaoPermissionCode.STORE_DELETE)
|
||||||
@PostMapping("/delete")
|
@PostMapping("/delete")
|
||||||
public void delete(@RequestParam String id) {
|
public void delete(@RequestParam String id) {
|
||||||
|
GaoStoreBusinessDay businessDay = service.get(id);
|
||||||
|
TimiException.required(businessDay, "not found businessDay");
|
||||||
|
storeScopeService.checkStoreId(businessDay.getStoreId());
|
||||||
service.delete(id);
|
service.delete(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,12 +3,14 @@ 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.service.GaoStoreChartService;
|
import com.imyeyu.api.modules.gao.service.GaoStoreChartService;
|
||||||
|
import com.imyeyu.api.modules.gao.service.GaoStoreScopeService;
|
||||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerDailyStateView;
|
import com.imyeyu.api.modules.gao.vo.GaoCustomerDailyStateView;
|
||||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerGenderStatView;
|
import com.imyeyu.api.modules.gao.vo.GaoCustomerGenderStatView;
|
||||||
import com.imyeyu.api.modules.gao.vo.GaoEventRecordCalendarView;
|
import com.imyeyu.api.modules.gao.vo.GaoEventRecordCalendarView;
|
||||||
import com.imyeyu.api.modules.gao.vo.GaoEventRecordDailyStatView;
|
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.GaoStoreChartReq;
|
import com.imyeyu.api.modules.gao.vo.GaoStoreChartReq;
|
||||||
|
import com.imyeyu.java.bean.timi.TimiException;
|
||||||
import com.imyeyu.spring.annotation.AOPLog;
|
import com.imyeyu.spring.annotation.AOPLog;
|
||||||
import com.imyeyu.spring.annotation.RequestRateLimit;
|
import com.imyeyu.spring.annotation.RequestRateLimit;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@@ -30,6 +32,7 @@ import java.util.List;
|
|||||||
public class GaoStoreChartController {
|
public class GaoStoreChartController {
|
||||||
|
|
||||||
private final GaoStoreChartService service;
|
private final GaoStoreChartService service;
|
||||||
|
private final GaoStoreScopeService storeScopeService;
|
||||||
|
|
||||||
/// 查询客户增长趋势
|
/// 查询客户增长趋势
|
||||||
@AOPLog
|
@AOPLog
|
||||||
@@ -37,6 +40,8 @@ public class GaoStoreChartController {
|
|||||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||||
@PostMapping("/customer/daily")
|
@PostMapping("/customer/daily")
|
||||||
public List<GaoCustomerDailyStateView> customerDaily(@RequestBody GaoStoreChartReq req) {
|
public List<GaoCustomerDailyStateView> customerDaily(@RequestBody GaoStoreChartReq req) {
|
||||||
|
TimiException.required(req, "not found req");
|
||||||
|
req.setStoreId(storeScopeService.resolveStoreId(req.getStoreId()));
|
||||||
return service.customerDailyTrend(req);
|
return service.customerDailyTrend(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,7 +51,7 @@ public class GaoStoreChartController {
|
|||||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||||
@PostMapping("/customer/gender")
|
@PostMapping("/customer/gender")
|
||||||
public List<GaoCustomerGenderStatView> customerGender(@RequestParam String storeId) {
|
public List<GaoCustomerGenderStatView> customerGender(@RequestParam String storeId) {
|
||||||
return service.customerGender(storeId);
|
return service.customerGender(storeScopeService.resolveStoreId(storeId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 查询登记事件每日统计,可同时支撑登记趋势和事件结构图表
|
/// 查询登记事件每日统计,可同时支撑登记趋势和事件结构图表
|
||||||
@@ -55,6 +60,8 @@ public class GaoStoreChartController {
|
|||||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||||
@PostMapping("/event/record/daily")
|
@PostMapping("/event/record/daily")
|
||||||
public List<GaoEventRecordDailyStatView> eventRecordDaily(@RequestBody GaoStoreChartReq req) {
|
public List<GaoEventRecordDailyStatView> eventRecordDaily(@RequestBody GaoStoreChartReq req) {
|
||||||
|
TimiException.required(req, "not found req");
|
||||||
|
req.setStoreId(storeScopeService.resolveStoreId(req.getStoreId()));
|
||||||
return service.eventRecordDailyStat(req);
|
return service.eventRecordDailyStat(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,6 +71,8 @@ public class GaoStoreChartController {
|
|||||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||||
@PostMapping("/event/record/number-value/daily")
|
@PostMapping("/event/record/number-value/daily")
|
||||||
public List<GaoEventRecordNumberValueDailyStatView> eventRecordNumberValueDaily(@RequestBody GaoStoreChartReq req) {
|
public List<GaoEventRecordNumberValueDailyStatView> eventRecordNumberValueDaily(@RequestBody GaoStoreChartReq req) {
|
||||||
|
TimiException.required(req, "not found req");
|
||||||
|
req.setStoreId(storeScopeService.resolveStoreId(req.getStoreId()));
|
||||||
return service.eventRecordNumberValueDailyStat(req);
|
return service.eventRecordNumberValueDailyStat(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,6 +82,8 @@ public class GaoStoreChartController {
|
|||||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||||
@PostMapping("/event/record/calendar")
|
@PostMapping("/event/record/calendar")
|
||||||
public List<GaoEventRecordCalendarView> eventRecordCalendar(@RequestBody GaoStoreChartReq req) {
|
public List<GaoEventRecordCalendarView> eventRecordCalendar(@RequestBody GaoStoreChartReq req) {
|
||||||
|
TimiException.required(req, "not found req");
|
||||||
|
req.setStoreId(storeScopeService.resolveStoreId(req.getStoreId()));
|
||||||
return service.eventRecordCalendar(req);
|
return service.eventRecordCalendar(req);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package com.imyeyu.api.modules.gao.controller;
|
package com.imyeyu.api.modules.gao.controller;
|
||||||
|
|
||||||
import com.imyeyu.api.bean.ModuleCode;
|
|
||||||
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.GaoStore;
|
import com.imyeyu.api.modules.gao.entity.GaoStore;
|
||||||
|
import com.imyeyu.api.modules.gao.service.GaoStoreScopeService;
|
||||||
import com.imyeyu.api.modules.gao.service.GaoStoreService;
|
import com.imyeyu.api.modules.gao.service.GaoStoreService;
|
||||||
import com.imyeyu.api.modules.user.service.PermissionChecker;
|
|
||||||
import com.imyeyu.api.modules.user.service.UserLoginService;
|
import com.imyeyu.api.modules.user.service.UserLoginService;
|
||||||
import com.imyeyu.java.TimiJava;
|
import com.imyeyu.java.TimiJava;
|
||||||
|
import com.imyeyu.java.bean.timi.TimiException;
|
||||||
import com.imyeyu.network.Network;
|
import com.imyeyu.network.Network;
|
||||||
import com.imyeyu.spring.TimiSpring;
|
import com.imyeyu.spring.TimiSpring;
|
||||||
import com.imyeyu.spring.annotation.AOPLog;
|
import com.imyeyu.spring.annotation.AOPLog;
|
||||||
@@ -37,14 +37,20 @@ import java.util.List;
|
|||||||
public class GaoStoreController {
|
public class GaoStoreController {
|
||||||
|
|
||||||
private final GaoStoreService service;
|
private final GaoStoreService service;
|
||||||
|
private final GaoStoreScopeService storeScopeService;
|
||||||
private final UserLoginService userLoginService;
|
private final UserLoginService userLoginService;
|
||||||
private final PermissionChecker permissionChecker;
|
|
||||||
|
|
||||||
@AOPLog
|
@AOPLog
|
||||||
@RequestRateLimit
|
@RequestRateLimit
|
||||||
@RequireGaoPermission(GaoPermissionCode.STORE_READ)
|
@RequireGaoPermission(GaoPermissionCode.STORE_READ)
|
||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
public PageResult<GaoStore> list(@RequestBody Page<GaoStore> page) {
|
public PageResult<GaoStore> list(@RequestBody Page<GaoStore> page) {
|
||||||
|
TimiException.required(page, "not found page");
|
||||||
|
if (!storeScopeService.hasGlobalScope()) {
|
||||||
|
GaoStore example = TimiJava.defaultIfNull(page.getEqualsExample(), new GaoStore());
|
||||||
|
example.setId(storeScopeService.resolveStoreId(example.getId()));
|
||||||
|
page.setEqualsExample(example);
|
||||||
|
}
|
||||||
return service.page(page);
|
return service.page(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +59,9 @@ public class GaoStoreController {
|
|||||||
@RequireGaoPermission(GaoPermissionCode.STORE_READ)
|
@RequireGaoPermission(GaoPermissionCode.STORE_READ)
|
||||||
@PostMapping("/detail")
|
@PostMapping("/detail")
|
||||||
public GaoStore detail(@RequestParam String id) {
|
public GaoStore detail(@RequestParam String id) {
|
||||||
return service.get(id);
|
GaoStore store = service.get(id);
|
||||||
|
storeScopeService.checkStore(store);
|
||||||
|
return store;
|
||||||
}
|
}
|
||||||
|
|
||||||
@AOPLog
|
@AOPLog
|
||||||
@@ -70,12 +78,13 @@ public class GaoStoreController {
|
|||||||
@RequireGaoPermission(GaoPermissionCode.STORE_UPDATE)
|
@RequireGaoPermission(GaoPermissionCode.STORE_UPDATE)
|
||||||
@PostMapping("/update")
|
@PostMapping("/update")
|
||||||
public void update(@RequestBody GaoStore store) {
|
public void update(@RequestBody GaoStore store) {
|
||||||
if (permissionChecker.hasAny(ModuleCode.GAO, GaoPermissionCode.STORE_CREATE.getValue())) {
|
if (storeScopeService.hasGlobalScope()) {
|
||||||
// 门店管理
|
// 门店管理
|
||||||
service.update(store);
|
service.update(store);
|
||||||
} else {
|
} else {
|
||||||
// 店长
|
// 店长
|
||||||
GaoStore dbStore = service.get(store.getId());
|
GaoStore dbStore = service.get(store.getId());
|
||||||
|
storeScopeService.checkStore(dbStore);
|
||||||
dbStore.setName(store.getName());
|
dbStore.setName(store.getName());
|
||||||
dbStore.setTelephone(store.getTelephone());
|
dbStore.setTelephone(store.getTelephone());
|
||||||
dbStore.setAddress(store.getAddress());
|
dbStore.setAddress(store.getAddress());
|
||||||
@@ -98,6 +107,11 @@ public class GaoStoreController {
|
|||||||
@RequireGaoPermission(GaoPermissionCode.STORE_UPDATE)
|
@RequireGaoPermission(GaoPermissionCode.STORE_UPDATE)
|
||||||
@PostMapping("/sort")
|
@PostMapping("/sort")
|
||||||
public void sort(@RequestBody List<String> idList) {
|
public void sort(@RequestBody List<String> idList) {
|
||||||
|
if (!storeScopeService.hasGlobalScope()) {
|
||||||
|
for (String id : TimiJava.safeIterable(idList)) {
|
||||||
|
storeScopeService.checkStore(service.get(id));
|
||||||
|
}
|
||||||
|
}
|
||||||
service.sort(idList);
|
service.sort(idList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,6 +121,12 @@ public class GaoStoreController {
|
|||||||
@RequireGaoPermission(GaoPermissionCode.STORE_EXPORT)
|
@RequireGaoPermission(GaoPermissionCode.STORE_EXPORT)
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(@RequestBody Page<GaoStore> page) throws IOException {
|
public void export(@RequestBody Page<GaoStore> page) throws IOException {
|
||||||
|
TimiException.required(page, "not found page");
|
||||||
|
if (!storeScopeService.hasGlobalScope()) {
|
||||||
|
GaoStore example = TimiJava.defaultIfNull(page.getEqualsExample(), new GaoStore());
|
||||||
|
example.setId(storeScopeService.resolveStoreId(example.getId()));
|
||||||
|
page.setEqualsExample(example);
|
||||||
|
}
|
||||||
HttpServletResponse resp = TimiSpring.getResponse();
|
HttpServletResponse resp = TimiSpring.getResponse();
|
||||||
String contentDisposition = Network.getFileDownloadHeader("门店列表-%s.xlsx".formatted(Time.serialize.format(Time.now())));
|
String contentDisposition = Network.getFileDownloadHeader("门店列表-%s.xlsx".formatted(Time.serialize.format(Time.now())));
|
||||||
resp.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
resp.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||||
|
|||||||
@@ -6,9 +6,8 @@ import com.imyeyu.api.modules.common.entity.Attachment;
|
|||||||
import com.imyeyu.api.modules.common.service.AttachmentService;
|
import com.imyeyu.api.modules.common.service.AttachmentService;
|
||||||
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.bean.GaoRoleCode;
|
|
||||||
import com.imyeyu.api.modules.gao.entity.GaoUser;
|
import com.imyeyu.api.modules.gao.entity.GaoUser;
|
||||||
import com.imyeyu.api.modules.gao.service.GaoStoreService;
|
import com.imyeyu.api.modules.gao.service.GaoStoreScopeService;
|
||||||
import com.imyeyu.api.modules.gao.service.GaoUserInviteService;
|
import com.imyeyu.api.modules.gao.service.GaoUserInviteService;
|
||||||
import com.imyeyu.api.modules.gao.service.GaoUserService;
|
import com.imyeyu.api.modules.gao.service.GaoUserService;
|
||||||
import com.imyeyu.api.modules.gao.vo.GaoUserInviteCreateRequest;
|
import com.imyeyu.api.modules.gao.vo.GaoUserInviteCreateRequest;
|
||||||
@@ -19,13 +18,13 @@ import com.imyeyu.api.modules.gao.vo.GaoUserInviteValidateRequest;
|
|||||||
import com.imyeyu.api.modules.gao.vo.GaoUserInviteValidateResponse;
|
import com.imyeyu.api.modules.gao.vo.GaoUserInviteValidateResponse;
|
||||||
import com.imyeyu.api.modules.user.entity.Role;
|
import com.imyeyu.api.modules.user.entity.Role;
|
||||||
import com.imyeyu.api.modules.user.entity.User;
|
import com.imyeyu.api.modules.user.entity.User;
|
||||||
import com.imyeyu.api.modules.user.service.RoleChecker;
|
import com.imyeyu.api.modules.user.service.AuthorizationScopeService;
|
||||||
import com.imyeyu.api.modules.user.service.RoleService;
|
|
||||||
import com.imyeyu.api.modules.user.service.UserLoginService;
|
import com.imyeyu.api.modules.user.service.UserLoginService;
|
||||||
import com.imyeyu.api.modules.user.service.UserRoleService;
|
import com.imyeyu.api.modules.user.service.UserRoleService;
|
||||||
import com.imyeyu.api.modules.user.service.UserService;
|
import com.imyeyu.api.modules.user.service.UserService;
|
||||||
import com.imyeyu.api.modules.user.vo.LoginResponse;
|
import com.imyeyu.api.modules.user.vo.LoginResponse;
|
||||||
import com.imyeyu.java.TimiJava;
|
import com.imyeyu.java.TimiJava;
|
||||||
|
import com.imyeyu.java.bean.timi.TimiException;
|
||||||
import com.imyeyu.spring.annotation.AOPLog;
|
import com.imyeyu.spring.annotation.AOPLog;
|
||||||
import com.imyeyu.spring.annotation.RequestRateLimit;
|
import com.imyeyu.spring.annotation.RequestRateLimit;
|
||||||
import com.imyeyu.spring.bean.Page;
|
import com.imyeyu.spring.bean.Page;
|
||||||
@@ -53,12 +52,11 @@ import java.util.UUID;
|
|||||||
public class GaoUserController {
|
public class GaoUserController {
|
||||||
|
|
||||||
private final UserService userService;
|
private final UserService userService;
|
||||||
private final RoleService roleService;
|
private final AuthorizationScopeService authorizationScopeService;
|
||||||
private final RoleChecker roleChecker;
|
|
||||||
private final GaoUserService service;
|
private final GaoUserService service;
|
||||||
private final GaoUserInviteService inviteService;
|
private final GaoUserInviteService inviteService;
|
||||||
private final UserRoleService userRoleService;
|
private final UserRoleService userRoleService;
|
||||||
private final GaoStoreService gaoStoreService;
|
private final GaoStoreScopeService storeScopeService;
|
||||||
private final UserLoginService userLoginService;
|
private final UserLoginService userLoginService;
|
||||||
private final AttachmentService attachmentService;
|
private final AttachmentService attachmentService;
|
||||||
|
|
||||||
@@ -93,10 +91,11 @@ public class GaoUserController {
|
|||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
@JsonView(ResponseView.Public.class)
|
@JsonView(ResponseView.Public.class)
|
||||||
public PageResult<GaoUser> list(@RequestBody Page<GaoUser> page) {
|
public PageResult<GaoUser> list(@RequestBody Page<GaoUser> page) {
|
||||||
if (!roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name())) {
|
TimiException.required(page, "not found page");
|
||||||
|
if (!storeScopeService.hasGlobalScope()) {
|
||||||
// 非全局管理只能看所在店用户
|
// 非全局管理只能看所在店用户
|
||||||
page.setEqualsExample(TimiJava.defaultIfNull(page.getEqualsExample(), new GaoUser()));
|
page.setEqualsExample(TimiJava.defaultIfNull(page.getEqualsExample(), new GaoUser()));
|
||||||
page.getEqualsExample().setStoreId(gaoStoreService.getByUserId(userLoginService.getRequireLoginUserId()).getId());
|
page.getEqualsExample().setStoreId(storeScopeService.resolveStoreId(page.getEqualsExample().getStoreId()));
|
||||||
}
|
}
|
||||||
PageResult<GaoUser> result = service.page(page);
|
PageResult<GaoUser> result = service.page(page);
|
||||||
{
|
{
|
||||||
@@ -118,6 +117,8 @@ public class GaoUserController {
|
|||||||
@JsonView(ResponseView.Public.class)
|
@JsonView(ResponseView.Public.class)
|
||||||
public GaoUser detail(@RequestParam String id) {
|
public GaoUser detail(@RequestParam String id) {
|
||||||
GaoUser result = service.get(id);
|
GaoUser result = service.get(id);
|
||||||
|
TimiException.required(result, "not found gao user");
|
||||||
|
storeScopeService.checkStoreId(result.getStoreId());
|
||||||
{
|
{
|
||||||
User user = userService.get(result.getUserId());
|
User user = userService.get(result.getUserId());
|
||||||
user.setAttachmentList(attachmentService.listByBizId(Attachment.BizType.USER, user.getId()));
|
user.setAttachmentList(attachmentService.listByBizId(Attachment.BizType.USER, user.getId()));
|
||||||
@@ -135,9 +136,7 @@ public class GaoUserController {
|
|||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@JsonView(ResponseView.Public.class)
|
@JsonView(ResponseView.Public.class)
|
||||||
public GaoUser create(@RequestBody GaoUser gaoUser) {
|
public GaoUser create(@RequestBody GaoUser gaoUser) {
|
||||||
if (!roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name())) {
|
gaoUser.setStoreId(storeScopeService.resolveStoreId(gaoUser.getStoreId()));
|
||||||
gaoUser.setStoreId(gaoStoreService.getByUserId(userLoginService.getRequireLoginUserId()).getId());
|
|
||||||
}
|
|
||||||
service.create(gaoUser);
|
service.create(gaoUser);
|
||||||
return service.get(gaoUser.getId());
|
return service.get(gaoUser.getId());
|
||||||
}
|
}
|
||||||
@@ -148,6 +147,12 @@ public class GaoUserController {
|
|||||||
@PostMapping("/update")
|
@PostMapping("/update")
|
||||||
@JsonView(ResponseView.Public.class)
|
@JsonView(ResponseView.Public.class)
|
||||||
public GaoUser update(@RequestBody GaoUser gaoUser) {
|
public GaoUser update(@RequestBody GaoUser gaoUser) {
|
||||||
|
TimiException.required(gaoUser, "not found gao user");
|
||||||
|
TimiException.required(gaoUser.getId(), "not found gao user.id");
|
||||||
|
GaoUser dbGaoUser = service.get(gaoUser.getId());
|
||||||
|
TimiException.required(dbGaoUser, "not found gao user");
|
||||||
|
storeScopeService.checkStoreId(dbGaoUser.getStoreId());
|
||||||
|
gaoUser.setStoreId(dbGaoUser.getStoreId());
|
||||||
service.update(gaoUser);
|
service.update(gaoUser);
|
||||||
return service.get(gaoUser.getId());
|
return service.get(gaoUser.getId());
|
||||||
}
|
}
|
||||||
@@ -158,6 +163,12 @@ public class GaoUserController {
|
|||||||
@PostMapping("/transfer/store")
|
@PostMapping("/transfer/store")
|
||||||
@JsonView(ResponseView.Public.class)
|
@JsonView(ResponseView.Public.class)
|
||||||
public GaoUser transferStore(@RequestBody GaoUser gaoUser) {
|
public GaoUser transferStore(@RequestBody GaoUser gaoUser) {
|
||||||
|
TimiException.required(gaoUser, "not found gao user");
|
||||||
|
TimiException.required(gaoUser.getId(), "not found gao user.id");
|
||||||
|
GaoUser dbGaoUser = service.get(gaoUser.getId());
|
||||||
|
TimiException.required(dbGaoUser, "not found gao user");
|
||||||
|
storeScopeService.checkStoreId(dbGaoUser.getStoreId());
|
||||||
|
gaoUser.setStoreId(storeScopeService.resolveStoreId(gaoUser.getStoreId()));
|
||||||
service.transferStore(gaoUser);
|
service.transferStore(gaoUser);
|
||||||
return service.get(gaoUser.getId());
|
return service.get(gaoUser.getId());
|
||||||
}
|
}
|
||||||
@@ -167,6 +178,9 @@ public class GaoUserController {
|
|||||||
@RequireGaoPermission(GaoPermissionCode.USER_DELETE)
|
@RequireGaoPermission(GaoPermissionCode.USER_DELETE)
|
||||||
@PostMapping("/delete")
|
@PostMapping("/delete")
|
||||||
public void delete(@RequestParam String id) {
|
public void delete(@RequestParam String id) {
|
||||||
|
GaoUser gaoUser = service.get(id);
|
||||||
|
TimiException.required(gaoUser, "not found gao user");
|
||||||
|
storeScopeService.checkStoreId(gaoUser.getStoreId());
|
||||||
service.delete(id);
|
service.delete(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,7 +189,6 @@ public class GaoUserController {
|
|||||||
@RequireGaoPermission(GaoPermissionCode.USER_READ)
|
@RequireGaoPermission(GaoPermissionCode.USER_READ)
|
||||||
@PostMapping("/role/list")
|
@PostMapping("/role/list")
|
||||||
public List<Role> roleList() {
|
public List<Role> roleList() {
|
||||||
// TODO 此接口获取本模块所有角色,需要限制角色
|
return authorizationScopeService.listGrantableRole(userLoginService.getRequireLoginUserId(), ModuleCode.GAO);
|
||||||
return roleService.listByModuleCode(ModuleCode.GAO);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,6 +117,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 +138,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;
|
||||||
|
|
||||||
@@ -70,10 +96,17 @@ public class GaoEventRecord extends UUIDEntity {
|
|||||||
@Transient
|
@Transient
|
||||||
private User operator;
|
private User operator;
|
||||||
|
|
||||||
|
@Transient
|
||||||
|
private User verifier;
|
||||||
|
|
||||||
@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;
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ import com.imyeyu.api.modules.gao.vo.GaoCustomerGenderStatView;
|
|||||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerPage;
|
import com.imyeyu.api.modules.gao.vo.GaoCustomerPage;
|
||||||
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.Update;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -48,4 +49,11 @@ public interface GaoCustomerMapper extends BaseMapper<GaoCustomer, String> {
|
|||||||
/// @param page 查询条件
|
/// @param page 查询条件
|
||||||
/// @return 客户列表
|
/// @return 客户列表
|
||||||
List<GaoCustomer> selectByQuery(GaoCustomerPage page);
|
List<GaoCustomer> selectByQuery(GaoCustomerPage page);
|
||||||
|
|
||||||
|
/// 原子调整邀请客户数
|
||||||
|
///
|
||||||
|
/// @param customerId 客户 ID
|
||||||
|
/// @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)
|
||||||
|
void updateInvitedCountDelta(@Param("customerId") String customerId, @Param("delta") Long delta);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,6 +8,7 @@ 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;
|
||||||
@@ -44,6 +45,14 @@ 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 核销时间
|
||||||
|
/// @return 更新行数
|
||||||
|
int verify(@Param("id") String id, @Param("verifierUserId") String verifierUserId, @Param("verifiedAt") Long verifiedAt);
|
||||||
|
|
||||||
/// 按门店和登记日期统计登记记录数
|
/// 按门店和登记日期统计登记记录数
|
||||||
///
|
///
|
||||||
/// @param storeId 门店 ID
|
/// @param storeId 门店 ID
|
||||||
@@ -71,6 +80,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);
|
||||||
|
}
|
||||||
@@ -1,7 +1,12 @@
|
|||||||
package com.imyeyu.api.modules.gao.mapper;
|
package com.imyeyu.api.modules.gao.mapper;
|
||||||
|
|
||||||
import com.imyeyu.api.modules.gao.entity.GaoUser;
|
import com.imyeyu.api.modules.gao.entity.GaoUser;
|
||||||
|
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 java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// GAO 用户 Mapper
|
/// GAO 用户 Mapper
|
||||||
@@ -9,4 +14,10 @@ import com.imyeyu.spring.mapper.BaseMapper;
|
|||||||
/// @author Codex
|
/// @author Codex
|
||||||
/// @since 2026-07-30
|
/// @since 2026-07-30
|
||||||
public interface GaoUserMapper extends BaseMapper<GaoUser, String> {
|
public interface GaoUserMapper extends BaseMapper<GaoUser, String> {
|
||||||
|
|
||||||
|
List<GaoUser> selectByUserIdList(Collection<String> userIdList);
|
||||||
|
|
||||||
|
List<GaoUser> selectRecipientPage(@Param("page") Page<GaoUser> page);
|
||||||
|
|
||||||
|
long countRecipients(@Param("page") Page<GaoUser> page);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.imyeyu.api.modules.gao.service;
|
|||||||
|
|
||||||
import com.imyeyu.api.modules.gao.entity.GaoCustomer;
|
import com.imyeyu.api.modules.gao.entity.GaoCustomer;
|
||||||
import com.imyeyu.api.modules.gao.entity.GaoEventRecord;
|
import com.imyeyu.api.modules.gao.entity.GaoEventRecord;
|
||||||
|
import com.imyeyu.api.modules.gao.vo.GaoEventOptionStatView;
|
||||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerEventRankView;
|
import com.imyeyu.api.modules.gao.vo.GaoCustomerEventRankView;
|
||||||
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;
|
||||||
@@ -24,6 +25,16 @@ public interface GaoEventRecordService extends BaseService<GaoEventRecord, Strin
|
|||||||
/// @return 登记事件记录列表
|
/// @return 登记事件记录列表
|
||||||
List<GaoEventRecord> listByCustomerId(String customerId);
|
List<GaoEventRecord> listByCustomerId(String customerId);
|
||||||
|
|
||||||
|
/// 为登记记录附加已选择的选项组
|
||||||
|
///
|
||||||
|
/// @param recordList 登记记录列表
|
||||||
|
void attachSelectedOptionGroupList(List<GaoEventRecord> recordList);
|
||||||
|
|
||||||
|
/// 核销登记事件记录
|
||||||
|
///
|
||||||
|
/// @param id 登记记录 ID
|
||||||
|
void verify(String id);
|
||||||
|
|
||||||
default void createBatch(List<GaoEventRecord> recordList) {
|
default void createBatch(List<GaoEventRecord> recordList) {
|
||||||
for (GaoEventRecord record : TimiJava.safeIterable(recordList)) {
|
for (GaoEventRecord record : TimiJava.safeIterable(recordList)) {
|
||||||
create(record);
|
create(record);
|
||||||
@@ -44,6 +55,12 @@ public interface GaoEventRecordService extends BaseService<GaoEventRecord, Strin
|
|||||||
/// @return 登记数值合计
|
/// @return 登记数值合计
|
||||||
Long sumNumberValueByRange(GaoEventRecordPage req);
|
Long sumNumberValueByRange(GaoEventRecordPage req);
|
||||||
|
|
||||||
|
/// 按选项统计登记记录数量
|
||||||
|
///
|
||||||
|
/// @param req 登记记录范围查询请求
|
||||||
|
/// @return 选项统计列表
|
||||||
|
List<GaoEventOptionStatView> optionStatByRange(GaoEventRecordPage req);
|
||||||
|
|
||||||
/// 按时间范围查询客户登记排行榜
|
/// 按时间范围查询客户登记排行榜
|
||||||
///
|
///
|
||||||
/// @param page 范围查询请求,不传时间为全部时间
|
/// @param page 范围查询请求,不传时间为全部时间
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.imyeyu.api.modules.gao.service;
|
package com.imyeyu.api.modules.gao.service;
|
||||||
|
|
||||||
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.spring.service.BaseService;
|
import com.imyeyu.spring.service.BaseService;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -24,6 +25,17 @@ public interface GaoEventService extends BaseService<GaoEvent, String> {
|
|||||||
/// @return 登记事件列表
|
/// @return 登记事件列表
|
||||||
List<GaoEvent> listValid(String storeId);
|
List<GaoEvent> listValid(String storeId);
|
||||||
|
|
||||||
|
/// 为登记事件附加选项组和选项
|
||||||
|
///
|
||||||
|
/// @param eventList 登记事件列表
|
||||||
|
void attachOptionGroupList(Collection<GaoEvent> eventList);
|
||||||
|
|
||||||
|
/// 更新登记事件的选项组配置
|
||||||
|
///
|
||||||
|
/// @param eventId 登记事件 ID
|
||||||
|
/// @param optionGroupList 选项组配置列表
|
||||||
|
void updateOptionGroupList(String eventId, List<GaoEventOptionGroup> optionGroupList);
|
||||||
|
|
||||||
/// 删除门店下的全部登记事件及角色关联
|
/// 删除门店下的全部登记事件及角色关联
|
||||||
///
|
///
|
||||||
/// @param storeId 门店 ID
|
/// @param storeId 门店 ID
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package com.imyeyu.api.modules.gao.service;
|
||||||
|
|
||||||
|
import com.imyeyu.api.modules.gao.entity.GaoStore;
|
||||||
|
|
||||||
|
/// GAO 门店资源范围服务
|
||||||
|
///
|
||||||
|
/// 同时拥有门店管理和店长角色时,按门店管理角色使用全局范围
|
||||||
|
///
|
||||||
|
/// @author Codex
|
||||||
|
/// @since 2026-08-23
|
||||||
|
public interface GaoStoreScopeService {
|
||||||
|
|
||||||
|
/// 判断当前用户是否拥有 GAO 全局范围
|
||||||
|
///
|
||||||
|
/// @return `true` 为允许访问全部门店
|
||||||
|
boolean hasGlobalScope();
|
||||||
|
|
||||||
|
/// 将请求门店 ID 解析为当前可用门店 ID
|
||||||
|
///
|
||||||
|
/// @param requestedStoreId 请求中的门店 ID,可为空
|
||||||
|
/// @return 门店 ID,全局范围可为空
|
||||||
|
String resolveStoreId(String requestedStoreId);
|
||||||
|
|
||||||
|
/// 检查门店是否在当前用户可管理范围内
|
||||||
|
///
|
||||||
|
/// @param storeId 门店 ID
|
||||||
|
void checkStoreId(String storeId);
|
||||||
|
|
||||||
|
/// 检查门店实体是否在当前用户可管理范围内
|
||||||
|
///
|
||||||
|
/// @param store 门店
|
||||||
|
void checkStore(GaoStore store);
|
||||||
|
}
|
||||||
@@ -1,8 +1,13 @@
|
|||||||
package com.imyeyu.api.modules.gao.service;
|
package com.imyeyu.api.modules.gao.service;
|
||||||
|
|
||||||
import com.imyeyu.api.modules.gao.entity.GaoUser;
|
import com.imyeyu.api.modules.gao.entity.GaoUser;
|
||||||
|
import com.imyeyu.spring.bean.Page;
|
||||||
|
import com.imyeyu.spring.bean.PageResult;
|
||||||
import com.imyeyu.spring.service.BaseService;
|
import com.imyeyu.spring.service.BaseService;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// GAO 用户服务
|
/// GAO 用户服务
|
||||||
///
|
///
|
||||||
@@ -19,4 +24,16 @@ public interface GaoUserService extends BaseService<GaoUser, String> {
|
|||||||
///
|
///
|
||||||
/// @param gaoUser GAO 用户,必须包含 ID 和目标门店 ID
|
/// @param gaoUser GAO 用户,必须包含 ID 和目标门店 ID
|
||||||
void transferStore(GaoUser gaoUser);
|
void transferStore(GaoUser gaoUser);
|
||||||
|
|
||||||
|
/// 根据核心用户 ID 映射 GAO 用户
|
||||||
|
///
|
||||||
|
/// @param userIdList 核心用户 ID 列表
|
||||||
|
/// @return GAO 用户映射
|
||||||
|
Map<String, GaoUser> mapByUserIdList(Collection<String> userIdList);
|
||||||
|
|
||||||
|
/// 查询可作为通知接收人的启用用户
|
||||||
|
///
|
||||||
|
/// @param page 分页参数
|
||||||
|
/// @return 接收用户分页结果
|
||||||
|
PageResult<GaoUser> pageRecipients(Page<GaoUser> page);
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-11
@@ -117,12 +117,10 @@ public class GaoCustomerServiceImplement extends AbstractEntityService<GaoCustom
|
|||||||
customer.setAge(ChronoUnit.YEARS.between(customer.getBirthdate(), LocalDate.now()));
|
customer.setAge(ChronoUnit.YEARS.between(customer.getBirthdate(), LocalDate.now()));
|
||||||
}
|
}
|
||||||
customer.setInvitedCount(0L);
|
customer.setInvitedCount(0L);
|
||||||
if (customer.hasIntroducer()) {
|
|
||||||
customer.setInvitedCount(1L);
|
|
||||||
}
|
|
||||||
customer.setCreatorUserId(userLoginService.getRequireLoginUserId());
|
customer.setCreatorUserId(userLoginService.getRequireLoginUserId());
|
||||||
|
|
||||||
super.create(customer);
|
super.create(customer);
|
||||||
|
changeInvitedCount(customer.getIntroducerCustomerId(), 1);
|
||||||
// 标签
|
// 标签
|
||||||
if (customer.getTagApply() != null) {
|
if (customer.getTagApply() != null) {
|
||||||
tagService.apply(TagApply.BizType.GAO_CUSTOMER, customer.getId(), customer.getTagApply().getTagIdList());
|
tagService.apply(TagApply.BizType.GAO_CUSTOMER, customer.getId(), customer.getTagApply().getTagIdList());
|
||||||
@@ -159,17 +157,18 @@ public class GaoCustomerServiceImplement extends AbstractEntityService<GaoCustom
|
|||||||
logger.setContent(jackson.writeValueAsString(customer));
|
logger.setContent(jackson.writeValueAsString(customer));
|
||||||
GaoCustomer dbCustomer = get(customer.getId());
|
GaoCustomer dbCustomer = get(customer.getId());
|
||||||
TimiException.requiredTrue(dbCustomer.getStoreId().equals(customer.getStoreId()), "customer.storeId invalid");
|
TimiException.requiredTrue(dbCustomer.getStoreId().equals(customer.getStoreId()), "customer.storeId invalid");
|
||||||
dbCustomer.setCode(TimiJava.defaultIfEmpty(customer.getCode(), null));
|
String code = TimiJava.defaultIfEmpty(customer.getCode(), null);
|
||||||
{
|
{
|
||||||
if (!Objects.equals(dbCustomer.getCode(), customer.getCode()) && TimiJava.isNotEmpty(customer.getCode())) {
|
if (!Objects.equals(dbCustomer.getCode(), code) && TimiJava.isNotEmpty(code)) {
|
||||||
GaoCustomer byCode = getByCode(customer.getStoreId(), customer.getCode());
|
GaoCustomer byCode = getByCode(customer.getStoreId(), code);
|
||||||
TimiException.requiredTrue(byCode == null || !byCode.getId().equals(dbCustomer.getId()), "该姓名客户已登记");
|
TimiException.requiredTrue(byCode == null || byCode.getId().equals(dbCustomer.getId()), "该编码客户已登记");
|
||||||
}
|
}
|
||||||
if (!Objects.equals(dbCustomer.getName(), customer.getName())) {
|
if (!Objects.equals(dbCustomer.getName(), customer.getName())) {
|
||||||
GaoCustomer byName = getByName(customer.getStoreId(), customer.getName());
|
GaoCustomer byName = getByName(customer.getStoreId(), customer.getName());
|
||||||
TimiException.requiredTrue(byName == null || !byName.getId().equals(dbCustomer.getId()), "该姓名客户已登记");
|
TimiException.requiredTrue(byName == null || !byName.getId().equals(dbCustomer.getId()), "该姓名客户已登记");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
dbCustomer.setCode(code);
|
||||||
dbCustomer.setName(customer.getName());
|
dbCustomer.setName(customer.getName());
|
||||||
fillPinyin(dbCustomer);
|
fillPinyin(dbCustomer);
|
||||||
dbCustomer.setGender(customer.getGender());
|
dbCustomer.setGender(customer.getGender());
|
||||||
@@ -369,10 +368,12 @@ public class GaoCustomerServiceImplement extends AbstractEntityService<GaoCustom
|
|||||||
try {
|
try {
|
||||||
logger.setContent(customerId);
|
logger.setContent(customerId);
|
||||||
GaoCustomer customer = get(customerId);
|
GaoCustomer customer = get(customerId);
|
||||||
|
TimiException.required(customer, "not found customer");
|
||||||
|
String oldIntroducerCustomerId = customer.getIntroducerCustomerId();
|
||||||
customer.setIntroducerCustomerId(null);
|
customer.setIntroducerCustomerId(null);
|
||||||
mapper.update(customer);
|
mapper.update(customer);
|
||||||
|
|
||||||
changeInvitedCount(customer.getIntroducerCustomerId(), -1);
|
changeInvitedCount(oldIntroducerCustomerId, -1);
|
||||||
logger.setLevel(Logger.Level.INFO);
|
logger.setLevel(Logger.Level.INFO);
|
||||||
logger.setResult(customerId);
|
logger.setResult(customerId);
|
||||||
} catch (TimiException e) {
|
} catch (TimiException e) {
|
||||||
@@ -434,9 +435,7 @@ public class GaoCustomerServiceImplement extends AbstractEntityService<GaoCustom
|
|||||||
if (TimiJava.isEmpty(customerId) || delta == 0) {
|
if (TimiJava.isEmpty(customerId) || delta == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GaoCustomer customer = get(customerId);
|
mapper.updateInvitedCountDelta(customerId, delta);
|
||||||
customer.setInvitedCount(customer.getInvitedCount() + delta);
|
|
||||||
mapper.update(customer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fillPinyin(GaoCustomer customer) {
|
private void fillPinyin(GaoCustomer customer) {
|
||||||
|
|||||||
+195
@@ -7,8 +7,13 @@ import com.imyeyu.api.modules.common.entity.Attachment;
|
|||||||
import com.imyeyu.api.modules.common.service.AttachmentService;
|
import com.imyeyu.api.modules.common.service.AttachmentService;
|
||||||
import com.imyeyu.api.modules.gao.entity.GaoCustomer;
|
import com.imyeyu.api.modules.gao.entity.GaoCustomer;
|
||||||
import com.imyeyu.api.modules.gao.entity.GaoEvent;
|
import com.imyeyu.api.modules.gao.entity.GaoEvent;
|
||||||
|
import com.imyeyu.api.modules.gao.entity.GaoEventOption;
|
||||||
|
import com.imyeyu.api.modules.gao.entity.GaoEventOptionGroup;
|
||||||
import com.imyeyu.api.modules.gao.entity.GaoEventRecord;
|
import com.imyeyu.api.modules.gao.entity.GaoEventRecord;
|
||||||
|
import com.imyeyu.api.modules.gao.entity.GaoEventRecordOption;
|
||||||
|
import com.imyeyu.api.modules.gao.entity.GaoEventRecordOptionGroup;
|
||||||
import com.imyeyu.api.modules.gao.mapper.GaoEventRecordMapper;
|
import com.imyeyu.api.modules.gao.mapper.GaoEventRecordMapper;
|
||||||
|
import com.imyeyu.api.modules.gao.mapper.GaoEventRecordOptionMapper;
|
||||||
import com.imyeyu.api.modules.gao.service.GaoCustomerService;
|
import com.imyeyu.api.modules.gao.service.GaoCustomerService;
|
||||||
import com.imyeyu.api.modules.gao.service.GaoEventRecordService;
|
import com.imyeyu.api.modules.gao.service.GaoEventRecordService;
|
||||||
import com.imyeyu.api.modules.gao.service.GaoEventService;
|
import com.imyeyu.api.modules.gao.service.GaoEventService;
|
||||||
@@ -16,6 +21,7 @@ import com.imyeyu.api.modules.gao.service.GaoPointTriggerService;
|
|||||||
import com.imyeyu.api.modules.gao.service.GaoStoreBusinessDayService;
|
import com.imyeyu.api.modules.gao.service.GaoStoreBusinessDayService;
|
||||||
import com.imyeyu.api.modules.gao.util.EventRecordXSSFBuilder;
|
import com.imyeyu.api.modules.gao.util.EventRecordXSSFBuilder;
|
||||||
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.GaoEventRecordRankPage;
|
import com.imyeyu.api.modules.gao.vo.GaoEventRecordRankPage;
|
||||||
import com.imyeyu.api.modules.system.entity.Logger;
|
import com.imyeyu.api.modules.system.entity.Logger;
|
||||||
@@ -43,7 +49,11 @@ import java.time.format.DateTimeFormatter;
|
|||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.time.temporal.TemporalAdjusters;
|
import java.time.temporal.TemporalAdjusters;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/// 登记事件记录服务实现
|
/// 登记事件记录服务实现
|
||||||
///
|
///
|
||||||
@@ -67,6 +77,7 @@ public class GaoEventRecordServiceImplement extends AbstractEntityService<GaoEve
|
|||||||
private final GaoStoreBusinessDayService businessDayService;
|
private final GaoStoreBusinessDayService businessDayService;
|
||||||
|
|
||||||
private final GaoEventRecordMapper mapper;
|
private final GaoEventRecordMapper mapper;
|
||||||
|
private final GaoEventRecordOptionMapper recordOptionMapper;
|
||||||
|
|
||||||
private final EventRecordXSSFBuilder xssfBuilder;
|
private final EventRecordXSSFBuilder xssfBuilder;
|
||||||
|
|
||||||
@@ -83,6 +94,69 @@ public class GaoEventRecordServiceImplement extends AbstractEntityService<GaoEve
|
|||||||
return mapper.selectAllByExample(example);
|
return mapper.selectAllByExample(example);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void attachSelectedOptionGroupList(List<GaoEventRecord> recordList) {
|
||||||
|
List<String> recordIdList = new ArrayList<>();
|
||||||
|
for (GaoEventRecord record : TimiJava.safeIterable(recordList)) {
|
||||||
|
if (record != null && TimiJava.isNotEmpty(record.getId())) {
|
||||||
|
recordIdList.add(record.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (recordIdList.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Map<String, GaoEventRecordOptionGroup>> groupMap = new LinkedHashMap<>();
|
||||||
|
for (GaoEventRecordOption relation : recordOptionMapper.selectAllByEventRecordIdList(recordIdList)) {
|
||||||
|
Map<String, GaoEventRecordOptionGroup> recordGroupMap = groupMap.computeIfAbsent(relation.getEventRecordId(), key -> new LinkedHashMap<>());
|
||||||
|
GaoEventRecordOptionGroup group = recordGroupMap.computeIfAbsent(relation.getGroupId(), key -> {
|
||||||
|
GaoEventRecordOptionGroup result = new GaoEventRecordOptionGroup();
|
||||||
|
result.setGroupId(relation.getGroupId());
|
||||||
|
result.setGroupName(relation.getGroupNameSnapshot());
|
||||||
|
result.setSelectedOptionList(new ArrayList<>());
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
GaoEventOption option = new GaoEventOption();
|
||||||
|
option.setId(relation.getOptionId());
|
||||||
|
option.setLabel(relation.getOptionLabelSnapshot());
|
||||||
|
option.setSort(relation.getOptionSort());
|
||||||
|
group.getSelectedOptionList().add(option);
|
||||||
|
}
|
||||||
|
for (GaoEventRecord record : TimiJava.safeIterable(recordList)) {
|
||||||
|
if (record != null) {
|
||||||
|
record.setSelectedOptionGroupList(new ArrayList<>(groupMap.getOrDefault(record.getId(), Map.of()).values()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||||
|
@Override
|
||||||
|
public void verify(String id) {
|
||||||
|
TimiException.required(id, "not found record.id");
|
||||||
|
Logger logger = new Logger(Logger.Module.GAO, "GAO_EVENT_RECORD_VERIFY");
|
||||||
|
try {
|
||||||
|
logger.setContent(id);
|
||||||
|
GaoEventRecord record = get(id);
|
||||||
|
TimiException.required(record, "not found event record");
|
||||||
|
TimiException.requiredTrue(record.getVerificationStatus() == GaoEventRecord.VerificationStatus.PENDING, "登记记录无需核销或已核销");
|
||||||
|
int updated = mapper.verify(id, userLoginService.getRequireLoginUserId(), Time.now());
|
||||||
|
TimiException.requiredTrue(0 < updated, "登记记录无需核销或已核销");
|
||||||
|
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("核销 GAO 登记记录失败", e);
|
||||||
|
throw new TimiException(TimiCode.ERROR, "核销 GAO 登记记录失败", e);
|
||||||
|
} finally {
|
||||||
|
loggerService.create(logger);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||||
@Override
|
@Override
|
||||||
public void create(GaoEventRecord record) {
|
public void create(GaoEventRecord record) {
|
||||||
@@ -97,7 +171,10 @@ public class GaoEventRecordServiceImplement extends AbstractEntityService<GaoEve
|
|||||||
GaoEvent event = eventService.get(record.getEventId());
|
GaoEvent event = eventService.get(record.getEventId());
|
||||||
TimiException.required(event, "not found event");
|
TimiException.required(event, "not found event");
|
||||||
TimiException.required(event.getStoreId(), "not found event.storeId");
|
TimiException.required(event.getStoreId(), "not found event.storeId");
|
||||||
|
eventService.attachOptionGroupList(List.of(event));
|
||||||
|
List<GaoEventRecordOption> canonicalOptionList = resolveRecordOptionList(event, record.getSelectedOptionGroupList());
|
||||||
verifyRecordValue(event, record.getNumberValue());
|
verifyRecordValue(event, record.getNumberValue());
|
||||||
|
verifyRecordAttachment(event, record.getAttachmentList());
|
||||||
// 检查权限
|
// 检查权限
|
||||||
checkEventPermission(event);
|
checkEventPermission(event);
|
||||||
int registeredDateValue = dateValue(registeredAt);
|
int registeredDateValue = dateValue(registeredAt);
|
||||||
@@ -130,8 +207,12 @@ public class GaoEventRecordServiceImplement extends AbstractEntityService<GaoEve
|
|||||||
dbRecord.setBusinessDayNo(businessDayNo);
|
dbRecord.setBusinessDayNo(businessDayNo);
|
||||||
dbRecord.setPointValue(record.getPointValue());
|
dbRecord.setPointValue(record.getPointValue());
|
||||||
dbRecord.setNumberValue(record.getNumberValue());
|
dbRecord.setNumberValue(record.getNumberValue());
|
||||||
|
dbRecord.setVerificationStatus(Boolean.TRUE.equals(event.getRequireVerification())
|
||||||
|
? GaoEventRecord.VerificationStatus.PENDING
|
||||||
|
: GaoEventRecord.VerificationStatus.NOT_REQUIRED);
|
||||||
dbRecord.setEarnedPointValue(0L);
|
dbRecord.setEarnedPointValue(0L);
|
||||||
super.create(dbRecord);
|
super.create(dbRecord);
|
||||||
|
saveRecordOptionList(dbRecord.getId(), canonicalOptionList);
|
||||||
// 附件
|
// 附件
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
// 第一个记录储存附件
|
// 第一个记录储存附件
|
||||||
@@ -168,11 +249,25 @@ public class GaoEventRecordServiceImplement extends AbstractEntityService<GaoEve
|
|||||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||||
@Override
|
@Override
|
||||||
public void createBatch(List<GaoEventRecord> recordList) {
|
public void createBatch(List<GaoEventRecord> recordList) {
|
||||||
|
Set<String> usedTempFileIdSet = new HashSet<>();
|
||||||
for (GaoEventRecord record : TimiJava.safeIterable(recordList)) {
|
for (GaoEventRecord record : TimiJava.safeIterable(recordList)) {
|
||||||
|
TimiException.required(record, "not found record");
|
||||||
|
prepareBatchAttachments(record, usedTempFileIdSet);
|
||||||
create(record);
|
create(record);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void prepareBatchAttachments(GaoEventRecord record, Set<String> usedTempFileIdSet) {
|
||||||
|
for (Attachment attachment : TimiJava.safeIterable(record.getAttachmentList())) {
|
||||||
|
if (attachment == null || TimiJava.isEmpty(attachment.getTempFileId()) || usedTempFileIdSet.add(attachment.getTempFileId())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Attachment clone = attachmentService.clone(attachment.getTempFileId());
|
||||||
|
TimiException.required(clone.getId(), "登记照片临时附件复制失败");
|
||||||
|
attachment.setTempFileId(clone.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||||
@Override
|
@Override
|
||||||
public void update(GaoEventRecord record) {
|
public void update(GaoEventRecord record) {
|
||||||
@@ -190,9 +285,21 @@ public class GaoEventRecordServiceImplement extends AbstractEntityService<GaoEve
|
|||||||
GaoEvent event = eventService.get(dbRecord.getEventId());
|
GaoEvent event = eventService.get(dbRecord.getEventId());
|
||||||
TimiException.required(event, "not found event");
|
TimiException.required(event, "not found event");
|
||||||
TimiException.required(event.getStoreId(), "not found event.storeId");
|
TimiException.required(event.getStoreId(), "not found event.storeId");
|
||||||
|
List<GaoEventRecordOption> canonicalOptionList = null;
|
||||||
|
if (record.getSelectedOptionGroupList() != null) {
|
||||||
|
eventService.attachOptionGroupList(List.of(event));
|
||||||
|
canonicalOptionList = resolveRecordOptionList(event, record.getSelectedOptionGroupList());
|
||||||
|
}
|
||||||
|
verifyRecordAttachment(event, record.getAttachmentList());
|
||||||
checkEventPermission(event);
|
checkEventPermission(event);
|
||||||
dbRecord.setRemark(record.getRemark());
|
dbRecord.setRemark(record.getRemark());
|
||||||
super.update(dbRecord);
|
super.update(dbRecord);
|
||||||
|
if (canonicalOptionList != null) {
|
||||||
|
GaoEventRecordOption optionExample = new GaoEventRecordOption();
|
||||||
|
optionExample.setEventRecordId(record.getId());
|
||||||
|
recordOptionMapper.deleteAllByExample(optionExample);
|
||||||
|
saveRecordOptionList(record.getId(), canonicalOptionList);
|
||||||
|
}
|
||||||
attachmentService.updateByBizId(Attachment.BizType.GAO_EVENT_RECORD, record.getId(), record.getAttachmentList());
|
attachmentService.updateByBizId(Attachment.BizType.GAO_EVENT_RECORD, record.getId(), record.getAttachmentList());
|
||||||
logger.setLevel(Logger.Level.INFO);
|
logger.setLevel(Logger.Level.INFO);
|
||||||
logger.setResult(record.getId());
|
logger.setResult(record.getId());
|
||||||
@@ -220,6 +327,9 @@ public class GaoEventRecordServiceImplement extends AbstractEntityService<GaoEve
|
|||||||
GaoEventRecord record = get(id);
|
GaoEventRecord record = get(id);
|
||||||
TimiException.required(record, "not found event record");
|
TimiException.required(record, "not found event record");
|
||||||
pointTriggerService.revokeByEventRecord(record);
|
pointTriggerService.revokeByEventRecord(record);
|
||||||
|
GaoEventRecordOption optionExample = new GaoEventRecordOption();
|
||||||
|
optionExample.setEventRecordId(record.getId());
|
||||||
|
recordOptionMapper.deleteAllByExample(optionExample);
|
||||||
attachmentService.deleteByBizId(Attachment.BizType.GAO_EVENT_RECORD, record.getId());
|
attachmentService.deleteByBizId(Attachment.BizType.GAO_EVENT_RECORD, record.getId());
|
||||||
super.delete(id);
|
super.delete(id);
|
||||||
logger.setLevel(Logger.Level.INFO);
|
logger.setLevel(Logger.Level.INFO);
|
||||||
@@ -281,6 +391,12 @@ public class GaoEventRecordServiceImplement extends AbstractEntityService<GaoEve
|
|||||||
return mapper.sumNumberValueByRange(page);
|
return mapper.sumNumberValueByRange(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<GaoEventOptionStatView> optionStatByRange(GaoEventRecordPage page) {
|
||||||
|
TimiException.required(page.getStoreId(), "not found page.storeId");
|
||||||
|
return mapper.selectOptionStatByRange(page);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] export(GaoEventRecordPage page) throws IOException {
|
public byte[] export(GaoEventRecordPage page) throws IOException {
|
||||||
TimiException.required(page.getStoreId(), "not found page.storeId");
|
TimiException.required(page.getStoreId(), "not found page.storeId");
|
||||||
@@ -383,6 +499,85 @@ public class GaoEventRecordServiceImplement extends AbstractEntityService<GaoEve
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<GaoEventRecordOption> resolveRecordOptionList(GaoEvent event, List<GaoEventRecordOptionGroup> selectedGroupList) {
|
||||||
|
List<GaoEventOptionGroup> groupList = event.getOptionGroupList();
|
||||||
|
Map<String, GaoEventOptionGroup> groupMap = new LinkedHashMap<>();
|
||||||
|
for (GaoEventOptionGroup group : TimiJava.safeIterable(groupList)) {
|
||||||
|
groupMap.put(group.getId(), group);
|
||||||
|
}
|
||||||
|
Map<String, GaoEventRecordOptionGroup> selectedMap = new LinkedHashMap<>();
|
||||||
|
for (GaoEventRecordOptionGroup selectedGroup : TimiJava.safeIterable(selectedGroupList)) {
|
||||||
|
TimiException.required(selectedGroup, "登记记录选项组不能为空");
|
||||||
|
String groupId = selectedGroup.getGroupId();
|
||||||
|
GaoEventOptionGroup group = groupMap.get(groupId);
|
||||||
|
TimiException.required(group, "登记记录选项组不存在或不属于当前事件");
|
||||||
|
TimiException.requiredTrue(selectedMap.put(groupId, selectedGroup) == null, "登记记录选项组不能重复");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<GaoEventRecordOption> result = new ArrayList<>();
|
||||||
|
for (GaoEventOptionGroup group : TimiJava.safeIterable(groupList)) {
|
||||||
|
GaoEventRecordOptionGroup selectedGroup = selectedMap.get(group.getId());
|
||||||
|
List<GaoEventOption> selectedOptionList = selectedGroup == null ? List.of() : TimiJava.defaultIfNull(selectedGroup.getSelectedOptionList(), List.of());
|
||||||
|
if (Boolean.TRUE.equals(group.getRequired())) {
|
||||||
|
TimiException.requiredTrue(!selectedOptionList.isEmpty(), "请至少选择%s中的一个选项".formatted(group.getName()));
|
||||||
|
}
|
||||||
|
if (group.getSelectionMode() == GaoEventOptionGroup.SelectionMode.SINGLE) {
|
||||||
|
TimiException.requiredTrue(selectedOptionList.size() < 2, "%s只能选择一个选项".formatted(group.getName()));
|
||||||
|
}
|
||||||
|
Map<String, GaoEventOption> optionMap = new LinkedHashMap<>();
|
||||||
|
for (GaoEventOption option : TimiJava.safeIterable(group.getOptionList())) {
|
||||||
|
optionMap.put(option.getId(), option);
|
||||||
|
}
|
||||||
|
Set<String> selectedOptionIdSet = new HashSet<>();
|
||||||
|
int optionSort = 0;
|
||||||
|
int groupSort = groupList.indexOf(group);
|
||||||
|
for (GaoEventOption selectedOption : selectedOptionList) {
|
||||||
|
TimiException.required(selectedOption, "登记记录选项不能为空");
|
||||||
|
GaoEventOption option = optionMap.get(selectedOption.getId());
|
||||||
|
TimiException.required(option, "登记记录选项不存在或不属于当前选项组");
|
||||||
|
TimiException.requiredTrue(selectedOptionIdSet.add(option.getId()), "登记记录选项不能重复");
|
||||||
|
GaoEventRecordOption recordOption = new GaoEventRecordOption();
|
||||||
|
recordOption.setGroupId(group.getId());
|
||||||
|
recordOption.setOptionId(option.getId());
|
||||||
|
recordOption.setGroupSort(groupSort);
|
||||||
|
recordOption.setOptionSort(option.getSort() == null ? optionSort : option.getSort());
|
||||||
|
recordOption.setGroupNameSnapshot(group.getName());
|
||||||
|
recordOption.setOptionLabelSnapshot(option.getLabel());
|
||||||
|
result.add(recordOption);
|
||||||
|
optionSort++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveRecordOptionList(String eventRecordId, List<GaoEventRecordOption> optionList) {
|
||||||
|
for (GaoEventRecordOption option : TimiJava.safeIterable(optionList)) {
|
||||||
|
GaoEventRecordOption recordOption = new GaoEventRecordOption();
|
||||||
|
recordOption.setEventRecordId(eventRecordId);
|
||||||
|
recordOption.setGroupId(option.getGroupId());
|
||||||
|
recordOption.setOptionId(option.getOptionId());
|
||||||
|
recordOption.setGroupSort(option.getGroupSort());
|
||||||
|
recordOption.setOptionSort(option.getOptionSort());
|
||||||
|
recordOption.setGroupNameSnapshot(option.getGroupNameSnapshot());
|
||||||
|
recordOption.setOptionLabelSnapshot(option.getOptionLabelSnapshot());
|
||||||
|
recordOptionMapper.insert(recordOption);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void verifyRecordAttachment(GaoEvent event, List<Attachment> attachmentList) {
|
||||||
|
if (!Boolean.TRUE.equals(event.getRequirePhoto())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
boolean hasPhoto = false;
|
||||||
|
for (Attachment attachment : TimiJava.safeIterable(attachmentList)) {
|
||||||
|
if (attachment != null && (attachment.getAttachType() == null || GaoEventRecord.AttachType.PHOTO.name().equalsIgnoreCase(attachment.getAttachType()))) {
|
||||||
|
hasPhoto = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TimiException.requiredTrue(hasPhoto, "该事件必须上传照片");
|
||||||
|
}
|
||||||
|
|
||||||
private void verifyImmutableRecordFields(GaoEventRecord request, GaoEventRecord dbRecord) {
|
private void verifyImmutableRecordFields(GaoEventRecord request, GaoEventRecord dbRecord) {
|
||||||
TimiException.requiredTrue(request.getCustomerId() == null || request.getCustomerId().equals(dbRecord.getCustomerId()), "登记记录 customerId 创建后不可修改");
|
TimiException.requiredTrue(request.getCustomerId() == null || request.getCustomerId().equals(dbRecord.getCustomerId()), "登记记录 customerId 创建后不可修改");
|
||||||
TimiException.requiredTrue(request.getEventId() == null || request.getEventId().equals(dbRecord.getEventId()), "登记记录 eventId 创建后不可修改");
|
TimiException.requiredTrue(request.getEventId() == null || request.getEventId().equals(dbRecord.getEventId()), "登记记录 eventId 创建后不可修改");
|
||||||
|
|||||||
+172
-1
@@ -3,8 +3,12 @@ package com.imyeyu.api.modules.gao.service.implement;
|
|||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.imyeyu.api.config.dbsource.TimiServerDBConfig;
|
import com.imyeyu.api.config.dbsource.TimiServerDBConfig;
|
||||||
import com.imyeyu.api.modules.gao.entity.GaoEvent;
|
import com.imyeyu.api.modules.gao.entity.GaoEvent;
|
||||||
|
import com.imyeyu.api.modules.gao.entity.GaoEventOption;
|
||||||
|
import com.imyeyu.api.modules.gao.entity.GaoEventOptionGroup;
|
||||||
import com.imyeyu.api.modules.gao.entity.GaoEventRoleRelation;
|
import com.imyeyu.api.modules.gao.entity.GaoEventRoleRelation;
|
||||||
import com.imyeyu.api.modules.gao.mapper.GaoEventMapper;
|
import com.imyeyu.api.modules.gao.mapper.GaoEventMapper;
|
||||||
|
import com.imyeyu.api.modules.gao.mapper.GaoEventOptionGroupMapper;
|
||||||
|
import com.imyeyu.api.modules.gao.mapper.GaoEventOptionMapper;
|
||||||
import com.imyeyu.api.modules.gao.mapper.GaoEventRecordMapper;
|
import com.imyeyu.api.modules.gao.mapper.GaoEventRecordMapper;
|
||||||
import com.imyeyu.api.modules.gao.mapper.GaoEventRoleRelationMapper;
|
import com.imyeyu.api.modules.gao.mapper.GaoEventRoleRelationMapper;
|
||||||
import com.imyeyu.api.modules.gao.service.GaoEventService;
|
import com.imyeyu.api.modules.gao.service.GaoEventService;
|
||||||
@@ -23,6 +27,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -46,6 +51,8 @@ public class GaoEventServiceImplement extends AbstractEntityService<GaoEvent, St
|
|||||||
private final LoggerService loggerService;
|
private final LoggerService loggerService;
|
||||||
|
|
||||||
private final GaoEventMapper mapper;
|
private final GaoEventMapper mapper;
|
||||||
|
private final GaoEventOptionGroupMapper optionGroupMapper;
|
||||||
|
private final GaoEventOptionMapper optionMapper;
|
||||||
private final GaoEventRecordMapper eventRecordMapper;
|
private final GaoEventRecordMapper eventRecordMapper;
|
||||||
private final GaoEventRoleRelationMapper roleRelationMapper;
|
private final GaoEventRoleRelationMapper roleRelationMapper;
|
||||||
|
|
||||||
@@ -69,12 +76,14 @@ public class GaoEventServiceImplement extends AbstractEntityService<GaoEvent, St
|
|||||||
event.setValueType(TimiJava.defaultIfNull(event.getValueType(), GaoEvent.ValueType.NONE));
|
event.setValueType(TimiJava.defaultIfNull(event.getValueType(), GaoEvent.ValueType.NONE));
|
||||||
event.setRequireValue(TimiJava.defaultIfNull(event.getRequireValue(), false));
|
event.setRequireValue(TimiJava.defaultIfNull(event.getRequireValue(), false));
|
||||||
event.setRequirePhoto(TimiJava.defaultIfNull(event.getRequirePhoto(), false));
|
event.setRequirePhoto(TimiJava.defaultIfNull(event.getRequirePhoto(), false));
|
||||||
|
event.setRequireVerification(TimiJava.defaultIfNull(event.getRequireVerification(), false));
|
||||||
event.setLimitType(TimiJava.defaultIfNull(event.getLimitType(), GaoEvent.LimitType.NONE));
|
event.setLimitType(TimiJava.defaultIfNull(event.getLimitType(), GaoEvent.LimitType.NONE));
|
||||||
event.setSort(TimiJava.defaultIfNull(event.getSort(), 0));
|
event.setSort(TimiJava.defaultIfNull(event.getSort(), 0));
|
||||||
verifyEvent(event);
|
verifyEvent(event);
|
||||||
super.create(event);
|
super.create(event);
|
||||||
|
|
||||||
saveRoleRelation(event.getId(), event.getRoleCodeList());
|
saveRoleRelation(event.getId(), event.getRoleCodeList());
|
||||||
|
saveOptionGroupList(event.getId(), event.getOptionGroupList());
|
||||||
logger.setLevel(Logger.Level.INFO);
|
logger.setLevel(Logger.Level.INFO);
|
||||||
logger.setResult(event.getId());
|
logger.setResult(event.getId());
|
||||||
} catch (TimiException e) {
|
} catch (TimiException e) {
|
||||||
@@ -122,15 +131,22 @@ public class GaoEventServiceImplement extends AbstractEntityService<GaoEvent, St
|
|||||||
dbEvent.setRequireValue(dbEvent.getRequireValue());
|
dbEvent.setRequireValue(dbEvent.getRequireValue());
|
||||||
}
|
}
|
||||||
dbEvent.setRequirePhoto(event.getRequirePhoto());
|
dbEvent.setRequirePhoto(event.getRequirePhoto());
|
||||||
|
dbEvent.setRequireVerification(TimiJava.defaultIfNull(event.getRequireVerification(), dbEvent.getRequireVerification()));
|
||||||
dbEvent.setLimitType(event.getLimitType());
|
dbEvent.setLimitType(event.getLimitType());
|
||||||
dbEvent.setLimitValue(event.getLimitValue());
|
dbEvent.setLimitValue(event.getLimitValue());
|
||||||
dbEvent.setBeginAt(event.getBeginAt());
|
dbEvent.setBeginAt(event.getBeginAt());
|
||||||
dbEvent.setEndAt(event.getEndAt());
|
dbEvent.setEndAt(event.getEndAt());
|
||||||
|
|
||||||
|
if (event.getOptionGroupList() != null) {
|
||||||
|
verifyOptionGroupList(event.getOptionGroupList());
|
||||||
|
}
|
||||||
verifyValueDefinitionChange(dbEvent, oldValueType, oldValueUnit);
|
verifyValueDefinitionChange(dbEvent, oldValueType, oldValueUnit);
|
||||||
verifyEvent(dbEvent);
|
verifyEvent(dbEvent);
|
||||||
mapper.update(dbEvent);
|
mapper.update(dbEvent);
|
||||||
saveRoleRelation(event.getId(), event.getRoleCodeList());
|
saveRoleRelation(event.getId(), event.getRoleCodeList());
|
||||||
|
if (event.getOptionGroupList() != null) {
|
||||||
|
saveOptionGroupList(event.getId(), event.getOptionGroupList());
|
||||||
|
}
|
||||||
logger.setLevel(Logger.Level.INFO);
|
logger.setLevel(Logger.Level.INFO);
|
||||||
logger.setResult(event.getId());
|
logger.setResult(event.getId());
|
||||||
} catch (TimiException e) {
|
} catch (TimiException e) {
|
||||||
@@ -147,6 +163,32 @@ public class GaoEventServiceImplement extends AbstractEntityService<GaoEvent, St
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||||
|
@Override
|
||||||
|
public void updateOptionGroupList(String eventId, List<GaoEventOptionGroup> optionGroupList) {
|
||||||
|
Logger logger = new Logger(Logger.Module.GAO, "GAO_EVENT_OPTION_UPDATE");
|
||||||
|
try {
|
||||||
|
logger.setContent(jackson.writeValueAsString(optionGroupList));
|
||||||
|
GaoEvent event = get(eventId);
|
||||||
|
TimiException.required(event, "not found event");
|
||||||
|
verifyOptionGroupList(optionGroupList);
|
||||||
|
saveOptionGroupList(eventId, optionGroupList);
|
||||||
|
logger.setLevel(Logger.Level.INFO);
|
||||||
|
logger.setResult(eventId);
|
||||||
|
} 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 event option error", e);
|
||||||
|
throw new TimiException(TimiCode.ERROR, "update event option error", e);
|
||||||
|
} finally {
|
||||||
|
loggerService.create(logger);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||||
@Override
|
@Override
|
||||||
public void delete(String id) {
|
public void delete(String id) {
|
||||||
@@ -201,7 +243,36 @@ public class GaoEventServiceImplement extends AbstractEntityService<GaoEvent, St
|
|||||||
@Override
|
@Override
|
||||||
public List<GaoEvent> listValid(String storeId) {
|
public List<GaoEvent> listValid(String storeId) {
|
||||||
TimiException.required(storeId, "not found storeId");
|
TimiException.required(storeId, "not found storeId");
|
||||||
return mapper.selectValidList(storeId, Time.now());
|
List<GaoEvent> eventList = mapper.selectValidList(storeId, Time.now());
|
||||||
|
attachOptionGroupList(eventList);
|
||||||
|
return eventList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void attachOptionGroupList(Collection<GaoEvent> eventList) {
|
||||||
|
List<GaoEvent> validEventList = new ArrayList<>();
|
||||||
|
for (GaoEvent event : TimiJava.safeIterable(eventList)) {
|
||||||
|
if (event != null && TimiJava.isNotEmpty(event.getId())) {
|
||||||
|
validEventList.add(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (validEventList.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> eventIdList = validEventList.stream().map(GaoEvent::getId).toList();
|
||||||
|
List<GaoEventOptionGroup> groupList = optionGroupMapper.selectAllByEventIdList(eventIdList);
|
||||||
|
List<String> groupIdList = groupList.stream().map(GaoEventOptionGroup::getId).filter(TimiJava::isNotEmpty).toList();
|
||||||
|
List<GaoEventOption> optionList = optionMapper.selectAllByGroupIdList(groupIdList);
|
||||||
|
Map<String, List<GaoEventOption>> optionMap = optionList.stream().collect(Collectors.groupingBy(GaoEventOption::getGroupId));
|
||||||
|
Map<String, List<GaoEventOptionGroup>> groupMap = new HashMap<>();
|
||||||
|
for (GaoEventOptionGroup group : groupList) {
|
||||||
|
group.setOptionList(optionMap.getOrDefault(group.getId(), List.of()));
|
||||||
|
groupMap.computeIfAbsent(group.getEventId(), key -> new ArrayList<>()).add(group);
|
||||||
|
}
|
||||||
|
for (GaoEvent event : validEventList) {
|
||||||
|
event.setOptionGroupList(groupMap.getOrDefault(event.getId(), List.of()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -240,6 +311,106 @@ public class GaoEventServiceImplement extends AbstractEntityService<GaoEvent, St
|
|||||||
if (event.getBeginAt() != null || event.getEndAt() != null) {
|
if (event.getBeginAt() != null || event.getEndAt() != null) {
|
||||||
TimiException.requiredTrue(event.getBeginAt() == null || event.getEndAt() == null || event.getBeginAt() <= event.getEndAt(), "invalid beginAt or endAt");
|
TimiException.requiredTrue(event.getBeginAt() == null || event.getEndAt() == null || event.getBeginAt() <= event.getEndAt(), "invalid beginAt or endAt");
|
||||||
}
|
}
|
||||||
|
verifyOptionGroupList(event.getOptionGroupList());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void verifyOptionGroupList(List<GaoEventOptionGroup> groupList) {
|
||||||
|
Set<String> groupIdSet = new HashSet<>();
|
||||||
|
Set<String> groupNameSet = new HashSet<>();
|
||||||
|
for (GaoEventOptionGroup group : TimiJava.safeIterable(groupList)) {
|
||||||
|
TimiException.required(group, "登记事件选项组不能为空");
|
||||||
|
String groupName = group.getName() == null ? "" : group.getName().trim();
|
||||||
|
TimiException.requiredTrue(!groupName.isEmpty(), "登记事件选项组名称不能为空");
|
||||||
|
TimiException.requiredTrue(groupNameSet.add(groupName), "登记事件选项组名称不能重复");
|
||||||
|
if (TimiJava.isNotEmpty(group.getId())) {
|
||||||
|
TimiException.requiredTrue(groupIdSet.add(group.getId()), "登记事件选项组 ID 不能重复");
|
||||||
|
}
|
||||||
|
TimiException.required(group.getSelectionMode(), "登记事件选项组必须配置选择模式");
|
||||||
|
List<GaoEventOption> optionList = group.getOptionList();
|
||||||
|
TimiException.requiredTrue(optionList != null && !optionList.isEmpty(), "登记事件选项组至少配置一个选项");
|
||||||
|
Set<String> optionIdSet = new HashSet<>();
|
||||||
|
Set<String> optionNameSet = new HashSet<>();
|
||||||
|
for (GaoEventOption option : TimiJava.safeIterable(optionList)) {
|
||||||
|
TimiException.required(option, "登记事件选项不能为空");
|
||||||
|
String label = option.getLabel() == null ? "" : option.getLabel().trim();
|
||||||
|
TimiException.requiredTrue(!label.isEmpty(), "登记事件选项名称不能为空");
|
||||||
|
TimiException.requiredTrue(optionNameSet.add(label), "同一选项组内选项名称不能重复");
|
||||||
|
if (TimiJava.isNotEmpty(option.getId())) {
|
||||||
|
TimiException.requiredTrue(optionIdSet.add(option.getId()), "登记事件选项 ID 不能重复");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveOptionGroupList(String eventId, List<GaoEventOptionGroup> groupList) {
|
||||||
|
List<GaoEventOptionGroup> dbGroupList = optionGroupMapper.selectAllByEventIdList(List.of(eventId));
|
||||||
|
Map<String, GaoEventOptionGroup> dbGroupMap = dbGroupList.stream().collect(Collectors.toMap(GaoEventOptionGroup::getId, Function.identity()));
|
||||||
|
Set<String> retainedGroupIdSet = new HashSet<>();
|
||||||
|
int groupSort = 0;
|
||||||
|
for (GaoEventOptionGroup group : TimiJava.safeIterable(groupList)) {
|
||||||
|
String groupId = group.getId();
|
||||||
|
GaoEventOptionGroup dbGroup;
|
||||||
|
if (TimiJava.isNotEmpty(groupId)) {
|
||||||
|
dbGroup = dbGroupMap.get(groupId);
|
||||||
|
TimiException.required(dbGroup, "登记事件选项组不属于当前事件");
|
||||||
|
dbGroup.setName(group.getName().trim());
|
||||||
|
dbGroup.setSelectionMode(group.getSelectionMode());
|
||||||
|
dbGroup.setRequired(TimiJava.defaultIfNull(group.getRequired(), false));
|
||||||
|
dbGroup.setSort(groupSort);
|
||||||
|
optionGroupMapper.update(dbGroup);
|
||||||
|
} else {
|
||||||
|
dbGroup = group;
|
||||||
|
dbGroup.setEventId(eventId);
|
||||||
|
dbGroup.setName(group.getName().trim());
|
||||||
|
dbGroup.setRequired(TimiJava.defaultIfNull(group.getRequired(), false));
|
||||||
|
dbGroup.setSort(groupSort);
|
||||||
|
optionGroupMapper.insert(dbGroup);
|
||||||
|
}
|
||||||
|
groupId = dbGroup.getId();
|
||||||
|
retainedGroupIdSet.add(groupId);
|
||||||
|
saveOptionList(groupId, group.getOptionList());
|
||||||
|
groupSort++;
|
||||||
|
}
|
||||||
|
for (GaoEventOptionGroup dbGroup : dbGroupList) {
|
||||||
|
if (retainedGroupIdSet.contains(dbGroup.getId())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
GaoEventOption optionExample = new GaoEventOption();
|
||||||
|
optionExample.setGroupId(dbGroup.getId());
|
||||||
|
optionMapper.deleteAllByExample(optionExample);
|
||||||
|
optionGroupMapper.delete(dbGroup.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveOptionList(String groupId, List<GaoEventOption> optionList) {
|
||||||
|
List<GaoEventOption> dbOptionList = optionMapper.selectAllByGroupIdList(List.of(groupId));
|
||||||
|
Map<String, GaoEventOption> dbOptionMap = dbOptionList.stream().collect(Collectors.toMap(GaoEventOption::getId, Function.identity()));
|
||||||
|
Set<String> retainedOptionIdSet = new HashSet<>();
|
||||||
|
int optionSort = 0;
|
||||||
|
for (GaoEventOption option : TimiJava.safeIterable(optionList)) {
|
||||||
|
String optionId = option.getId();
|
||||||
|
GaoEventOption dbOption;
|
||||||
|
if (TimiJava.isNotEmpty(optionId)) {
|
||||||
|
dbOption = dbOptionMap.get(optionId);
|
||||||
|
TimiException.required(dbOption, "登记事件选项不属于当前选项组");
|
||||||
|
dbOption.setLabel(option.getLabel().trim());
|
||||||
|
dbOption.setSort(optionSort);
|
||||||
|
optionMapper.update(dbOption);
|
||||||
|
} else {
|
||||||
|
dbOption = option;
|
||||||
|
dbOption.setGroupId(groupId);
|
||||||
|
dbOption.setLabel(option.getLabel().trim());
|
||||||
|
dbOption.setSort(optionSort);
|
||||||
|
optionMapper.insert(dbOption);
|
||||||
|
}
|
||||||
|
retainedOptionIdSet.add(dbOption.getId());
|
||||||
|
optionSort++;
|
||||||
|
}
|
||||||
|
for (GaoEventOption dbOption : dbOptionList) {
|
||||||
|
if (!retainedOptionIdSet.contains(dbOption.getId())) {
|
||||||
|
optionMapper.delete(dbOption.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyValueDefinitionChange(GaoEvent event, GaoEvent.ValueType oldValueType, GaoEvent.ValueUnit oldValueUnit) {
|
private void verifyValueDefinitionChange(GaoEvent event, GaoEvent.ValueType oldValueType, GaoEvent.ValueUnit oldValueUnit) {
|
||||||
|
|||||||
+58
@@ -0,0 +1,58 @@
|
|||||||
|
package com.imyeyu.api.modules.gao.service.implement;
|
||||||
|
|
||||||
|
import com.imyeyu.api.bean.CoreRoleCode;
|
||||||
|
import com.imyeyu.api.bean.ModuleCode;
|
||||||
|
import com.imyeyu.api.modules.gao.bean.GaoRoleCode;
|
||||||
|
import com.imyeyu.api.modules.gao.entity.GaoStore;
|
||||||
|
import com.imyeyu.api.modules.gao.service.GaoStoreScopeService;
|
||||||
|
import com.imyeyu.api.modules.gao.service.GaoStoreService;
|
||||||
|
import com.imyeyu.api.modules.user.service.RoleChecker;
|
||||||
|
import com.imyeyu.java.TimiJava;
|
||||||
|
import com.imyeyu.java.bean.timi.TimiException;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/// GAO 门店资源范围服务实现
|
||||||
|
///
|
||||||
|
/// @author Codex
|
||||||
|
/// @since 2026-08-23
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class GaoStoreScopeServiceImplement implements GaoStoreScopeService {
|
||||||
|
|
||||||
|
private final RoleChecker roleChecker;
|
||||||
|
private final GaoStoreService gaoStoreService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasGlobalScope() {
|
||||||
|
return roleChecker.hasAny(ModuleCode.CORE, CoreRoleCode.SYSTEM.name(), CoreRoleCode.ADMIN.name())
|
||||||
|
|| roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String resolveStoreId(String requestedStoreId) {
|
||||||
|
if (hasGlobalScope()) {
|
||||||
|
return requestedStoreId;
|
||||||
|
}
|
||||||
|
String currentStoreId = gaoStoreService.getBelongIdByRequiredLoginUserId();
|
||||||
|
if (TimiJava.isNotEmpty(requestedStoreId)) {
|
||||||
|
TimiException.requiredTrue(currentStoreId.equals(requestedStoreId), "无权操作其他门店");
|
||||||
|
}
|
||||||
|
return currentStoreId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void checkStoreId(String storeId) {
|
||||||
|
TimiException.required(storeId, "not found storeId");
|
||||||
|
if (!hasGlobalScope()) {
|
||||||
|
String currentStoreId = gaoStoreService.getBelongIdByRequiredLoginUserId();
|
||||||
|
TimiException.requiredTrue(currentStoreId.equals(storeId), "无权操作其他门店");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void checkStore(GaoStore store) {
|
||||||
|
TimiException.required(store, "not found store");
|
||||||
|
checkStoreId(store.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
+3
-2
@@ -25,6 +25,7 @@ import com.imyeyu.spring.mapper.BaseMapper;
|
|||||||
import com.imyeyu.spring.service.AbstractEntityService;
|
import com.imyeyu.spring.service.AbstractEntityService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.ObjectProvider;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@@ -54,7 +55,7 @@ public class GaoStoreServiceImplement extends AbstractEntityService<GaoStore, St
|
|||||||
private final GaoPointAccountService pointAccountService;
|
private final GaoPointAccountService pointAccountService;
|
||||||
private final GaoPointRuleService pointRuleService;
|
private final GaoPointRuleService pointRuleService;
|
||||||
private final GaoStoreBusinessDayService businessDayService;
|
private final GaoStoreBusinessDayService businessDayService;
|
||||||
private final GaoUserService gaoUserService;
|
private final ObjectProvider<GaoUserService> gaoUserServiceProvider;
|
||||||
private final TagService tagService;
|
private final TagService tagService;
|
||||||
|
|
||||||
private final GaoStoreMapper mapper;
|
private final GaoStoreMapper mapper;
|
||||||
@@ -190,7 +191,7 @@ public class GaoStoreServiceImplement extends AbstractEntityService<GaoStore, St
|
|||||||
///
|
///
|
||||||
/// @param storeId 门店 ID
|
/// @param storeId 门店 ID
|
||||||
private void deleteGaoUsers(String storeId) {
|
private void deleteGaoUsers(String storeId) {
|
||||||
gaoUserService.deleteByStoreId(storeId);
|
gaoUserServiceProvider.getObject().deleteByStoreId(storeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 清理门店下未被客户删除逻辑覆盖的积分账户
|
/// 清理门店下未被客户删除逻辑覆盖的积分账户
|
||||||
|
|||||||
+24
@@ -13,12 +13,19 @@ 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;
|
||||||
import com.imyeyu.spring.mapper.BaseMapper;
|
import com.imyeyu.spring.mapper.BaseMapper;
|
||||||
|
import com.imyeyu.spring.bean.Page;
|
||||||
|
import com.imyeyu.spring.bean.PageResult;
|
||||||
import com.imyeyu.spring.service.AbstractEntityService;
|
import com.imyeyu.spring.service.AbstractEntityService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// GAO 用户服务实现
|
/// GAO 用户服务实现
|
||||||
///
|
///
|
||||||
@@ -160,4 +167,21 @@ public class GaoUserServiceImplement extends AbstractEntityService<GaoUser, Stri
|
|||||||
loggerService.create(logger);
|
loggerService.create(logger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, GaoUser> mapByUserIdList(Collection<String> userIdList) {
|
||||||
|
if (TimiJava.isEmpty(userIdList)) {
|
||||||
|
return Map.of();
|
||||||
|
}
|
||||||
|
return mapper.selectByUserIdList(userIdList).stream()
|
||||||
|
.collect(Collectors.toMap(GaoUser::getUserId, Function.identity()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<GaoUser> pageRecipients(Page<GaoUser> page) {
|
||||||
|
PageResult<GaoUser> result = new PageResult<>();
|
||||||
|
result.setTotal(mapper.countRecipients(page));
|
||||||
|
result.setList(mapper.selectRecipientPage(page));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.imyeyu.api.modules.gao.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/// 登记事件选项统计视图
|
||||||
|
///
|
||||||
|
/// @author Codex
|
||||||
|
/// @since 2026-08-30
|
||||||
|
@Data
|
||||||
|
public class GaoEventOptionStatView {
|
||||||
|
|
||||||
|
/// 选项组 ID
|
||||||
|
private String groupId;
|
||||||
|
|
||||||
|
/// 选项组名称
|
||||||
|
private String groupName;
|
||||||
|
|
||||||
|
/// 选项 ID
|
||||||
|
private String optionId;
|
||||||
|
|
||||||
|
/// 选项名称
|
||||||
|
private String optionLabel;
|
||||||
|
|
||||||
|
/// 登记记录数量
|
||||||
|
private Long recordCount;
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.imyeyu.api.modules.gao.vo;
|
package com.imyeyu.api.modules.gao.vo;
|
||||||
|
|
||||||
|
import com.imyeyu.api.modules.gao.entity.GaoEventRecord;
|
||||||
import com.imyeyu.java.bean.BasePage;
|
import com.imyeyu.java.bean.BasePage;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
@@ -24,6 +25,12 @@ public class GaoEventRecordPage extends BasePage {
|
|||||||
/// 登记事件 ID 列表,为空查询全部登记事件
|
/// 登记事件 ID 列表,为空查询全部登记事件
|
||||||
private List<String> eventIdList;
|
private List<String> eventIdList;
|
||||||
|
|
||||||
|
/// 必须同时包含的选项 ID 列表
|
||||||
|
private List<String> optionIdList;
|
||||||
|
|
||||||
|
/// 核销状态,为空查询全部状态
|
||||||
|
private GaoEventRecord.VerificationStatus verificationStatus;
|
||||||
|
|
||||||
/// 关键词,匹配客户、登记事件、备注、登记人
|
/// 关键词,匹配客户、登记事件、备注、登记人
|
||||||
private String keyword;
|
private String keyword;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
ALTER TABLE `notify_detail`
|
||||||
|
CHANGE COLUMN `data` `content` LONGTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '内容',
|
||||||
|
ADD COLUMN `content_type` VARCHAR(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '内容类型' AFTER `content`;
|
||||||
|
|
||||||
|
ALTER TABLE `sms_queue`
|
||||||
|
CHANGE COLUMN `data` `content` LONGTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '内容';
|
||||||
|
|
||||||
|
ALTER TABLE `mail_queue`
|
||||||
|
CHANGE COLUMN `data` `content` LONGTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '内容';
|
||||||
|
|
||||||
|
ALTER TABLE `http_queue`
|
||||||
|
CHANGE COLUMN `data` `content` LONGTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '内容';
|
||||||
|
|
||||||
|
ALTER TABLE `wechat_queue`
|
||||||
|
CHANGE COLUMN `data` `content` LONGTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '内容';
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
UPDATE `gao_customer` AS `customer`
|
||||||
|
SET `invited_count` = (
|
||||||
|
SELECT COUNT(1)
|
||||||
|
FROM `gao_customer` AS `invitee`
|
||||||
|
WHERE
|
||||||
|
`invitee`.`introducer_customer_id` = `customer`.`id`
|
||||||
|
AND `invitee`.`deleted_at` IS NULL
|
||||||
|
)
|
||||||
|
WHERE `customer`.`deleted_at` IS NULL;
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
ALTER TABLE `notify`
|
||||||
|
ADD INDEX `idx_created_by_created`(`created_by` ASC, `created_at` DESC) USING BTREE;
|
||||||
|
|
||||||
|
ALTER TABLE `notify_detail`
|
||||||
|
ADD INDEX `idx_notify_send_from_deleted`(`notify_id` ASC, `send_from` ASC, `deleted_at` ASC) USING BTREE,
|
||||||
|
ADD INDEX `idx_internal_user_send_at`(`msg_type` ASC, `send_to` ASC, `send_at` ASC, `deleted_at` ASC) USING BTREE;
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
ALTER TABLE `notify_detail`
|
||||||
|
ADD COLUMN `hidden_at` BIGINT(20) COMMENT '收件人隐藏时间' AFTER `read_at`,
|
||||||
|
DROP INDEX `idx_internal_user_send_at`,
|
||||||
|
ADD INDEX `idx_internal_user_send_at`(`msg_type` ASC, `send_to` ASC, `hidden_at` ASC, `send_at` ASC, `deleted_at` ASC) USING BTREE;
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
ALTER TABLE `gao_event`
|
||||||
|
ADD COLUMN `require_verification` BIT(1) NOT NULL DEFAULT b'0' COMMENT 'true 为登记记录需要核销' AFTER `require_photo`;
|
||||||
|
|
||||||
|
ALTER TABLE `gao_event_record`
|
||||||
|
ADD COLUMN `verification_status` VARCHAR(32) NOT NULL DEFAULT 'NOT_REQUIRED' COMMENT '核销状态,NOT_REQUIRED 无需核销,PENDING 待核销,VERIFIED 已核销' AFTER `number_value`,
|
||||||
|
ADD COLUMN `verifier_user_id` VARCHAR(36) NULL COMMENT '核销用户 ID' AFTER `verification_status`,
|
||||||
|
ADD COLUMN `verified_at` BIGINT NULL COMMENT '核销时间,毫秒' AFTER `verifier_user_id`,
|
||||||
|
ADD KEY `idx_gao_event_record_store_verification` (`store_id`, `verification_status`, `deleted_at`, `registered_at`);
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS `gao_event_option_group` (
|
||||||
|
`id` VARCHAR(36) NOT NULL,
|
||||||
|
`event_id` VARCHAR(36) NOT NULL COMMENT '登记事件 ID',
|
||||||
|
`name` VARCHAR(64) NOT NULL COMMENT '选项组名称',
|
||||||
|
`selection_mode` VARCHAR(16) NOT NULL COMMENT '选择模式,SINGLE 单选,MULTIPLE 多选',
|
||||||
|
`required` BIT(1) NOT NULL DEFAULT b'0' COMMENT 'true 为登记时必须选择至少一个选项',
|
||||||
|
`sort` INT NOT NULL DEFAULT 0 COMMENT '排序值',
|
||||||
|
`created_at` BIGINT NOT NULL,
|
||||||
|
`updated_at` BIGINT NULL,
|
||||||
|
`deleted_at` BIGINT NULL,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `idx_gao_event_option_group_event` (`event_id`, `deleted_at`, `sort`, `created_at`)
|
||||||
|
) COMMENT='登记事件选项组';
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `gao_event_option` (
|
||||||
|
`id` VARCHAR(36) NOT NULL,
|
||||||
|
`group_id` VARCHAR(36) NOT NULL COMMENT '选项组 ID',
|
||||||
|
`label` VARCHAR(128) NOT NULL COMMENT '选项名称',
|
||||||
|
`sort` INT NOT NULL DEFAULT 0 COMMENT '排序值',
|
||||||
|
`created_at` BIGINT NOT NULL,
|
||||||
|
`updated_at` BIGINT NULL,
|
||||||
|
`deleted_at` BIGINT NULL,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `idx_gao_event_option_group` (`group_id`, `deleted_at`, `sort`, `created_at`)
|
||||||
|
) COMMENT='登记事件选项';
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `gao_event_record_option` (
|
||||||
|
`id` VARCHAR(36) NOT NULL,
|
||||||
|
`event_record_id` VARCHAR(36) NOT NULL COMMENT '登记事件记录 ID',
|
||||||
|
`group_id` VARCHAR(36) NOT NULL COMMENT '选项组 ID',
|
||||||
|
`option_id` VARCHAR(36) NOT NULL COMMENT '选项 ID',
|
||||||
|
`group_sort` INT NOT NULL DEFAULT 0 COMMENT '选项组排序快照',
|
||||||
|
`option_sort` INT NOT NULL DEFAULT 0 COMMENT '选项排序快照',
|
||||||
|
`group_name_snapshot` VARCHAR(64) NOT NULL COMMENT '选项组名称快照',
|
||||||
|
`option_label_snapshot` VARCHAR(128) NOT NULL COMMENT '选项名称快照',
|
||||||
|
`created_at` BIGINT NOT NULL,
|
||||||
|
`updated_at` BIGINT NULL,
|
||||||
|
`deleted_at` BIGINT NULL,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `uk_gao_event_record_option` (`event_record_id`, `option_id`, `deleted_at`),
|
||||||
|
KEY `idx_gao_event_record_option_option` (`option_id`, `deleted_at`, `event_record_id`),
|
||||||
|
KEY `idx_gao_event_record_option_group` (`group_id`, `deleted_at`, `event_record_id`)
|
||||||
|
) COMMENT='登记事件记录选项';
|
||||||
@@ -98,6 +98,13 @@
|
|||||||
)
|
)
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateExpireAt">
|
||||||
|
UPDATE `attachment_variant`
|
||||||
|
SET `expire_at` = #{expireAt}
|
||||||
|
WHERE `id` = #{id}
|
||||||
|
AND `expire_at` > #{now}
|
||||||
|
</update>
|
||||||
|
|
||||||
<delete id="delete">
|
<delete id="delete">
|
||||||
DELETE FROM `attachment_variant`
|
DELETE FROM `attachment_variant`
|
||||||
WHERE `id` = #{id}
|
WHERE `id` = #{id}
|
||||||
|
|||||||
@@ -0,0 +1,82 @@
|
|||||||
|
<?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.NotifyMapper">
|
||||||
|
<select id="selectManagementPage" resultType="com.imyeyu.api.modules.common.vo.NotifyManagementItem">
|
||||||
|
SELECT
|
||||||
|
n.`id`,
|
||||||
|
n.`created_by`,
|
||||||
|
n.`created_at`,
|
||||||
|
n.`updated_at`,
|
||||||
|
MAX(detail.`subject`) AS `subject`,
|
||||||
|
MAX(detail.`content`) AS `content`,
|
||||||
|
MAX(detail.`content_type`) AS `content_type`,
|
||||||
|
MAX(detail.`send_at`) AS `send_at`,
|
||||||
|
COUNT(detail.`id`) AS `recipient_count`,
|
||||||
|
COUNT(CASE WHEN detail.`read_at` IS NOT NULL THEN 1 END) AS `read_count`,
|
||||||
|
COUNT(CASE WHEN detail.`status` = 'WAITING' THEN 1 END) AS `waiting_count`,
|
||||||
|
COUNT(CASE WHEN detail.`status` = 'REMINDED' THEN 1 END) AS `reminded_count`,
|
||||||
|
COUNT(CASE WHEN detail.`status` = 'TIMEOUT' THEN 1 END) AS `timeout_count`,
|
||||||
|
COUNT(CASE WHEN detail.`status` = 'CANCEL' THEN 1 END) AS `cancel_count`,
|
||||||
|
COUNT(CASE WHEN detail.`status` = 'FAIL' THEN 1 END) AS `fail_count`
|
||||||
|
FROM `notify` n
|
||||||
|
INNER JOIN `notify_detail` detail
|
||||||
|
ON detail.`notify_id` = n.`id`
|
||||||
|
AND detail.`msg_type` = 'INTERNAL'
|
||||||
|
AND detail.`deleted_at` IS NULL
|
||||||
|
WHERE n.`deleted_at` IS NULL
|
||||||
|
AND (
|
||||||
|
n.`created_by` = #{userId}
|
||||||
|
OR EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM `notify_detail` owner_detail
|
||||||
|
WHERE owner_detail.`notify_id` = n.`id`
|
||||||
|
AND owner_detail.`send_from` = #{userId}
|
||||||
|
AND owner_detail.`deleted_at` IS NULL
|
||||||
|
)
|
||||||
|
)
|
||||||
|
GROUP BY n.`id`, n.`created_by`, n.`created_at`, n.`updated_at`
|
||||||
|
ORDER BY n.`created_at` DESC
|
||||||
|
LIMIT #{offset}, #{limit}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="countManagement" resultType="long">
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM `notify` n
|
||||||
|
WHERE n.`deleted_at` IS NULL
|
||||||
|
AND (
|
||||||
|
n.`created_by` = #{userId}
|
||||||
|
OR EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM `notify_detail` owner_detail
|
||||||
|
WHERE owner_detail.`notify_id` = n.`id`
|
||||||
|
AND owner_detail.`send_from` = #{userId}
|
||||||
|
AND owner_detail.`deleted_at` IS NULL
|
||||||
|
)
|
||||||
|
)
|
||||||
|
AND EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM `notify_detail` detail
|
||||||
|
WHERE detail.`notify_id` = n.`id`
|
||||||
|
AND detail.`msg_type` = 'INTERNAL'
|
||||||
|
AND detail.`deleted_at` IS NULL
|
||||||
|
)
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectManagement" resultType="com.imyeyu.api.modules.common.entity.Notify">
|
||||||
|
SELECT n.*
|
||||||
|
FROM `notify` n
|
||||||
|
WHERE n.`id` = #{notifyId}
|
||||||
|
AND n.`deleted_at` IS NULL
|
||||||
|
AND (
|
||||||
|
n.`created_by` = #{userId}
|
||||||
|
OR EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM `notify_detail` owner_detail
|
||||||
|
WHERE owner_detail.`notify_id` = n.`id`
|
||||||
|
AND owner_detail.`send_from` = #{userId}
|
||||||
|
AND owner_detail.`deleted_at` IS NULL
|
||||||
|
)
|
||||||
|
)
|
||||||
|
LIMIT 1
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?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.GaoEventOptionGroupMapper">
|
||||||
|
<select id="selectAllByEventIdList" resultType="com.imyeyu.api.modules.gao.entity.GaoEventOptionGroup">
|
||||||
|
SELECT
|
||||||
|
*
|
||||||
|
FROM `gao_event_option_group`
|
||||||
|
WHERE
|
||||||
|
TRUE
|
||||||
|
<if test="eventIdList != null and !eventIdList.isEmpty()">
|
||||||
|
AND `event_id` IN
|
||||||
|
<foreach collection="eventIdList" item="eventId" separator="," open="(" close=")">
|
||||||
|
#{eventId}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="eventIdList == null or eventIdList.isEmpty()">
|
||||||
|
AND FALSE
|
||||||
|
</if>
|
||||||
|
AND `deleted_at` IS NULL
|
||||||
|
ORDER BY `sort`, `created_at`
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?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.GaoEventOptionMapper">
|
||||||
|
<select id="selectAllByGroupIdList" resultType="com.imyeyu.api.modules.gao.entity.GaoEventOption">
|
||||||
|
SELECT
|
||||||
|
*
|
||||||
|
FROM `gao_event_option`
|
||||||
|
WHERE
|
||||||
|
TRUE
|
||||||
|
<if test="groupIdList != null and !groupIdList.isEmpty()">
|
||||||
|
AND `group_id` IN
|
||||||
|
<foreach collection="groupIdList" item="groupId" separator="," open="(" close=")">
|
||||||
|
#{groupId}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="groupIdList == null or groupIdList.isEmpty()">
|
||||||
|
AND FALSE
|
||||||
|
</if>
|
||||||
|
AND `deleted_at` IS NULL
|
||||||
|
ORDER BY `sort`, `created_at`
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
@@ -59,6 +59,19 @@
|
|||||||
AND `deleted_at` IS NULL
|
AND `deleted_at` IS NULL
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<update id="verify">
|
||||||
|
UPDATE `gao_event_record`
|
||||||
|
SET
|
||||||
|
`verification_status` = 'VERIFIED',
|
||||||
|
`verifier_user_id` = #{verifierUserId},
|
||||||
|
`verified_at` = #{verifiedAt},
|
||||||
|
`updated_at` = ROUND(UNIX_TIMESTAMP(CURRENT_TIMESTAMP(3)) * 1000)
|
||||||
|
WHERE
|
||||||
|
`id` = #{id}
|
||||||
|
AND `verification_status` = 'PENDING'
|
||||||
|
AND `deleted_at` IS NULL
|
||||||
|
</update>
|
||||||
|
|
||||||
<select id="countByStoreIdAndRegisteredDateValue" resultType="java.lang.Long">
|
<select id="countByStoreIdAndRegisteredDateValue" resultType="java.lang.Long">
|
||||||
SELECT
|
SELECT
|
||||||
COUNT(1)
|
COUNT(1)
|
||||||
@@ -105,6 +118,20 @@
|
|||||||
#{eventId}
|
#{eventId}
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
|
<if test="optionIdList != null and optionIdList.size() > 0">
|
||||||
|
<foreach collection="optionIdList" item="optionId">
|
||||||
|
AND EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM `gao_event_record_option` fro
|
||||||
|
WHERE fro.`event_record_id` = r.`id`
|
||||||
|
AND fro.`option_id` = #{optionId}
|
||||||
|
AND fro.`deleted_at` IS NULL
|
||||||
|
)
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="verificationStatus != null">
|
||||||
|
AND r.`verification_status` = #{verificationStatus}
|
||||||
|
</if>
|
||||||
<if test="keyword != null and keyword.trim() != ''">
|
<if test="keyword != null and keyword.trim() != ''">
|
||||||
AND (
|
AND (
|
||||||
c.`code` LIKE CONCAT('%', #{keyword}, '%')
|
c.`code` LIKE CONCAT('%', #{keyword}, '%')
|
||||||
@@ -138,6 +165,27 @@
|
|||||||
<include refid="rangeWhere"/>
|
<include refid="rangeWhere"/>
|
||||||
AND r.`number_value` IS NOT NULL
|
AND r.`number_value` IS NOT NULL
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selectOptionStatByRange" resultType="com.imyeyu.api.modules.gao.vo.GaoEventOptionStatView">
|
||||||
|
SELECT
|
||||||
|
ro.`group_id` AS `groupId`,
|
||||||
|
ro.`group_name_snapshot` AS `groupName`,
|
||||||
|
ro.`option_id` AS `optionId`,
|
||||||
|
ro.`option_label_snapshot` AS `optionLabel`,
|
||||||
|
COUNT(DISTINCT ro.`event_record_id`) AS `recordCount`
|
||||||
|
FROM `gao_event_record` r
|
||||||
|
INNER JOIN `gao_event_record_option` ro ON ro.`event_record_id` = r.`id`
|
||||||
|
WHERE
|
||||||
|
<include refid="rangeWhere"/>
|
||||||
|
AND ro.`deleted_at` IS NULL
|
||||||
|
GROUP BY
|
||||||
|
ro.`group_id`,
|
||||||
|
ro.`group_name_snapshot`,
|
||||||
|
ro.`option_id`,
|
||||||
|
ro.`option_label_snapshot`,
|
||||||
|
ro.`group_sort`,
|
||||||
|
ro.`option_sort`
|
||||||
|
ORDER BY ro.`group_sort`, ro.`option_sort`
|
||||||
|
</select>
|
||||||
|
|
||||||
<sql id="rankWhere">
|
<sql id="rankWhere">
|
||||||
r.`deleted_at` IS NULL
|
r.`deleted_at` IS NULL
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?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.GaoEventRecordOptionMapper">
|
||||||
|
<select id="selectAllByEventRecordIdList" resultType="com.imyeyu.api.modules.gao.entity.GaoEventRecordOption">
|
||||||
|
SELECT
|
||||||
|
*
|
||||||
|
FROM `gao_event_record_option`
|
||||||
|
WHERE
|
||||||
|
TRUE
|
||||||
|
<if test="eventRecordIdList != null and !eventRecordIdList.isEmpty()">
|
||||||
|
AND `event_record_id` IN
|
||||||
|
<foreach collection="eventRecordIdList" item="eventRecordId" separator="," open="(" close=")">
|
||||||
|
#{eventRecordId}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="eventRecordIdList == null or eventRecordIdList.isEmpty()">
|
||||||
|
AND FALSE
|
||||||
|
</if>
|
||||||
|
AND `deleted_at` IS NULL
|
||||||
|
ORDER BY `group_sort`, `option_sort`, `created_at`
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<?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.GaoUserMapper">
|
||||||
|
<select id="selectByUserIdList" resultType="com.imyeyu.api.modules.gao.entity.GaoUser">
|
||||||
|
SELECT
|
||||||
|
*
|
||||||
|
FROM `gao_user`
|
||||||
|
WHERE
|
||||||
|
`user_id` IN
|
||||||
|
<foreach collection="userIdList" item="userId" separator="," open="(" close=")">
|
||||||
|
#{userId}
|
||||||
|
</foreach>
|
||||||
|
AND `deleted_at` IS NULL
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectRecipientPage" resultType="com.imyeyu.api.modules.gao.entity.GaoUser">
|
||||||
|
SELECT *
|
||||||
|
FROM `gao_user`
|
||||||
|
WHERE `enabled` = 1
|
||||||
|
AND (`deleted_at` IS NULL OR FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000) < `deleted_at`)
|
||||||
|
<if test="page.equalsExample != null and page.equalsExample.storeId != null and page.equalsExample.storeId != ''">
|
||||||
|
AND `store_id` = #{page.equalsExample.storeId}
|
||||||
|
</if>
|
||||||
|
ORDER BY COALESCE(`updated_at`, `created_at`) DESC
|
||||||
|
LIMIT #{page.offset}, #{page.limit}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="countRecipients" resultType="long">
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM `gao_user`
|
||||||
|
WHERE `enabled` = 1
|
||||||
|
AND (`deleted_at` IS NULL OR FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000) < `deleted_at`)
|
||||||
|
<if test="page.equalsExample != null and page.equalsExample.storeId != null and page.equalsExample.storeId != ''">
|
||||||
|
AND `store_id` = #{page.equalsExample.storeId}
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user