Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fcf358a768 | ||
|
|
36e2a37af2 | ||
|
|
348f7396a1 |
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
<groupId>com.imyeyu.timiserverapi</groupId>
|
<groupId>com.imyeyu.timiserverapi</groupId>
|
||||||
<artifactId>TimiServerAPI</artifactId>
|
<artifactId>TimiServerAPI</artifactId>
|
||||||
<version>1.0.12</version>
|
<version>1.0.13</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>TimiServerAPI</name>
|
<name>TimiServerAPI</name>
|
||||||
<description>imyeyu.com API</description>
|
<description>imyeyu.com API</description>
|
||||||
|
|||||||
@@ -14,6 +14,21 @@ import lombok.EqualsAndHashCode;
|
|||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class Tag extends UUIDEntity {
|
public class Tag extends UUIDEntity {
|
||||||
|
|
||||||
|
///
|
||||||
|
///
|
||||||
|
/// @author 夜雨
|
||||||
|
/// @since 2026-08-12 16:49
|
||||||
|
public enum OwnerType {
|
||||||
|
|
||||||
|
GAO_STORE
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 归属类型
|
||||||
|
protected OwnerType ownerType;
|
||||||
|
|
||||||
|
/// 归属 ID
|
||||||
|
protected String ownerId;
|
||||||
|
|
||||||
/// 名称多语言 ID
|
/// 名称多语言 ID
|
||||||
protected String nameLangId;
|
protected String nameLangId;
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.imyeyu.api.modules.common.mapper;
|
|||||||
|
|
||||||
import com.imyeyu.api.modules.common.entity.Tag;
|
import com.imyeyu.api.modules.common.entity.Tag;
|
||||||
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.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -13,4 +14,6 @@ import java.util.List;
|
|||||||
public interface TagMapper extends BaseMapper<Tag, String> {
|
public interface TagMapper extends BaseMapper<Tag, String> {
|
||||||
|
|
||||||
List<Tag> selectByIdList(Collection<String> idList);
|
List<Tag> selectByIdList(Collection<String> idList);
|
||||||
|
|
||||||
|
Tag selectByOwnerAndZhCN(@Param("ownerType") Tag.OwnerType ownerType, @Param("ownerId") String ownerId, @Param("zhCN") String zhCN);
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-2
@@ -40,6 +40,9 @@ public class TagServiceImplement extends AbstractEntityService<Tag, String> impl
|
|||||||
public void create(Tag tag) {
|
public void create(Tag tag) {
|
||||||
TimiException.required(tag, "not found tag");
|
TimiException.required(tag, "not found tag");
|
||||||
TimiException.required(tag.getZhCN(), "not found tag.zhCN");
|
TimiException.required(tag.getZhCN(), "not found tag.zhCN");
|
||||||
|
TimiException.required(tag.getOwnerType(), "not found ownerType");
|
||||||
|
TimiException.required(tag.getOwnerId(), "not found ownerId");
|
||||||
|
checkZhCNUniqueInOwner(tag, null);
|
||||||
tag.setNameLangId(multilingualService.create(tag.getZhCN()));
|
tag.setNameLangId(multilingualService.create(tag.getZhCN()));
|
||||||
super.create(tag);
|
super.create(tag);
|
||||||
}
|
}
|
||||||
@@ -48,12 +51,15 @@ public class TagServiceImplement extends AbstractEntityService<Tag, String> impl
|
|||||||
public void update(Tag tag) {
|
public void update(Tag tag) {
|
||||||
TimiException.required(tag, "not found tag");
|
TimiException.required(tag, "not found tag");
|
||||||
TimiException.required(tag.getId(), "not found tag.id");
|
TimiException.required(tag.getId(), "not found tag.id");
|
||||||
|
Tag dbTag = get(tag.getId());
|
||||||
|
TimiException.required(dbTag, "not found tag");
|
||||||
|
tag.setOwnerType(dbTag.getOwnerType());
|
||||||
|
tag.setOwnerId(dbTag.getOwnerId());
|
||||||
if (tag.getZhCN() != null) {
|
if (tag.getZhCN() != null) {
|
||||||
if (tag.getNameLangId() == null) {
|
if (tag.getNameLangId() == null) {
|
||||||
Tag dbTag = get(tag.getId());
|
|
||||||
TimiException.required(dbTag, "not found tag");
|
|
||||||
tag.setNameLangId(dbTag.getNameLangId());
|
tag.setNameLangId(dbTag.getNameLangId());
|
||||||
}
|
}
|
||||||
|
checkZhCNUniqueInOwner(tag, tag.getId());
|
||||||
tag.setNameLangId(multilingualService.createIfDifferent(tag.getNameLangId(), tag.getZhCN()));
|
tag.setNameLangId(multilingualService.createIfDifferent(tag.getNameLangId(), tag.getZhCN()));
|
||||||
}
|
}
|
||||||
super.update(tag);
|
super.update(tag);
|
||||||
@@ -97,4 +103,9 @@ public class TagServiceImplement extends AbstractEntityService<Tag, String> impl
|
|||||||
example.setBizId(bizId);
|
example.setBizId(bizId);
|
||||||
return applyMapper.selectAllByExample(example);
|
return applyMapper.selectAllByExample(example);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkZhCNUniqueInOwner(Tag tag, String allowedId) {
|
||||||
|
Tag existed = mapper.selectByOwnerAndZhCN(tag.getOwnerType(), tag.getOwnerId(), tag.getZhCN());
|
||||||
|
TimiException.requiredTrue(existed == null || existed.getId().equals(allowedId), "该标签名称已存在");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import com.imyeyu.api.modules.gao.service.GaoCustomerService;
|
|||||||
import com.imyeyu.api.modules.gao.service.GaoStoreService;
|
import com.imyeyu.api.modules.gao.service.GaoStoreService;
|
||||||
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.GaoCustomerTrendStateReq;
|
import com.imyeyu.api.modules.gao.vo.GaoCustomerTrendStateReq;
|
||||||
import com.imyeyu.api.modules.user.service.RoleChecker;
|
import com.imyeyu.api.modules.user.service.RoleChecker;
|
||||||
import com.imyeyu.api.modules.user.service.UserLoginService;
|
import com.imyeyu.api.modules.user.service.UserLoginService;
|
||||||
@@ -60,8 +61,8 @@ public class GaoCustomerController {
|
|||||||
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_READ)
|
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_READ)
|
||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
@JsonView(ResponseView.Public.class)
|
@JsonView(ResponseView.Public.class)
|
||||||
public PageResult<GaoCustomer> list(@RequestBody Page<GaoCustomer> page) {
|
public PageResult<GaoCustomer> list(@RequestBody GaoCustomerPage page) {
|
||||||
PageResult<GaoCustomer> result = service.page(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();
|
||||||
Map<String, List<Attachment>> attachmentMap = attachmentService.mapByBizIdList(Attachment.BizType.GAO_CUSTOMER, idList);
|
Map<String, List<Attachment>> attachmentMap = attachmentService.mapByBizIdList(Attachment.BizType.GAO_CUSTOMER, idList);
|
||||||
|
|||||||
@@ -0,0 +1,139 @@
|
|||||||
|
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.ModuleCode;
|
||||||
|
import com.imyeyu.api.modules.common.entity.Tag;
|
||||||
|
import com.imyeyu.api.modules.common.entity.TagApply;
|
||||||
|
import com.imyeyu.api.modules.common.service.TagService;
|
||||||
|
import com.imyeyu.api.modules.gao.bean.GaoRoleCode;
|
||||||
|
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 com.imyeyu.spring.annotation.AOPLog;
|
||||||
|
import com.imyeyu.spring.annotation.RequestRateLimit;
|
||||||
|
import com.imyeyu.spring.bean.Page;
|
||||||
|
import com.imyeyu.spring.bean.PageResult;
|
||||||
|
import com.imyeyu.spring.util.ResponseView;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/// GAO 标签接口
|
||||||
|
///
|
||||||
|
/// @author Codex
|
||||||
|
/// @since 2026-08-13
|
||||||
|
@RestController
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RequestMapping("/gao/tag")
|
||||||
|
public class GaoTagController {
|
||||||
|
|
||||||
|
private final TagService service;
|
||||||
|
private final RoleChecker roleChecker;
|
||||||
|
private final GaoStoreService storeService;
|
||||||
|
|
||||||
|
/// 查询标签列表
|
||||||
|
///
|
||||||
|
/// @param page 分页参数
|
||||||
|
/// @return 标签分页
|
||||||
|
@JsonView(ResponseView.Public.class)
|
||||||
|
@RequestRateLimit
|
||||||
|
@RequireCorePermission(CorePermissionCode.TAG_READ)
|
||||||
|
@PostMapping("/list")
|
||||||
|
public PageResult<Tag> list(@RequestBody Page<Tag> page) {
|
||||||
|
TimiException.required(page, "未找到分页参数");
|
||||||
|
page.setEqualsExample(TimiJava.defaultIfNull(page.getEqualsExample(), new Tag()));
|
||||||
|
page.getEqualsExample().setOwnerType(Tag.OwnerType.GAO_STORE);
|
||||||
|
if (!roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name())) {
|
||||||
|
page.getEqualsExample().setOwnerId(storeService.getBelongIdByRequiredLoginUserId());
|
||||||
|
}
|
||||||
|
return service.page(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 查询标签详情
|
||||||
|
///
|
||||||
|
/// @param id 标签 ID
|
||||||
|
/// @return 标签详情
|
||||||
|
@JsonView(ResponseView.Public.class)
|
||||||
|
@RequestRateLimit
|
||||||
|
@RequireCorePermission(CorePermissionCode.TAG_READ)
|
||||||
|
@PostMapping("/detail")
|
||||||
|
public Tag detail(@RequestParam String id) {
|
||||||
|
return service.get(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 创建标签
|
||||||
|
///
|
||||||
|
/// @param tag 标签
|
||||||
|
/// @return 标签
|
||||||
|
@AOPLog
|
||||||
|
@JsonView(ResponseView.Public.class)
|
||||||
|
@RequestRateLimit
|
||||||
|
@RequireCorePermission(CorePermissionCode.TAG_CREATE)
|
||||||
|
@PostMapping("/create")
|
||||||
|
public Tag create(@RequestBody Tag tag) {
|
||||||
|
tag.setOwnerType(Tag.OwnerType.GAO_STORE);
|
||||||
|
if (!roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name())) {
|
||||||
|
tag.setOwnerId(storeService.getBelongIdByRequiredLoginUserId());
|
||||||
|
}
|
||||||
|
service.create(tag);
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 更新标签
|
||||||
|
///
|
||||||
|
/// @param tag 标签
|
||||||
|
@AOPLog
|
||||||
|
@RequestRateLimit
|
||||||
|
@RequireCorePermission(CorePermissionCode.TAG_UPDATE)
|
||||||
|
@PostMapping("/update")
|
||||||
|
public void update(@RequestBody Tag tag) {
|
||||||
|
Tag dbTag = service.get(tag.getId());
|
||||||
|
tag.setOwnerType(dbTag.getOwnerType());
|
||||||
|
tag.setOwnerId(dbTag.getOwnerId());
|
||||||
|
service.update(tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 删除标签
|
||||||
|
///
|
||||||
|
/// @param id 标签 ID
|
||||||
|
@AOPLog
|
||||||
|
@RequestRateLimit
|
||||||
|
@RequireCorePermission(CorePermissionCode.TAG_DELETE)
|
||||||
|
@PostMapping("/delete")
|
||||||
|
public void delete(@RequestParam String id) {
|
||||||
|
service.delete(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 按业务查询标签
|
||||||
|
///
|
||||||
|
/// @param bizType 业务类型
|
||||||
|
/// @param bizId 业务 ID
|
||||||
|
/// @return 标签列表
|
||||||
|
@JsonView(ResponseView.Public.class)
|
||||||
|
@RequestRateLimit
|
||||||
|
@RequireCorePermission(CorePermissionCode.TAG_READ)
|
||||||
|
@GetMapping("/list/biz/id")
|
||||||
|
public List<Tag> listByBizType(@RequestParam TagApply.BizType bizType, @RequestParam String bizId) {
|
||||||
|
return service.listByBizType(bizType, bizId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 差分保存业务标签
|
||||||
|
///
|
||||||
|
/// @param apply 标签请求
|
||||||
|
@AOPLog
|
||||||
|
@RequestRateLimit
|
||||||
|
@RequireCorePermission(CorePermissionCode.TAG_APPLY)
|
||||||
|
@PostMapping("/apply")
|
||||||
|
public void apply(@RequestBody TagApply apply) {
|
||||||
|
service.apply(apply.getBizType(), apply.getBizId(), apply.getTagIdList());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ package com.imyeyu.api.modules.gao.mapper;
|
|||||||
import com.imyeyu.api.modules.gao.entity.GaoCustomer;
|
import com.imyeyu.api.modules.gao.entity.GaoCustomer;
|
||||||
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.spring.mapper.BaseMapper;
|
import com.imyeyu.spring.mapper.BaseMapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
@@ -35,4 +36,16 @@ public interface GaoCustomerMapper extends BaseMapper<GaoCustomer, String> {
|
|||||||
///
|
///
|
||||||
/// @return 性别统计列表
|
/// @return 性别统计列表
|
||||||
List<GaoCustomerGenderStatView> stateGender(@Param("storeId") String storeId);
|
List<GaoCustomerGenderStatView> stateGender(@Param("storeId") String storeId);
|
||||||
|
|
||||||
|
/// 查询客户总数
|
||||||
|
///
|
||||||
|
/// @param page 查询条件
|
||||||
|
/// @return 客户总数
|
||||||
|
long countByQuery(GaoCustomerPage page);
|
||||||
|
|
||||||
|
/// 分页查询客户
|
||||||
|
///
|
||||||
|
/// @param page 查询条件
|
||||||
|
/// @return 客户列表
|
||||||
|
List<GaoCustomer> selectByQuery(GaoCustomerPage page);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,10 @@ 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.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.GaoCustomerTrendStateReq;
|
import com.imyeyu.api.modules.gao.vo.GaoCustomerTrendStateReq;
|
||||||
import com.imyeyu.spring.bean.Page;
|
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.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -19,6 +21,12 @@ import java.util.stream.Collectors;
|
|||||||
/// @since 2026-07-27 14:12
|
/// @since 2026-07-27 14:12
|
||||||
public interface GaoCustomerService extends BaseService<GaoCustomer, String> {
|
public interface GaoCustomerService extends BaseService<GaoCustomer, String> {
|
||||||
|
|
||||||
|
/// 按查询条件分页查询客户
|
||||||
|
///
|
||||||
|
/// @param page 查询条件
|
||||||
|
/// @return 客户分页
|
||||||
|
PageResult<GaoCustomer> pageByQuery(GaoCustomerPage page);
|
||||||
|
|
||||||
void updateWithAttachment(GaoCustomer customer);
|
void updateWithAttachment(GaoCustomer customer);
|
||||||
|
|
||||||
/// 按编码查询客户
|
/// 按编码查询客户
|
||||||
|
|||||||
+11
@@ -10,6 +10,7 @@ import com.imyeyu.api.modules.gao.service.GaoCustomerService;
|
|||||||
import com.imyeyu.api.modules.gao.util.CustomerXSSFBuilder;
|
import com.imyeyu.api.modules.gao.util.CustomerXSSFBuilder;
|
||||||
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.GaoCustomerTrendStateReq;
|
import com.imyeyu.api.modules.gao.vo.GaoCustomerTrendStateReq;
|
||||||
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;
|
||||||
@@ -18,6 +19,7 @@ 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.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;
|
||||||
@@ -65,6 +67,15 @@ public class GaoCustomerServiceImplement extends AbstractEntityService<GaoCustom
|
|||||||
return mapper;
|
return mapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<GaoCustomer> pageByQuery(GaoCustomerPage page) {
|
||||||
|
TimiException.required(page, "not found page");
|
||||||
|
PageResult<GaoCustomer> result = new PageResult<>();
|
||||||
|
result.setTotal(mapper.countByQuery(page));
|
||||||
|
result.setList(mapper.selectByQuery(page));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||||
@Override
|
@Override
|
||||||
public void create(GaoCustomer customer) {
|
public void create(GaoCustomer customer) {
|
||||||
|
|||||||
+63
-37
@@ -15,6 +15,8 @@ import com.imyeyu.api.modules.gao.service.GaoPointAccountService;
|
|||||||
import com.imyeyu.api.modules.gao.service.GaoPointLedgerService;
|
import com.imyeyu.api.modules.gao.service.GaoPointLedgerService;
|
||||||
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.system.entity.Logger;
|
||||||
|
import com.imyeyu.api.modules.system.service.LoggerService;
|
||||||
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;
|
||||||
@@ -24,6 +26,7 @@ import com.imyeyu.spring.mapper.BaseMapper;
|
|||||||
import com.imyeyu.spring.service.AbstractEntityService;
|
import com.imyeyu.spring.service.AbstractEntityService;
|
||||||
import com.imyeyu.utils.Time;
|
import com.imyeyu.utils.Time;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@@ -34,6 +37,7 @@ import java.util.Map;
|
|||||||
///
|
///
|
||||||
/// @author Codex
|
/// @author Codex
|
||||||
/// @since 2026-08-11
|
/// @since 2026-08-11
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class GaoPointLedgerServiceImplement extends AbstractEntityService<GaoPointLedger, String> implements GaoPointLedgerService {
|
public class GaoPointLedgerServiceImplement extends AbstractEntityService<GaoPointLedger, String> implements GaoPointLedgerService {
|
||||||
@@ -42,6 +46,7 @@ public class GaoPointLedgerServiceImplement extends AbstractEntityService<GaoPoi
|
|||||||
private final GaoPointAccountService accountService;
|
private final GaoPointAccountService accountService;
|
||||||
private final GaoCustomerService customerService;
|
private final GaoCustomerService customerService;
|
||||||
private final AttachmentService attachmentService;
|
private final AttachmentService attachmentService;
|
||||||
|
private final LoggerService loggerService;
|
||||||
private final UserLoginService userLoginService;
|
private final UserLoginService userLoginService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -128,43 +133,64 @@ public class GaoPointLedgerServiceImplement extends AbstractEntityService<GaoPoi
|
|||||||
}
|
}
|
||||||
|
|
||||||
private GaoPointLedger apply(String storeId, String customerId, GaoPointLedger.ChangeType changeType, long pointDelta, String ruleId, String eventId, String eventRecordId, JsonNode sourcePayload, String idempotencyKey, String remark, String operatorUserId, Long occurredAt) {
|
private GaoPointLedger apply(String storeId, String customerId, GaoPointLedger.ChangeType changeType, long pointDelta, String ruleId, String eventId, String eventRecordId, JsonNode sourcePayload, String idempotencyKey, String remark, String operatorUserId, Long occurredAt) {
|
||||||
GaoPointLedger existing = mapper.selectByIdempotencyKey(idempotencyKey);
|
Logger logger = new Logger(Logger.Module.GAO, "GAO_POINT_LEDGER_APPLY");
|
||||||
if (existing != null) {
|
logger.setContent("storeId=%s, customerId=%s, changeType=%s, pointDelta=%d, idempotencyKey=%s, remark=%s".formatted(storeId, customerId, changeType, pointDelta, idempotencyKey, remark));
|
||||||
return existing;
|
try {
|
||||||
|
GaoPointLedger existing = mapper.selectByIdempotencyKey(idempotencyKey);
|
||||||
|
if (existing != null) {
|
||||||
|
logger.setLevel(Logger.Level.INFO);
|
||||||
|
logger.setResult(existing.getId());
|
||||||
|
return existing;
|
||||||
|
}
|
||||||
|
|
||||||
|
GaoPointAccount account = accountService.getOrCreateForUpdate(storeId, customerId);
|
||||||
|
existing = mapper.selectByIdempotencyKey(idempotencyKey);
|
||||||
|
if (existing != null) {
|
||||||
|
logger.setLevel(Logger.Level.INFO);
|
||||||
|
logger.setResult(existing.getId());
|
||||||
|
return existing;
|
||||||
|
}
|
||||||
|
|
||||||
|
long balanceBefore = account.getBalance();
|
||||||
|
long balanceAfter = Math.addExact(balanceBefore, pointDelta);
|
||||||
|
long totalEarnedDelta = changeType == GaoPointLedger.ChangeType.EARN ? pointDelta : 0L;
|
||||||
|
long totalRevokedDelta = changeType == GaoPointLedger.ChangeType.REVOKE ? -pointDelta : 0L;
|
||||||
|
long totalAdjustedDelta = changeType == GaoPointLedger.ChangeType.ADJUST ? pointDelta : 0L;
|
||||||
|
|
||||||
|
GaoPointLedger ledger = new GaoPointLedger();
|
||||||
|
ledger.setAccountId(account.getId());
|
||||||
|
ledger.setStoreId(storeId);
|
||||||
|
ledger.setCustomerId(customerId);
|
||||||
|
ledger.setChangeType(changeType);
|
||||||
|
ledger.setDirection(0 < pointDelta ? GaoPointLedger.Direction.INCREASE : GaoPointLedger.Direction.DECREASE);
|
||||||
|
ledger.setPointDelta(pointDelta);
|
||||||
|
ledger.setBalanceBefore(balanceBefore);
|
||||||
|
ledger.setBalanceAfter(balanceAfter);
|
||||||
|
ledger.setRuleId(ruleId);
|
||||||
|
ledger.setEventId(eventId);
|
||||||
|
ledger.setEventRecordId(eventRecordId);
|
||||||
|
ledger.setSourcePayload(sourcePayload);
|
||||||
|
ledger.setIdempotencyKey(idempotencyKey);
|
||||||
|
ledger.setRemark(remark);
|
||||||
|
ledger.setOperatorUserId(operatorUserId);
|
||||||
|
ledger.setOccurredAt(occurredAt);
|
||||||
|
create(ledger);
|
||||||
|
int updated = accountService.updateBalance(account.getId(), pointDelta, totalEarnedDelta, totalRevokedDelta, totalAdjustedDelta);
|
||||||
|
TimiException.requiredTrue(0 < updated, "积分余额不足");
|
||||||
|
logger.setLevel(Logger.Level.INFO);
|
||||||
|
logger.setResult(ledger.getId());
|
||||||
|
return ledger;
|
||||||
|
} 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
GaoPointAccount account = accountService.getOrCreateForUpdate(storeId, customerId);
|
|
||||||
existing = mapper.selectByIdempotencyKey(idempotencyKey);
|
|
||||||
if (existing != null) {
|
|
||||||
return existing;
|
|
||||||
}
|
|
||||||
|
|
||||||
long balanceBefore = account.getBalance();
|
|
||||||
long balanceAfter = Math.addExact(balanceBefore, pointDelta);
|
|
||||||
long totalEarnedDelta = changeType == GaoPointLedger.ChangeType.EARN ? pointDelta : 0L;
|
|
||||||
long totalRevokedDelta = changeType == GaoPointLedger.ChangeType.REVOKE ? -pointDelta : 0L;
|
|
||||||
long totalAdjustedDelta = changeType == GaoPointLedger.ChangeType.ADJUST ? pointDelta : 0L;
|
|
||||||
|
|
||||||
GaoPointLedger ledger = new GaoPointLedger();
|
|
||||||
ledger.setAccountId(account.getId());
|
|
||||||
ledger.setStoreId(storeId);
|
|
||||||
ledger.setCustomerId(customerId);
|
|
||||||
ledger.setChangeType(changeType);
|
|
||||||
ledger.setDirection(0 < pointDelta ? GaoPointLedger.Direction.INCREASE : GaoPointLedger.Direction.DECREASE);
|
|
||||||
ledger.setPointDelta(pointDelta);
|
|
||||||
ledger.setBalanceBefore(balanceBefore);
|
|
||||||
ledger.setBalanceAfter(balanceAfter);
|
|
||||||
ledger.setRuleId(ruleId);
|
|
||||||
ledger.setEventId(eventId);
|
|
||||||
ledger.setEventRecordId(eventRecordId);
|
|
||||||
ledger.setSourcePayload(sourcePayload);
|
|
||||||
ledger.setIdempotencyKey(idempotencyKey);
|
|
||||||
ledger.setRemark(remark);
|
|
||||||
ledger.setOperatorUserId(operatorUserId);
|
|
||||||
ledger.setOccurredAt(occurredAt);
|
|
||||||
create(ledger);
|
|
||||||
int updated = accountService.updateBalance(account.getId(), pointDelta, totalEarnedDelta, totalRevokedDelta, totalAdjustedDelta);
|
|
||||||
TimiException.requiredTrue(0 < updated, "积分余额不足");
|
|
||||||
return ledger;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package com.imyeyu.api.modules.gao.vo;
|
||||||
|
|
||||||
|
import com.imyeyu.java.bean.BasePage;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/// GAO 客户分页查询请求
|
||||||
|
///
|
||||||
|
/// @author Codex
|
||||||
|
/// @since 2026-08-13
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class GaoCustomerPage extends BasePage {
|
||||||
|
|
||||||
|
/// 门店 ID
|
||||||
|
private String storeId;
|
||||||
|
|
||||||
|
/// 关键字,匹配编码、姓名、电话
|
||||||
|
private String keyword;
|
||||||
|
|
||||||
|
/// 标签 ID 列表,客户必须同时拥有列表内全部标签
|
||||||
|
private List<String> tagIdList;
|
||||||
|
}
|
||||||
@@ -143,7 +143,7 @@ public class FileController implements TimiJava, OS.FileSystem {
|
|||||||
public void read(HttpServletRequest req, HttpServletResponse resp) {
|
public void read(HttpServletRequest req, HttpServletResponse resp) {
|
||||||
try {
|
try {
|
||||||
String path = req.getServletPath().substring("/system/file/read".length());
|
String path = req.getServletPath().substring("/system/file/read".length());
|
||||||
path = "E:\\IDEAProject\\TimiServerAPI\\data\\file" + path;
|
path = "/root/bin/data/mnt" + path;
|
||||||
if (TimiJava.isEmpty(path)) {
|
if (TimiJava.isEmpty(path)) {
|
||||||
resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
|
resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
-- 历史标签统一归入迁移时创建的默认门店。
|
||||||
|
SET @gao_default_store_id = '00000000-0000-0000-0000-000000000001';
|
||||||
|
|
||||||
|
ALTER TABLE `tag`
|
||||||
|
ADD COLUMN `owner_type` VARCHAR(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '归属类型' AFTER `id`,
|
||||||
|
ADD COLUMN `owner_id` VARCHAR(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '归属门店 ID' AFTER `owner_type`;
|
||||||
|
|
||||||
|
UPDATE `tag`
|
||||||
|
SET
|
||||||
|
`owner_type` = 'GAO_STORE',
|
||||||
|
`owner_id` = @gao_default_store_id
|
||||||
|
WHERE `owner_type` IS NULL
|
||||||
|
OR `owner_id` IS NULL;
|
||||||
|
|
||||||
|
ALTER TABLE `tag`
|
||||||
|
MODIFY COLUMN `owner_type` VARCHAR(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '归属类型',
|
||||||
|
MODIFY COLUMN `owner_id` VARCHAR(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '归属门店 ID',
|
||||||
|
ADD KEY `idx_tag_owner` (`owner_type`, `owner_id`, `deleted_at`);
|
||||||
@@ -18,4 +18,18 @@
|
|||||||
</if>
|
</if>
|
||||||
AND `deleted_at` IS NULL
|
AND `deleted_at` IS NULL
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selectByOwnerAndZhCN" resultType="com.imyeyu.api.modules.common.entity.Tag">
|
||||||
|
SELECT
|
||||||
|
`t`.*
|
||||||
|
FROM `tag` `t`
|
||||||
|
INNER JOIN `multilingual` `m`
|
||||||
|
ON `m`.`id` = `t`.`name_lang_id`
|
||||||
|
AND `m`.`deleted_at` IS NULL
|
||||||
|
WHERE
|
||||||
|
`t`.`owner_type` = #{ownerType}
|
||||||
|
AND `t`.`owner_id` = #{ownerId}
|
||||||
|
AND `m`.`zh_cn` = #{zhCN}
|
||||||
|
AND `t`.`deleted_at` IS NULL
|
||||||
|
LIMIT 1
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -19,6 +19,52 @@
|
|||||||
AND `deleted_at` IS NULL
|
AND `deleted_at` IS NULL
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<sql id="queryWhere">
|
||||||
|
`c`.`deleted_at` IS NULL
|
||||||
|
<if test="storeId != null and storeId != ''">
|
||||||
|
AND `c`.`store_id` = #{storeId}
|
||||||
|
</if>
|
||||||
|
<if test="keyword != null and keyword != ''">
|
||||||
|
AND (
|
||||||
|
`c`.`code` LIKE CONCAT('%', #{keyword}, '%')
|
||||||
|
OR `c`.`name` LIKE CONCAT('%', #{keyword}, '%')
|
||||||
|
OR `c`.`telephone` LIKE CONCAT('%', #{keyword}, '%')
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
<if test="tagIdList != null and !tagIdList.isEmpty()">
|
||||||
|
<bind name="tagCount" value="tagIdList.size()"/>
|
||||||
|
AND `c`.`id` IN (
|
||||||
|
SELECT `ta`.`biz_id`
|
||||||
|
FROM `tag_apply` `ta`
|
||||||
|
WHERE
|
||||||
|
`ta`.`biz_type` = 'GAO_CUSTOMER'
|
||||||
|
AND `ta`.`tag_id` IN
|
||||||
|
<foreach collection="tagIdList" item="tagId" separator="," open="(" close=")">
|
||||||
|
#{tagId}
|
||||||
|
</foreach>
|
||||||
|
AND `ta`.`deleted_at` IS NULL
|
||||||
|
GROUP BY `ta`.`biz_id`
|
||||||
|
HAVING COUNT(DISTINCT `ta`.`tag_id`) = #{tagCount}
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="countByQuery" resultType="long">
|
||||||
|
SELECT COUNT(1)
|
||||||
|
FROM `gao_customer` `c`
|
||||||
|
WHERE
|
||||||
|
<include refid="queryWhere"/>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectByQuery" resultType="com.imyeyu.api.modules.gao.entity.GaoCustomer">
|
||||||
|
SELECT `c`.*
|
||||||
|
FROM `gao_customer` `c`
|
||||||
|
WHERE
|
||||||
|
<include refid="queryWhere"/>
|
||||||
|
ORDER BY `c`.`created_at` DESC, `c`.`id` DESC
|
||||||
|
LIMIT #{offset}, #{limit}
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="stateDailyNewCustomer" resultType="com.imyeyu.api.modules.gao.vo.GaoCustomerDailyStateView">
|
<select id="stateDailyNewCustomer" resultType="com.imyeyu.api.modules.gao.vo.GaoCustomerDailyStateView">
|
||||||
SELECT
|
SELECT
|
||||||
CAST(DATE_FORMAT(FROM_UNIXTIME(`created_at` / 1000), '%Y%m%d') AS UNSIGNED) AS `dateValue`,
|
CAST(DATE_FORMAT(FROM_UNIXTIME(`created_at` / 1000), '%Y%m%d') AS UNSIGNED) AS `dateValue`,
|
||||||
|
|||||||
Reference in New Issue
Block a user