Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
feb4d7af66 | ||
|
|
5cfcd24657 | ||
|
|
712118556b |
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
<groupId>com.imyeyu.timiserverapi</groupId>
|
<groupId>com.imyeyu.timiserverapi</groupId>
|
||||||
<artifactId>TimiServerAPI</artifactId>
|
<artifactId>TimiServerAPI</artifactId>
|
||||||
<version>1.0.27</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>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.imyeyu.api.modules.gao.controller;
|
|||||||
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission;
|
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission;
|
||||||
import com.imyeyu.api.modules.gao.bean.GaoPermissionCode;
|
import com.imyeyu.api.modules.gao.bean.GaoPermissionCode;
|
||||||
import com.imyeyu.api.modules.gao.entity.GaoEvent;
|
import com.imyeyu.api.modules.gao.entity.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.GaoStoreScopeService;
|
import com.imyeyu.api.modules.gao.service.GaoStoreScopeService;
|
||||||
import com.imyeyu.java.TimiJava;
|
import com.imyeyu.java.TimiJava;
|
||||||
@@ -49,6 +50,7 @@ public class GaoEventController {
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,6 +71,7 @@ public class GaoEventController {
|
|||||||
TimiException.required(event, "not found event");
|
TimiException.required(event, "not found event");
|
||||||
storeScopeService.checkStoreId(event.getStoreId());
|
storeScopeService.checkStoreId(event.getStoreId());
|
||||||
event.setRoleCodeList(service.listRoleCode(event.getId()));
|
event.setRoleCodeList(service.listRoleCode(event.getId()));
|
||||||
|
service.attachOptionGroupList(List.of(event));
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,6 +98,17 @@ public class GaoEventController {
|
|||||||
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)
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ 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.gao.vo.GaoEventOptionStatView;
|
||||||
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;
|
||||||
@@ -78,6 +79,7 @@ public class GaoEventRecordController {
|
|||||||
record.setCustomer(customerMap.get(record.getCustomerId()));
|
record.setCustomer(customerMap.get(record.getCustomerId()));
|
||||||
record.getCustomer().setAttachmentList(attachMap.get(record.getCustomerId()));
|
record.getCustomer().setAttachmentList(attachMap.get(record.getCustomerId()));
|
||||||
}
|
}
|
||||||
|
service.attachSelectedOptionGroupList(result.getList());
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -110,11 +112,13 @@ public class GaoEventRecordController {
|
|||||||
record.setCustomer(customerService.get(record.getCustomerId()));
|
record.setCustomer(customerService.get(record.getCustomerId()));
|
||||||
record.getCustomer().setAttachmentList(attachmentService.listByBizId(Attachment.BizType.GAO_CUSTOMER, record.getCustomerId()));
|
record.getCustomer().setAttachmentList(attachmentService.listByBizId(Attachment.BizType.GAO_CUSTOMER, record.getCustomerId()));
|
||||||
record.setEvent(eventService.get(record.getEventId()));
|
record.setEvent(eventService.get(record.getEventId()));
|
||||||
|
eventService.attachOptionGroupList(List.of(record.getEvent()));
|
||||||
record.setOperator(userService.get(record.getOperatorUserId()));
|
record.setOperator(userService.get(record.getOperatorUserId()));
|
||||||
if (record.getVerifierUserId() != null) {
|
if (record.getVerifierUserId() != null) {
|
||||||
record.setVerifier(userService.get(record.getVerifierUserId()));
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,6 +238,16 @@ public class GaoEventRecordController {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AOPLog
|
||||||
|
@RequestRateLimit
|
||||||
|
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||||
|
@PostMapping("/option/stat")
|
||||||
|
public List<GaoEventOptionStatView> optionStat(@RequestBody GaoEventRecordPage page) {
|
||||||
|
TimiException.required(page, "not found page");
|
||||||
|
page.setStoreId(storeScopeService.resolveStoreId(page.getStoreId()));
|
||||||
|
return service.optionStatByRange(page);
|
||||||
|
}
|
||||||
|
|
||||||
private void resolveCreateRecordStore(GaoEventRecord record) {
|
private void resolveCreateRecordStore(GaoEventRecord record) {
|
||||||
TimiException.required(record, "not found event record");
|
TimiException.required(record, "not found event record");
|
||||||
GaoEvent event = eventService.get(record.getEventId());
|
GaoEvent event = eventService.get(record.getEventId());
|
||||||
|
|||||||
@@ -138,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;
|
||||||
|
}
|
||||||
@@ -105,4 +105,8 @@ public class GaoEventRecord extends UUIDEntity {
|
|||||||
/// 客户 ID 列表,批量登记时使用
|
/// 客户 ID 列表,批量登记时使用
|
||||||
@Transient
|
@Transient
|
||||||
private List<String> customerIdList;
|
private List<String> customerIdList;
|
||||||
|
|
||||||
|
/// 登记记录已选择的选项组列表
|
||||||
|
@Transient
|
||||||
|
private List<GaoEventRecordOptionGroup> selectedOptionGroupList;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.imyeyu.api.modules.gao.entity;
|
||||||
|
|
||||||
|
import com.imyeyu.spring.entity.UUIDEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/// 登记事件记录选项关系
|
||||||
|
///
|
||||||
|
/// @author Codex
|
||||||
|
/// @since 2026-08-30
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class GaoEventRecordOption extends UUIDEntity {
|
||||||
|
|
||||||
|
/// 登记事件记录 ID
|
||||||
|
private String eventRecordId;
|
||||||
|
|
||||||
|
/// 选项组 ID
|
||||||
|
private String groupId;
|
||||||
|
|
||||||
|
/// 选项 ID
|
||||||
|
private String optionId;
|
||||||
|
|
||||||
|
/// 选项组排序快照
|
||||||
|
private Integer groupSort;
|
||||||
|
|
||||||
|
/// 选项排序快照
|
||||||
|
private Integer optionSort;
|
||||||
|
|
||||||
|
/// 选项组名称快照
|
||||||
|
private String groupNameSnapshot;
|
||||||
|
|
||||||
|
/// 选项名称快照
|
||||||
|
private String optionLabelSnapshot;
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.imyeyu.api.modules.gao.entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/// 登记事件记录选项组视图
|
||||||
|
///
|
||||||
|
/// @author Codex
|
||||||
|
/// @since 2026-08-30
|
||||||
|
@Data
|
||||||
|
public class GaoEventRecordOptionGroup {
|
||||||
|
|
||||||
|
/// 选项组 ID
|
||||||
|
private String groupId;
|
||||||
|
|
||||||
|
/// 选项组名称
|
||||||
|
private String groupName;
|
||||||
|
|
||||||
|
/// 已选择的选项列表
|
||||||
|
private List<GaoEventOption> selectedOptionList;
|
||||||
|
}
|
||||||
@@ -0,0 +1,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;
|
||||||
@@ -79,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);
|
||||||
|
}
|
||||||
@@ -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,11 @@ 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
|
/// @param id 登记记录 ID
|
||||||
@@ -49,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
|
||||||
|
|||||||
+132
@@ -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;
|
||||||
@@ -44,7 +50,9 @@ 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.HashSet;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/// 登记事件记录服务实现
|
/// 登记事件记录服务实现
|
||||||
@@ -69,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;
|
||||||
|
|
||||||
@@ -85,6 +94,41 @@ 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)
|
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||||
@Override
|
@Override
|
||||||
public void verify(String id) {
|
public void verify(String id) {
|
||||||
@@ -127,6 +171,8 @@ 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());
|
verifyRecordAttachment(event, record.getAttachmentList());
|
||||||
// 检查权限
|
// 检查权限
|
||||||
@@ -166,6 +212,7 @@ public class GaoEventRecordServiceImplement extends AbstractEntityService<GaoEve
|
|||||||
: GaoEventRecord.VerificationStatus.NOT_REQUIRED);
|
: 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) {
|
||||||
// 第一个记录储存附件
|
// 第一个记录储存附件
|
||||||
@@ -238,10 +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());
|
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());
|
||||||
@@ -269,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);
|
||||||
@@ -330,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");
|
||||||
@@ -432,6 +499,71 @@ 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) {
|
private void verifyRecordAttachment(GaoEvent event, List<Attachment> attachmentList) {
|
||||||
if (!Boolean.TRUE.equals(event.getRequirePhoto())) {
|
if (!Boolean.TRUE.equals(event.getRequirePhoto())) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
+170
-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;
|
||||||
|
|
||||||
@@ -76,6 +83,7 @@ public class GaoEventServiceImplement extends AbstractEntityService<GaoEvent, St
|
|||||||
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) {
|
||||||
@@ -129,10 +137,16 @@ public class GaoEventServiceImplement extends AbstractEntityService<GaoEvent, St
|
|||||||
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) {
|
||||||
@@ -149,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) {
|
||||||
@@ -203,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
|
||||||
@@ -242,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) {
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -25,6 +25,9 @@ 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 GaoEventRecord.VerificationStatus verificationStatus;
|
||||||
|
|
||||||
|
|||||||
@@ -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='登记事件记录选项';
|
||||||
@@ -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>
|
||||||
@@ -118,6 +118,17 @@
|
|||||||
#{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">
|
<if test="verificationStatus != null">
|
||||||
AND r.`verification_status` = #{verificationStatus}
|
AND r.`verification_status` = #{verificationStatus}
|
||||||
</if>
|
</if>
|
||||||
@@ -154,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>
|
||||||
Reference in New Issue
Block a user