Commit 14e65c11 by guojuxing

门店分组

parent bdd10c81
......@@ -110,8 +110,7 @@ public class StoreGroupApiServiceImpl implements StoreGroupApiService{
}
int storeGroupId = storeGroupDTO.getStoreGroupId();
TabStoreGroup oldStoreGroup = validIsDefault(storeGroupId);
if (storeGroupDTO.getGroupLevel() != StoreGroupConstant.FIRST_STORE_GROUP_LEVEL) {
//如果不是第一级,则可能有上级分组修改
if (oldStoreGroup.getGroupLevel() != StoreGroupConstant.FIRST_STORE_GROUP_LEVEL) {
if (storeGroupDTO.getParentStoreGroupId() == null) {
throw new StoreGroupException(StoreGroupErrorEnum.ParentStoreGroupParamError.getCode(), StoreGroupErrorEnum.ParentStoreGroupParamError.getMessage());
}
......@@ -119,6 +118,15 @@ public class StoreGroupApiServiceImpl implements StoreGroupApiService{
int oldStoreGroupParentId = oldStoreGroup.getParentStoreGroupId();
boolean hasEditParentId = storeGroupParentId != oldStoreGroupParentId;
if (hasEditParentId) {
//验证父级ID的层级和当前层级是否相差一,如果是,则正确,否则,数据异常
TabStoreGroup parentStoreGroup = tabStoreGroupMapper.selectByPrimaryKey(storeGroupParentId);
if (parentStoreGroup == null) {
throw new StoreGroupException(StoreGroupErrorEnum.ParentStoreGroupParamError.getCode(), "父级ID数据错误,查询不到数据");
}
if (oldStoreGroup.getGroupLevel() - parentStoreGroup.getGroupLevel() != 1) {
throw new StoreGroupException(StoreGroupErrorEnum.ParentStoreGroupParamError.getCode(), "父级ID数据错误,不是当前的上级层级");
}
//如果修改了上级分组,则该分组下的所有子级分组都需要修改分组链数据
tabStoreGroupMapper.updateStoreGroupChainByStoreGroupId(storeGroupId, oldStoreGroupParentId, storeGroupParentId);
......@@ -134,7 +142,7 @@ public class StoreGroupApiServiceImpl implements StoreGroupApiService{
StoreGroupDTO noStoreGroup = new StoreGroupDTO();
noStoreGroup.setEnterpriseId(storeGroupDTO.getEnterpriseId());
noStoreGroup.setGroupLevel(oldStoreGroup.getGroupLevel());
noStoreGroup.setStoreGroupName("未分组门店");
noStoreGroup.setStoreGroupName("未分组门店" + System.currentTimeMillis());
noStoreGroup.setParentStoreGroupId(storeGroupParentId);
int noStoreGroupId = save(noStoreGroup);
//转移门店
......
......@@ -48,6 +48,7 @@ public class StoreGroupQO implements Serializable{
/**
* 父级分组id
*/
@NotNull(message = "父级ID不能为空", groups = {EditParentIdValidView.class})
private Integer parentStoreGroupId;
/**
......@@ -58,7 +59,7 @@ public class StoreGroupQO implements Serializable{
/**
* 分组层级
*/
@NotNull(message = "层级不能为空", groups = {SaveValidView.class, EditParentIdValidView.class})
@NotNull(message = "层级不能为空", groups = {SaveValidView.class})
private Integer groupLevel;
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment