update store delete
This commit is contained in:
@@ -39,4 +39,10 @@ public interface TagService extends BaseService<Tag, String> {
|
|||||||
/// @param bizId 业务 ID
|
/// @param bizId 业务 ID
|
||||||
/// @param tagIdList 标签 ID 列表
|
/// @param tagIdList 标签 ID 列表
|
||||||
void apply(TagApply.BizType bizType, String bizId, List<String> tagIdList);
|
void apply(TagApply.BizType bizType, String bizId, List<String> tagIdList);
|
||||||
|
|
||||||
|
/// 删除指定归属下的全部标签
|
||||||
|
///
|
||||||
|
/// @param ownerType 归属类型
|
||||||
|
/// @param ownerId 归属 ID
|
||||||
|
void deleteByOwner(Tag.OwnerType ownerType, String ownerId);
|
||||||
}
|
}
|
||||||
|
|||||||
+15
@@ -1,5 +1,6 @@
|
|||||||
package com.imyeyu.api.modules.common.service.implement;
|
package com.imyeyu.api.modules.common.service.implement;
|
||||||
|
|
||||||
|
import com.imyeyu.api.config.dbsource.TimiServerDBConfig;
|
||||||
import com.imyeyu.api.modules.common.entity.Tag;
|
import com.imyeyu.api.modules.common.entity.Tag;
|
||||||
import com.imyeyu.api.modules.common.entity.TagApply;
|
import com.imyeyu.api.modules.common.entity.TagApply;
|
||||||
import com.imyeyu.api.modules.common.mapper.TagApplyMapper;
|
import com.imyeyu.api.modules.common.mapper.TagApplyMapper;
|
||||||
@@ -14,6 +15,7 @@ import com.imyeyu.spring.service.AbstractEntityService;
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@@ -104,6 +106,19 @@ public class TagServiceImplement extends AbstractEntityService<Tag, String> 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<TagApply> listApply(TagApply.BizType bizType, String bizId) {
|
private List<TagApply> listApply(TagApply.BizType bizType, String bizId) {
|
||||||
TimiException.required(bizType, "not found bizType");
|
TimiException.required(bizType, "not found bizType");
|
||||||
TimiException.required(bizId, "not found bizId");
|
TimiException.required(bizId, "not found bizId");
|
||||||
|
|||||||
@@ -45,6 +45,11 @@ public interface GaoCustomerService extends BaseService<GaoCustomer, String> {
|
|||||||
|
|
||||||
List<GaoCustomer> listByIdList(Collection<String> idList);
|
List<GaoCustomer> listByIdList(Collection<String> idList);
|
||||||
|
|
||||||
|
/// 删除门店下的全部客户及其关联业务数据
|
||||||
|
///
|
||||||
|
/// @param storeId 门店 ID
|
||||||
|
void deleteByStoreId(String storeId);
|
||||||
|
|
||||||
default Map<String, GaoCustomer> mapByIdList(Collection<String> idList) {
|
default Map<String, GaoCustomer> mapByIdList(Collection<String> idList) {
|
||||||
return listByIdList(idList).stream().collect(Collectors.toMap(GaoCustomer::getId, item -> item));
|
return listByIdList(idList).stream().collect(Collectors.toMap(GaoCustomer::getId, item -> item));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,11 @@ public interface GaoEventService extends BaseService<GaoEvent, String> {
|
|||||||
/// @return 登记事件列表
|
/// @return 登记事件列表
|
||||||
List<GaoEvent> listValid(String storeId);
|
List<GaoEvent> listValid(String storeId);
|
||||||
|
|
||||||
|
/// 删除门店下的全部登记事件及角色关联
|
||||||
|
///
|
||||||
|
/// @param storeId 门店 ID
|
||||||
|
void deleteByStoreId(String storeId);
|
||||||
|
|
||||||
/// 查询登记事件要求的角色
|
/// 查询登记事件要求的角色
|
||||||
///
|
///
|
||||||
/// @param eventId 登记事件 ID
|
/// @param eventId 登记事件 ID
|
||||||
|
|||||||
@@ -31,6 +31,11 @@ public interface GaoPointAccountService extends BaseService<GaoPointAccount, Str
|
|||||||
/// @return 积分账户,不存在时返回 null
|
/// @return 积分账户,不存在时返回 null
|
||||||
GaoPointAccount getByIdAndStoreId(String storeId, String id);
|
GaoPointAccount getByIdAndStoreId(String storeId, String id);
|
||||||
|
|
||||||
|
/// 删除门店下的全部积分账户
|
||||||
|
///
|
||||||
|
/// @param storeId 门店 ID
|
||||||
|
void deleteByStoreId(String storeId);
|
||||||
|
|
||||||
/// 获取并锁定客户积分账户,不存在时创建
|
/// 获取并锁定客户积分账户,不存在时创建
|
||||||
///
|
///
|
||||||
/// @param storeId 门店 ID
|
/// @param storeId 门店 ID
|
||||||
|
|||||||
@@ -25,6 +25,11 @@ public interface GaoPointRuleService extends BaseService<GaoPointRule, String> {
|
|||||||
/// @return 规则列表
|
/// @return 规则列表
|
||||||
List<GaoPointRule> listByIdList(List<String> idList);
|
List<GaoPointRule> listByIdList(List<String> idList);
|
||||||
|
|
||||||
|
/// 删除门店下的全部积分规则
|
||||||
|
///
|
||||||
|
/// @param storeId 门店 ID
|
||||||
|
void deleteByStoreId(String storeId);
|
||||||
|
|
||||||
/// 按客户端提交的顺序更新启用规则优先级
|
/// 按客户端提交的顺序更新启用规则优先级
|
||||||
///
|
///
|
||||||
/// @param idList 规则 ID 列表
|
/// @param idList 规则 ID 列表
|
||||||
|
|||||||
@@ -36,4 +36,9 @@ public interface GaoStoreBusinessDayService extends BaseService<GaoStoreBusiness
|
|||||||
/// @param endDateValue 结束日期值,格式为 yyyyMMdd
|
/// @param endDateValue 结束日期值,格式为 yyyyMMdd
|
||||||
/// @return 营业日列表
|
/// @return 营业日列表
|
||||||
java.util.List<GaoStoreBusinessDay> listByDateRange(String storeId, Integer beginDateValue, Integer endDateValue);
|
java.util.List<GaoStoreBusinessDay> listByDateRange(String storeId, Integer beginDateValue, Integer endDateValue);
|
||||||
|
|
||||||
|
/// 删除门店下的全部营业日
|
||||||
|
///
|
||||||
|
/// @param storeId 门店 ID
|
||||||
|
void deleteByStoreId(String storeId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,11 @@ import com.imyeyu.spring.service.BaseService;
|
|||||||
/// @since 2026-07-30
|
/// @since 2026-07-30
|
||||||
public interface GaoUserService extends BaseService<GaoUser, String> {
|
public interface GaoUserService extends BaseService<GaoUser, String> {
|
||||||
|
|
||||||
|
/// 删除门店下的全部 GAO 用户关系,不删除核心用户
|
||||||
|
///
|
||||||
|
/// @param storeId 门店 ID
|
||||||
|
void deleteByStoreId(String storeId);
|
||||||
|
|
||||||
/// 调整 GAO 用户所属门店
|
/// 调整 GAO 用户所属门店
|
||||||
///
|
///
|
||||||
/// @param gaoUser GAO 用户,必须包含 ID 和目标门店 ID
|
/// @param gaoUser GAO 用户,必须包含 ID 和目标门店 ID
|
||||||
|
|||||||
+11
@@ -252,6 +252,17 @@ public class GaoCustomerServiceImplement extends AbstractEntityService<GaoCustom
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||||
|
@Override
|
||||||
|
public void deleteByStoreId(String storeId) {
|
||||||
|
TimiException.required(storeId, "not found storeId");
|
||||||
|
GaoCustomer example = new GaoCustomer();
|
||||||
|
example.setStoreId(storeId);
|
||||||
|
for (GaoCustomer customer : mapper.selectAllByExample(example)) {
|
||||||
|
delete(customer.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||||
@Override
|
@Override
|
||||||
public void updateWithAttachment(GaoCustomer customer) {
|
public void updateWithAttachment(GaoCustomer customer) {
|
||||||
|
|||||||
+14
@@ -172,6 +172,20 @@ public class GaoEventServiceImplement extends AbstractEntityService<GaoEvent, St
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||||
|
@Override
|
||||||
|
public void deleteByStoreId(String storeId) {
|
||||||
|
TimiException.required(storeId, "not found storeId");
|
||||||
|
GaoEvent example = new GaoEvent();
|
||||||
|
example.setStoreId(storeId);
|
||||||
|
for (GaoEvent event : mapper.selectAllByExample(example)) {
|
||||||
|
GaoEventRoleRelation relationExample = new GaoEventRoleRelation();
|
||||||
|
relationExample.setEventId(event.getId());
|
||||||
|
roleRelationMapper.deleteAllByExample(relationExample);
|
||||||
|
delete(event.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, GaoEvent> mapByIdList(Collection<String> idList) {
|
public Map<String, GaoEvent> mapByIdList(Collection<String> idList) {
|
||||||
return mapper.selectByIdList(new HashSet<>(idList)).stream().collect(Collectors.toMap(GaoEvent::getId, Function.identity()));
|
return mapper.selectByIdList(new HashSet<>(idList)).stream().collect(Collectors.toMap(GaoEvent::getId, Function.identity()));
|
||||||
|
|||||||
+11
@@ -67,6 +67,17 @@ public class GaoPointAccountServiceImplement extends AbstractEntityService<GaoPo
|
|||||||
return account;
|
return account;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||||
|
@Override
|
||||||
|
public void deleteByStoreId(String storeId) {
|
||||||
|
TimiException.required(storeId, "not found storeId");
|
||||||
|
GaoPointAccount example = new GaoPointAccount();
|
||||||
|
example.setStoreId(storeId);
|
||||||
|
for (GaoPointAccount account : mapper.selectAllByExample(example)) {
|
||||||
|
super.delete(account.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void fillCustomer(List<GaoPointAccount> accountList) {
|
private void fillCustomer(List<GaoPointAccount> accountList) {
|
||||||
List<String> customerIdList = accountList.stream()
|
List<String> customerIdList = accountList.stream()
|
||||||
.map(GaoPointAccount::getCustomerId)
|
.map(GaoPointAccount::getCustomerId)
|
||||||
|
|||||||
+11
@@ -55,6 +55,17 @@ public class GaoPointRuleServiceImplement extends AbstractEntityService<GaoPoint
|
|||||||
return mapper.selectByIdList(new LinkedHashSet<>(idList));
|
return mapper.selectByIdList(new LinkedHashSet<>(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)
|
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||||
@Override
|
@Override
|
||||||
public void sort(List<String> idList) {
|
public void sort(List<String> idList) {
|
||||||
|
|||||||
+10
@@ -71,6 +71,16 @@ public class GaoStoreBusinessDayServiceImplement extends AbstractEntityService<G
|
|||||||
rebuildBusinessDayNo(businessDay.getStoreId(), businessDay.getDateValue());
|
rebuildBusinessDayNo(businessDay.getStoreId(), businessDay.getDateValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||||
|
@Override
|
||||||
|
public void deleteByStoreId(String storeId) {
|
||||||
|
TimiException.required(storeId, "not found storeId");
|
||||||
|
GaoStoreBusinessDay example = new GaoStoreBusinessDay();
|
||||||
|
example.setStoreId(storeId);
|
||||||
|
// 门店整体删除后不再需要重算营业日序号
|
||||||
|
mapper.deleteAllByExample(example);
|
||||||
|
}
|
||||||
|
|
||||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||||
@Override
|
@Override
|
||||||
public GaoStoreBusinessDay resolveOpenBusinessDay(String storeId, Integer dateValue) {
|
public GaoStoreBusinessDay resolveOpenBusinessDay(String storeId, Integer dateValue) {
|
||||||
|
|||||||
+72
@@ -2,9 +2,17 @@ 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.common.entity.Tag;
|
||||||
|
import com.imyeyu.api.modules.common.service.TagService;
|
||||||
import com.imyeyu.api.modules.gao.entity.GaoStore;
|
import com.imyeyu.api.modules.gao.entity.GaoStore;
|
||||||
import com.imyeyu.api.modules.gao.mapper.GaoStoreMapper;
|
import com.imyeyu.api.modules.gao.mapper.GaoStoreMapper;
|
||||||
|
import com.imyeyu.api.modules.gao.service.GaoCustomerService;
|
||||||
|
import com.imyeyu.api.modules.gao.service.GaoEventService;
|
||||||
|
import com.imyeyu.api.modules.gao.service.GaoPointAccountService;
|
||||||
|
import com.imyeyu.api.modules.gao.service.GaoPointRuleService;
|
||||||
|
import com.imyeyu.api.modules.gao.service.GaoStoreBusinessDayService;
|
||||||
import com.imyeyu.api.modules.gao.service.GaoStoreService;
|
import com.imyeyu.api.modules.gao.service.GaoStoreService;
|
||||||
|
import com.imyeyu.api.modules.gao.service.GaoUserService;
|
||||||
import com.imyeyu.api.modules.gao.util.StoreXSSFBuilder;
|
import com.imyeyu.api.modules.gao.util.StoreXSSFBuilder;
|
||||||
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;
|
||||||
@@ -41,6 +49,13 @@ public class GaoStoreServiceImplement extends AbstractEntityService<GaoStore, St
|
|||||||
|
|
||||||
private final LoggerService loggerService;
|
private final LoggerService loggerService;
|
||||||
private final UserLoginService userLoginService;
|
private final UserLoginService userLoginService;
|
||||||
|
private final GaoCustomerService customerService;
|
||||||
|
private final GaoEventService eventService;
|
||||||
|
private final GaoPointAccountService pointAccountService;
|
||||||
|
private final GaoPointRuleService pointRuleService;
|
||||||
|
private final GaoStoreBusinessDayService businessDayService;
|
||||||
|
private final GaoUserService gaoUserService;
|
||||||
|
private final TagService tagService;
|
||||||
|
|
||||||
private final GaoStoreMapper mapper;
|
private final GaoStoreMapper mapper;
|
||||||
private final StoreXSSFBuilder storeXSSFBuilder;
|
private final StoreXSSFBuilder storeXSSFBuilder;
|
||||||
@@ -116,6 +131,14 @@ public class GaoStoreServiceImplement extends AbstractEntityService<GaoStore, St
|
|||||||
try {
|
try {
|
||||||
logger.setContent(id);
|
logger.setContent(id);
|
||||||
GaoStore store = get(id);
|
GaoStore store = get(id);
|
||||||
|
TimiException.required(store, "not found store");
|
||||||
|
deleteCustomers(store.getId());
|
||||||
|
deletePointRules(store.getId());
|
||||||
|
deleteEvents(store.getId());
|
||||||
|
deleteBusinessDays(store.getId());
|
||||||
|
deleteGaoUsers(store.getId());
|
||||||
|
deletePointAccounts(store.getId());
|
||||||
|
deleteStoreTags(store.getId());
|
||||||
store.setStatus(GaoStore.Status.DELETED);
|
store.setStatus(GaoStore.Status.DELETED);
|
||||||
super.update(store);
|
super.update(store);
|
||||||
super.delete(id);
|
super.delete(id);
|
||||||
@@ -135,6 +158,55 @@ public class GaoStoreServiceImplement extends AbstractEntityService<GaoStore, St
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 删除门店客户及其登记、积分账户、客户标签和附件
|
||||||
|
///
|
||||||
|
/// @param storeId 门店 ID
|
||||||
|
private void deleteCustomers(String storeId) {
|
||||||
|
customerService.deleteByStoreId(storeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 删除门店积分规则
|
||||||
|
///
|
||||||
|
/// @param storeId 门店 ID
|
||||||
|
private void deletePointRules(String storeId) {
|
||||||
|
pointRuleService.deleteByStoreId(storeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 删除门店登记事件及角色关联
|
||||||
|
///
|
||||||
|
/// @param storeId 门店 ID
|
||||||
|
private void deleteEvents(String storeId) {
|
||||||
|
eventService.deleteByStoreId(storeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 删除门店营业日
|
||||||
|
///
|
||||||
|
/// @param storeId 门店 ID
|
||||||
|
private void deleteBusinessDays(String storeId) {
|
||||||
|
businessDayService.deleteByStoreId(storeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 删除门店用户关系,不删除核心用户
|
||||||
|
///
|
||||||
|
/// @param storeId 门店 ID
|
||||||
|
private void deleteGaoUsers(String storeId) {
|
||||||
|
gaoUserService.deleteByStoreId(storeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 清理门店下未被客户删除逻辑覆盖的积分账户
|
||||||
|
///
|
||||||
|
/// @param storeId 门店 ID
|
||||||
|
private void deletePointAccounts(String storeId) {
|
||||||
|
pointAccountService.deleteByStoreId(storeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 删除门店自有标签,客户标签应用由客户删除逻辑处理
|
||||||
|
///
|
||||||
|
/// @param storeId 门店 ID
|
||||||
|
private void deleteStoreTags(String storeId) {
|
||||||
|
tagService.deleteByOwner(Tag.OwnerType.GAO_STORE, storeId);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GaoStore getByUserId(String userId) {
|
public GaoStore getByUserId(String userId) {
|
||||||
TimiException.required(userId, "not found userId");
|
TimiException.required(userId, "not found userId");
|
||||||
|
|||||||
+11
@@ -40,6 +40,17 @@ public class GaoUserServiceImplement extends AbstractEntityService<GaoUser, Stri
|
|||||||
return mapper;
|
return mapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||||
|
@Override
|
||||||
|
public void deleteByStoreId(String storeId) {
|
||||||
|
TimiException.required(storeId, "not found storeId");
|
||||||
|
GaoUser example = new GaoUser();
|
||||||
|
example.setStoreId(storeId);
|
||||||
|
for (GaoUser gaoUser : mapper.selectAllByExample(example)) {
|
||||||
|
super.delete(gaoUser.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||||
@Override
|
@Override
|
||||||
public void create(GaoUser gaoUser) {
|
public void create(GaoUser gaoUser) {
|
||||||
|
|||||||
Reference in New Issue
Block a user