diff --git a/pom.xml b/pom.xml
index a8268e9..2c8c326 100644
--- a/pom.xml
+++ b/pom.xml
@@ -11,7 +11,7 @@
com.imyeyu.timiserverapi
TimiServerAPI
- 1.0.22
+ 1.0.23
jar
TimiServerAPI
imyeyu.com API
diff --git a/src/main/java/com/imyeyu/api/modules/common/service/TagService.java b/src/main/java/com/imyeyu/api/modules/common/service/TagService.java
index d0744a4..80c3baf 100644
--- a/src/main/java/com/imyeyu/api/modules/common/service/TagService.java
+++ b/src/main/java/com/imyeyu/api/modules/common/service/TagService.java
@@ -39,4 +39,10 @@ public interface TagService extends BaseService {
/// @param bizId 业务 ID
/// @param tagIdList 标签 ID 列表
void apply(TagApply.BizType bizType, String bizId, List tagIdList);
+
+ /// 删除指定归属下的全部标签
+ ///
+ /// @param ownerType 归属类型
+ /// @param ownerId 归属 ID
+ void deleteByOwner(Tag.OwnerType ownerType, String ownerId);
}
diff --git a/src/main/java/com/imyeyu/api/modules/common/service/implement/TagServiceImplement.java b/src/main/java/com/imyeyu/api/modules/common/service/implement/TagServiceImplement.java
index 349434d..de128f4 100644
--- a/src/main/java/com/imyeyu/api/modules/common/service/implement/TagServiceImplement.java
+++ b/src/main/java/com/imyeyu/api/modules/common/service/implement/TagServiceImplement.java
@@ -1,5 +1,6 @@
package com.imyeyu.api.modules.common.service.implement;
+import com.imyeyu.api.config.dbsource.TimiServerDBConfig;
import com.imyeyu.api.modules.common.entity.Tag;
import com.imyeyu.api.modules.common.entity.TagApply;
import com.imyeyu.api.modules.common.mapper.TagApplyMapper;
@@ -14,6 +15,7 @@ import com.imyeyu.spring.service.AbstractEntityService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
import java.util.Collection;
import java.util.HashSet;
@@ -104,6 +106,19 @@ public class TagServiceImplement extends AbstractEntityService impl
}
}
+ @Transactional(TimiServerDBConfig.ROLLBACKER)
+ @Override
+ public void deleteByOwner(Tag.OwnerType ownerType, String ownerId) {
+ TimiException.required(ownerType, "not found ownerType");
+ TimiException.required(ownerId, "not found ownerId");
+ Tag example = new Tag();
+ example.setOwnerType(ownerType);
+ example.setOwnerId(ownerId);
+ for (Tag tag : mapper.selectAllByExample(example)) {
+ super.delete(tag.getId());
+ }
+ }
+
private List listApply(TagApply.BizType bizType, String bizId) {
TimiException.required(bizType, "not found bizType");
TimiException.required(bizId, "not found bizId");
diff --git a/src/main/java/com/imyeyu/api/modules/gao/controller/GaoPointAccountController.java b/src/main/java/com/imyeyu/api/modules/gao/controller/GaoPointAccountController.java
index 537e0a1..ef977ac 100644
--- a/src/main/java/com/imyeyu/api/modules/gao/controller/GaoPointAccountController.java
+++ b/src/main/java/com/imyeyu/api/modules/gao/controller/GaoPointAccountController.java
@@ -7,11 +7,15 @@ import com.imyeyu.api.modules.gao.bean.GaoRoleCode;
import com.imyeyu.api.modules.gao.entity.GaoPointAccount;
import com.imyeyu.api.modules.gao.service.GaoPointAccountService;
import com.imyeyu.api.modules.gao.service.GaoStoreService;
+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.spring.annotation.AOPLog;
import com.imyeyu.spring.annotation.RequestRateLimit;
+import com.imyeyu.spring.bean.PageResult;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@@ -32,12 +36,30 @@ public class GaoPointAccountController {
@AOPLog
@RequestRateLimit
@RequireGaoPermission(GaoPermissionCode.POINT_ACCOUNT_READ)
- @PostMapping("/account/detail")
+ @PostMapping("/account/list")
+ public PageResult list(@RequestBody GaoPointAccountPage page) {
+ TimiException.required(page, "not found page");
+ page.setStoreId(resolveStoreId(page.getStoreId()));
+ return accountService.pageByQuery(page);
+ }
+
+ @AOPLog
+ @RequestRateLimit
+ @RequireGaoPermission(GaoPermissionCode.POINT_ACCOUNT_READ)
+ @PostMapping("/account/detail/customer")
public GaoPointAccount detail(@RequestParam String customerId, @RequestParam(required = false) String storeId) {
storeId = resolveStoreId(storeId);
return accountService.getByCustomerId(storeId, customerId);
}
+ @AOPLog
+ @RequestRateLimit
+ @RequireGaoPermission(GaoPermissionCode.POINT_ACCOUNT_READ)
+ @PostMapping("/account/detail")
+ public GaoPointAccount detailById(@RequestParam String id, @RequestParam(required = false) String storeId) {
+ return accountService.getByIdAndStoreId(resolveStoreId(storeId), id);
+ }
+
private String resolveStoreId(String requestedStoreId) {
if (roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name())) {
return requestedStoreId;
diff --git a/src/main/java/com/imyeyu/api/modules/gao/entity/GaoPointAccount.java b/src/main/java/com/imyeyu/api/modules/gao/entity/GaoPointAccount.java
index 87c06eb..f3c8320 100644
--- a/src/main/java/com/imyeyu/api/modules/gao/entity/GaoPointAccount.java
+++ b/src/main/java/com/imyeyu/api/modules/gao/entity/GaoPointAccount.java
@@ -1,5 +1,6 @@
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;
@@ -24,6 +25,9 @@ public class GaoPointAccount extends UUIDEntity {
/// 累计获得积分
private Long totalEarned;
+ /// 累计消耗积分
+ private Long totalConsumed;
+
/// 累计撤销积分
private Long totalRevoked;
@@ -32,4 +36,8 @@ public class GaoPointAccount extends UUIDEntity {
/// 乐观锁版本
private Long version;
+
+ /// 客户信息
+ @Transient
+ private GaoCustomer customer;
}
diff --git a/src/main/java/com/imyeyu/api/modules/gao/mapper/GaoPointAccountMapper.java b/src/main/java/com/imyeyu/api/modules/gao/mapper/GaoPointAccountMapper.java
index 4392dc3..e5d1edd 100644
--- a/src/main/java/com/imyeyu/api/modules/gao/mapper/GaoPointAccountMapper.java
+++ b/src/main/java/com/imyeyu/api/modules/gao/mapper/GaoPointAccountMapper.java
@@ -1,9 +1,12 @@
package com.imyeyu.api.modules.gao.mapper;
import com.imyeyu.api.modules.gao.entity.GaoPointAccount;
+import com.imyeyu.api.modules.gao.vo.GaoPointAccountPage;
import com.imyeyu.spring.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
+import java.util.List;
+
/// GAO 客户积分账户 Mapper
///
/// @author Codex
@@ -17,6 +20,25 @@ public interface GaoPointAccountMapper extends BaseMapper selectByQuery(GaoPointAccountPage page);
+
/// 创建客户积分账户,已存在时保持原账户不变
///
/// @param account 积分账户
@@ -33,9 +55,10 @@ public interface GaoPointAccountMapper extends BaseMapper {
List listByIdList(Collection idList);
+ /// 删除门店下的全部客户及其关联业务数据
+ ///
+ /// @param storeId 门店 ID
+ void deleteByStoreId(String storeId);
+
default Map mapByIdList(Collection idList) {
return listByIdList(idList).stream().collect(Collectors.toMap(GaoCustomer::getId, item -> item));
}
diff --git a/src/main/java/com/imyeyu/api/modules/gao/service/GaoEventService.java b/src/main/java/com/imyeyu/api/modules/gao/service/GaoEventService.java
index 6331a21..c008fb9 100644
--- a/src/main/java/com/imyeyu/api/modules/gao/service/GaoEventService.java
+++ b/src/main/java/com/imyeyu/api/modules/gao/service/GaoEventService.java
@@ -24,6 +24,11 @@ public interface GaoEventService extends BaseService {
/// @return 登记事件列表
List listValid(String storeId);
+ /// 删除门店下的全部登记事件及角色关联
+ ///
+ /// @param storeId 门店 ID
+ void deleteByStoreId(String storeId);
+
/// 查询登记事件要求的角色
///
/// @param eventId 登记事件 ID
diff --git a/src/main/java/com/imyeyu/api/modules/gao/service/GaoPointAccountService.java b/src/main/java/com/imyeyu/api/modules/gao/service/GaoPointAccountService.java
index c824b8a..ac71d39 100644
--- a/src/main/java/com/imyeyu/api/modules/gao/service/GaoPointAccountService.java
+++ b/src/main/java/com/imyeyu/api/modules/gao/service/GaoPointAccountService.java
@@ -1,6 +1,8 @@
package com.imyeyu.api.modules.gao.service;
import com.imyeyu.api.modules.gao.entity.GaoPointAccount;
+import com.imyeyu.api.modules.gao.vo.GaoPointAccountPage;
+import com.imyeyu.spring.bean.PageResult;
import com.imyeyu.spring.service.BaseService;
/// GAO 客户积分账户服务
@@ -9,6 +11,12 @@ import com.imyeyu.spring.service.BaseService;
/// @since 2026-08-11
public interface GaoPointAccountService extends BaseService {
+ /// 分页查询积分账户
+ ///
+ /// @param page 查询条件
+ /// @return 账户分页
+ PageResult pageByQuery(GaoPointAccountPage page);
+
/// 查询客户当前有效积分账户
///
/// @param storeId 门店 ID
@@ -16,6 +24,18 @@ public interface GaoPointAccountService extends BaseService {
/// @return 规则列表
List listByIdList(List idList);
+ /// 删除门店下的全部积分规则
+ ///
+ /// @param storeId 门店 ID
+ void deleteByStoreId(String storeId);
+
/// 按客户端提交的顺序更新启用规则优先级
///
/// @param idList 规则 ID 列表
diff --git a/src/main/java/com/imyeyu/api/modules/gao/service/GaoStoreBusinessDayService.java b/src/main/java/com/imyeyu/api/modules/gao/service/GaoStoreBusinessDayService.java
index a64f449..1ff48b0 100644
--- a/src/main/java/com/imyeyu/api/modules/gao/service/GaoStoreBusinessDayService.java
+++ b/src/main/java/com/imyeyu/api/modules/gao/service/GaoStoreBusinessDayService.java
@@ -36,4 +36,9 @@ public interface GaoStoreBusinessDayService extends BaseService listByDateRange(String storeId, Integer beginDateValue, Integer endDateValue);
+
+ /// 删除门店下的全部营业日
+ ///
+ /// @param storeId 门店 ID
+ void deleteByStoreId(String storeId);
}
diff --git a/src/main/java/com/imyeyu/api/modules/gao/service/GaoUserService.java b/src/main/java/com/imyeyu/api/modules/gao/service/GaoUserService.java
index b3de23b..61a7da2 100644
--- a/src/main/java/com/imyeyu/api/modules/gao/service/GaoUserService.java
+++ b/src/main/java/com/imyeyu/api/modules/gao/service/GaoUserService.java
@@ -10,6 +10,11 @@ import com.imyeyu.spring.service.BaseService;
/// @since 2026-07-30
public interface GaoUserService extends BaseService {
+ /// 删除门店下的全部 GAO 用户关系,不删除核心用户
+ ///
+ /// @param storeId 门店 ID
+ void deleteByStoreId(String storeId);
+
/// 调整 GAO 用户所属门店
///
/// @param gaoUser GAO 用户,必须包含 ID 和目标门店 ID
diff --git a/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoCustomerServiceImplement.java b/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoCustomerServiceImplement.java
index 064dc6c..98ad6d5 100644
--- a/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoCustomerServiceImplement.java
+++ b/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoCustomerServiceImplement.java
@@ -252,6 +252,17 @@ public class GaoCustomerServiceImplement extends AbstractEntityService mapByIdList(Collection idList) {
return mapper.selectByIdList(new HashSet<>(idList)).stream().collect(Collectors.toMap(GaoEvent::getId, Function.identity()));
diff --git a/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoPointAccountServiceImplement.java b/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoPointAccountServiceImplement.java
index 734dc9c..c1579ea 100644
--- a/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoPointAccountServiceImplement.java
+++ b/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoPointAccountServiceImplement.java
@@ -1,10 +1,16 @@
package com.imyeyu.api.modules.gao.service.implement;
import com.imyeyu.api.config.dbsource.TimiServerDBConfig;
+import com.imyeyu.api.modules.common.entity.Attachment;
+import com.imyeyu.api.modules.common.service.AttachmentService;
+import com.imyeyu.api.modules.gao.entity.GaoCustomer;
import com.imyeyu.api.modules.gao.entity.GaoPointAccount;
+import com.imyeyu.api.modules.gao.mapper.GaoCustomerMapper;
import com.imyeyu.api.modules.gao.mapper.GaoPointAccountMapper;
import com.imyeyu.api.modules.gao.service.GaoPointAccountService;
+import com.imyeyu.api.modules.gao.vo.GaoPointAccountPage;
import com.imyeyu.java.bean.timi.TimiException;
+import com.imyeyu.spring.bean.PageResult;
import com.imyeyu.spring.mapper.BaseMapper;
import com.imyeyu.spring.service.AbstractEntityService;
import com.imyeyu.utils.Time;
@@ -12,7 +18,10 @@ import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import java.util.List;
+import java.util.Map;
import java.util.UUID;
+import java.util.stream.Collectors;
/// GAO 客户积分账户服务实现
///
@@ -23,12 +32,24 @@ import java.util.UUID;
public class GaoPointAccountServiceImplement extends AbstractEntityService implements GaoPointAccountService {
private final GaoPointAccountMapper mapper;
+ private final GaoCustomerMapper customerMapper;
+ private final AttachmentService attachmentService;
@Override
protected BaseMapper mapper() {
return mapper;
}
+ @Override
+ public PageResult pageByQuery(GaoPointAccountPage page) {
+ TimiException.required(page, "not found page");
+ PageResult result = new PageResult<>();
+ result.setTotal(mapper.countByQuery(page));
+ result.setList(mapper.selectByQuery(page));
+ fillCustomer(result.getList());
+ return result;
+ }
+
@Override
public GaoPointAccount getByCustomerId(String storeId, String customerId) {
TimiException.required(storeId, "not found storeId");
@@ -36,6 +57,50 @@ public class GaoPointAccountServiceImplement extends AbstractEntityService accountList) {
+ List customerIdList = accountList.stream()
+ .map(GaoPointAccount::getCustomerId)
+ .filter(id -> id != null && !id.isBlank())
+ .distinct()
+ .toList();
+ if (customerIdList.isEmpty()) {
+ return;
+ }
+
+ Map customerMap = customerMapper.selectByIdList(customerIdList).stream()
+ .collect(Collectors.toMap(GaoCustomer::getId, item -> item));
+ Map> attachmentMap = attachmentService.mapByBizIdList(Attachment.BizType.GAO_CUSTOMER, customerIdList);
+ for (GaoPointAccount account : accountList) {
+ GaoCustomer customer = customerMap.get(account.getCustomerId());
+ if (customer == null) {
+ continue;
+ }
+ customer.setAttachmentList(attachmentMap.get(customer.getId()));
+ account.setCustomer(customer);
+ }
+ }
+
@Transactional(TimiServerDBConfig.ROLLBACKER)
@Override
public GaoPointAccount getOrCreateForUpdate(String storeId, String customerId) {
@@ -50,6 +115,7 @@ public class GaoPointAccountServiceImplement extends AbstractEntityService(idList));
}
+ @Transactional(TimiServerDBConfig.ROLLBACKER)
+ @Override
+ public void deleteByStoreId(String storeId) {
+ TimiException.required(storeId, "not found storeId");
+ GaoPointRule example = new GaoPointRule();
+ example.setStoreId(storeId);
+ for (GaoPointRule rule : mapper.selectAllByExample(example)) {
+ delete(rule.getId());
+ }
+ }
+
@Transactional(TimiServerDBConfig.ROLLBACKER)
@Override
public void sort(List idList) {
diff --git a/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoStoreBusinessDayServiceImplement.java b/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoStoreBusinessDayServiceImplement.java
index 6bc2f4b..4f289af 100644
--- a/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoStoreBusinessDayServiceImplement.java
+++ b/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoStoreBusinessDayServiceImplement.java
@@ -71,6 +71,16 @@ public class GaoStoreBusinessDayServiceImplement extends AbstractEntityService directRoleIdList = userRoleService.listRoleByUserId(ModuleCode.GAO, inviterUserId)
- .stream()
- .map(Role::getId)
- .toList();
boolean adminInviteGlobalManager = isCoreAdmin() && isGlobalManagerRole(role);
- boolean descendant = adminInviteGlobalManager || (authorizationScopeService.listManageableRole(inviterUserId, ModuleCode.GAO)
+ boolean descendant = adminInviteGlobalManager || authorizationScopeService.listManageableRole(inviterUserId, ModuleCode.GAO)
.stream()
- .anyMatch(item -> role.getId().equals(item.getId()))
- && !directRoleIdList.contains(role.getId()));
+ .anyMatch(item -> role.getId().equals(item.getId()));
if (!descendant) {
throw new TimiException(TimiCode.PERMISSION_ERROR, "角色不在可邀请范围内");
}
diff --git a/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoUserServiceImplement.java b/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoUserServiceImplement.java
index 44b42bd..6ce98b7 100644
--- a/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoUserServiceImplement.java
+++ b/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoUserServiceImplement.java
@@ -40,6 +40,17 @@ public class GaoUserServiceImplement extends AbstractEntityService
+
+
+
+ `a`.`deleted_at` IS NULL
+ AND `c`.`deleted_at` IS NULL
+
+ AND `a`.`store_id` = #{storeId}
+
+
+ AND (
+ `c`.`code` LIKE CONCAT('%', #{keyword}, '%')
+ OR `c`.`name` LIKE CONCAT('%', #{keyword}, '%')
+ OR `c`.`telephone` LIKE CONCAT('%', #{keyword}, '%')
+ OR `c`.`name_pinyin_full` LIKE CONCAT(#{keyword}, '%')
+ OR `c`.`name_pinyin_initial` LIKE CONCAT(#{keyword}, '%')
+ OR `c`.`name_pinyin_mixed` LIKE CONCAT(#{keyword}, '%')
+ )
+
+
+
+
+
+
+
INSERT INTO `gao_point_account` (
- `id`, `store_id`, `customer_id`, `balance`, `total_earned`, `total_revoked`, `total_adjusted`, `version`, `created_at`, `updated_at`, `deleted_at`
+ `id`, `store_id`, `customer_id`, `balance`, `total_earned`, `total_consumed`, `total_revoked`, `total_adjusted`, `version`, `created_at`, `updated_at`, `deleted_at`
) VALUES (
- #{account.id}, #{account.storeId}, #{account.customerId}, #{account.balance}, #{account.totalEarned}, #{account.totalRevoked}, #{account.totalAdjusted}, #{account.version}, #{account.createdAt}, #{account.updatedAt}, #{account.deletedAt}
+ #{account.id}, #{account.storeId}, #{account.customerId}, #{account.balance}, #{account.totalEarned}, #{account.totalConsumed}, #{account.totalRevoked}, #{account.totalAdjusted}, #{account.version}, #{account.createdAt}, #{account.updatedAt}, #{account.deletedAt}
)
ON DUPLICATE KEY UPDATE `id` = `id`
@@ -33,6 +80,7 @@
SET
`balance` = `balance` + #{delta},
`total_earned` = `total_earned` + #{totalEarnedDelta},
+ `total_consumed` = `total_consumed` + #{totalConsumedDelta},
`total_revoked` = `total_revoked` + #{totalRevokedDelta},
`total_adjusted` = `total_adjusted` + #{totalAdjustedDelta},
`version` = `version` + 1,