Commit 4905d711 by zhiwj

Merge branch 'developer' of http://115.159.76.241/base_platform_enterprise/gic-store into developer

parents ae343d4f 1c128b1f
......@@ -340,4 +340,13 @@ public interface StoreApiService {
* @return
*/
ServiceResponse<Void> saveStoreAndClerkForBulkOrder(String params);
/** @Description: 刷新门店缓存
* @author taogs
* @Date 20:29 2020/3/25
* @Param
* @return
*/
void refreshCache(Integer enterpriseId, Integer storeId);
}
......@@ -35,6 +35,28 @@ public interface StoreGroupApiService {
ServiceResponse<String> update(StoreGroupDTO storeGroupDTO);
/**
* 修改上级分组之前验证,上级分组ID是否是子节点且有门店
* @Title: tipWhenUpdateParentId

* @Description:

* @author guojuxing
* @param parentStoreGroupId

* @return com.gic.api.base.commons.ServiceResponse<java.lang.Boolean>


*/
ServiceResponse<Boolean> tipWhenUpdateParentId(Integer parentStoreGroupId);
/**
* 新增子分组验证,是否是子节点且有门店
* @Title: tipWhenSaveStoreGroup

* @Description:

* @author guojuxing
* @param groupLevel
* @param enterpriseId
* @param parentStoreGroupId

* @return com.gic.api.base.commons.ServiceResponse<java.lang.Boolean>


*/
ServiceResponse<Boolean> tipWhenSaveStoreGroup(Integer groupLevel, Integer enterpriseId, Integer parentStoreGroupId);
/**
* 编辑名称
* @Title: updateStoreGroupName

* @Description:
......
......@@ -146,7 +146,7 @@ public class StoreGroupServiceImpl implements StoreGroupService{
@Override
public boolean isLeafNode(Integer storeGroupId) {
int count = tabStoreGroupMapper.countByParentId(storeGroupId);
if (count > 0) {
if (count > 1) { //新节点已经创建,所以应该大于1
return false;
} else {
return true;
......
......@@ -201,6 +201,12 @@ public class StoreApiServiceImpl implements StoreApiService {
return this.saveOrUpdate(storeDTO);
}
@Override
public void refreshCache(Integer enterpriseId, Integer storeId) {
String key = Constants.STORE_KEY + enterpriseId + ":" + storeId;
RedisUtil.delCache(key);
}
/**
* 修改日志
*/
......@@ -339,11 +345,6 @@ public class StoreApiServiceImpl implements StoreApiService {
return null;
}
private void refreshCache(Integer enterpriseId, Integer storeId) {
String key = Constants.STORE_KEY + enterpriseId + ":" + storeId;
RedisUtil.delCache(key);
}
private void refreshIndex(Integer storeId, Integer enterpriseId) {
this.addStoreToIndex(enterpriseId, storeId);
}
......@@ -1067,6 +1068,7 @@ public class StoreApiServiceImpl implements StoreApiService {
@Override
public ServiceResponse addStoreToIndex(Integer enterpriseId, Integer storeId) {
logger.info("addStoreToIndex:{},{}",enterpriseId,storeId);
this.refreshCache(enterpriseId, storeId);
int logId = this.storeIndexLogService.saveStoreIndexLog(enterpriseId, storeId);
JSONObject json = new JSONObject();
json.put("enterpriseId", enterpriseId);
......
......@@ -53,8 +53,6 @@ public class StoreGroupApiServiceImpl implements StoreGroupApiService {
} else {
return parentIdWhenNew;
}
storeGroupDTO.setCreateTime(new Date());
storeGroupDTO.setUpdateTime(new Date());
storeGroupDTO.setStatus(1);
......@@ -72,8 +70,9 @@ public class StoreGroupApiServiceImpl implements StoreGroupApiService {
storeGroupChain.setStoreGroupId(storeGroupId);
storeGroupChain.setStoreGroupChain(getStoreGroupChain(storeGroupId));
storeGroupService.update(storeGroupChain);
if (isNeedTransferStore(storeGroupDTO)) {
boolean needTransferStore = isNeedTransferStore(storeGroupDTO.getParentStoreGroupId());
logger.info("needTransferStore:{}", needTransferStore);
if (needTransferStore) {
//转移门店
storeService.updateGroupId(storeGroupDTO.getParentStoreGroupId(), storeGroupId);
}
......@@ -99,6 +98,7 @@ public class StoreGroupApiServiceImpl implements StoreGroupApiService {
}
int storeGroupId = storeGroupDTO.getStoreGroupId();
TabStoreGroup oldStoreGroup;
//初始化的门店分组不允许编辑
ServiceResponse<TabStoreGroup> oldStoreGroupResponse = validIsDefault(storeGroupId);
if (oldStoreGroupResponse.isSuccess()) {
oldStoreGroup = oldStoreGroupResponse.getResult();
......@@ -112,12 +112,15 @@ public class StoreGroupApiServiceImpl implements StoreGroupApiService {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "父级ID参数错误");
}
int storeGroupParentId = storeGroupDTO.getParentStoreGroupId();
//初始化的门店分组下面不允许有子分组
ServiceResponse<TabStoreGroup> authValid = validIsDefault(storeGroupParentId);
if (!authValid.isSuccess()) {
return ServiceResponse.failure(authValid.getCode(), authValid.getMessage());
}
//验证上级分组是改动
int oldStoreGroupParentId = oldStoreGroup.getParentStoreGroupId();
boolean hasEditParentId = storeGroupParentId != oldStoreGroupParentId;
if (hasEditParentId) {
//验证父级ID的层级和当前层级是否相差一,如果是,则正确,否则,数据异常
TabStoreGroup parentStoreGroup = storeGroupService.getStoreGroupById(storeGroupParentId);
......@@ -139,7 +142,7 @@ public class StoreGroupApiServiceImpl implements StoreGroupApiService {
storeGroupService.update(tabStoreGroup);
//如果上级分组有门店,则新建一个未分组数据,然后把所有门店放进去
if (isNeedTransferStore(storeGroupDTO)) {
if (isNeedTransferStore(storeGroupParentId)) {
StoreGroupDTO noStoreGroup = new StoreGroupDTO();
noStoreGroup.setEnterpriseId(storeGroupDTO.getEnterpriseId());
noStoreGroup.setGroupLevel(oldStoreGroup.getGroupLevel());
......@@ -160,6 +163,23 @@ public class StoreGroupApiServiceImpl implements StoreGroupApiService {
}
@Override
public ServiceResponse<Boolean> tipWhenUpdateParentId(Integer parentStoreGroupId) {
return ServiceResponse.success(isNeedTransferStore(parentStoreGroupId));
}
@Override
public ServiceResponse<Boolean> tipWhenSaveStoreGroup(Integer groupLevel, Integer enterpriseId, Integer parentStoreGroupId) {
//父级ID
ServiceResponse<Integer> parentIdWhenNew = getParentIdWhenNew(groupLevel, enterpriseId, parentStoreGroupId);
if (parentIdWhenNew.isSuccess()) {
parentStoreGroupId = parentIdWhenNew.getResult();
} else {
return ServiceResponse.failure(parentIdWhenNew.getCode(), parentIdWhenNew.getMessage());
}
return ServiceResponse.success(isNeedTransferStore(parentStoreGroupId));
}
@Override
public ServiceResponse<Integer> updateStoreGroupName(StoreGroupDTO storeGroupDTO) {
if (storeGroupDTO.getStoreGroupId() == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "主键不能为空");
......@@ -362,12 +382,12 @@ public class StoreGroupApiServiceImpl implements StoreGroupApiService {
/**
* 是否需要转移门店,新增门店,判断上级门店是否是子节点,并且是否有门店
* @param storeGroupDTO
* @param parentStoreGroupId
* @return
*/
private boolean isNeedTransferStore(StoreGroupDTO storeGroupDTO) {
if (storeGroupService.isLeafNode(storeGroupDTO.getParentStoreGroupId())
&& isContainStore(storeGroupDTO.getStoreGroupId())) {
private boolean isNeedTransferStore(Integer parentStoreGroupId) {
if (storeGroupService.isLeafNode(parentStoreGroupId)
&& isContainStore(parentStoreGroupId)) {
return true;
} else {
return false;
......
......@@ -218,8 +218,9 @@ public class StoreStrategyApiServiceImpl implements StoreStrategyApiService{
searchDBDTO.setRegionIdList(regionIdList);
searchDBDTO.setStatusList(storeStatusList);
com.github.pagehelper.Page<StoreDTO> listStore = this.storeService.listStore(searchDBDTO, 1, Integer.MAX_VALUE);
for (StoreDTO store : listStore.getResult()) {
String result = storeStrategyService.isHitStrategy(store.getStoreInfoId(), store.getEnterpriseId(), StoreGroupConstant.STORE_GROUP_STRATEGY_TYPE);
List<StoreDTO> storeList = listStore.getResult();
for (StoreDTO store : storeList) {
String result = storeStrategyService.isHitStrategy(store.getStoreId(), store.getEnterpriseId(), StoreGroupConstant.STORE_GROUP_STRATEGY_TYPE);
if (StringUtils.isNotBlank(result)) {
storeService.updateStoreGroupId(store.getStoreInfoId(), Integer.parseInt(result));
}
......
......@@ -3,6 +3,7 @@ package com.gic.store.web.controller;
import java.util.List;
import com.gic.download.utils.OperationResultUtils;
import com.gic.enterprise.utils.ResultControllerUtils;
import com.gic.enterprise.utils.UserDetailUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -70,26 +71,49 @@ public class StoreGroupController {
return OperationResultUtils.operationResult(result, "修改上级分组", OperationResultUtils.getOperationObject(result));
}
/**
* 新增子分组验证,是否是子节点且有门店
* @param groupLevel
* @param parentStoreGroupId
* @return
*/
@RequestMapping("/has-parent-store-group-store-when-save")
public RestResponse hasParentStoreGroupStoreWhenSave(Integer groupLevel, Integer parentStoreGroupId) {
return ResultControllerUtils.commonResult(storeGroupApiService.tipWhenSaveStoreGroup(groupLevel,
UserDetailUtils.getUserDetail().getEnterpriseId(), parentStoreGroupId));
}
/**
* 修改上级分组之前验证,上级分组ID是否是子节点且有门店
* @param parentStoreGroupId
* @return
*/
@RequestMapping("/has-parent-store-group-store")
public RestResponse hasParentStoreGroupStore(Integer parentStoreGroupId) {
return ResultControllerUtils.commonResult(storeGroupApiService.tipWhenUpdateParentId(parentStoreGroupId));
}
@RequestMapping("/drag-sort")
public RestResponse dragSort(@Validated({ StoreGroupQO.RemoveValidView.class,
StoreGroupQO.SetSortValueValidView.class }) StoreGroupQO storeGroupQO) {
ServiceResponse<String> result = storeGroupApiService.dragSort(storeGroupQO.getStoreGroupId(), storeGroupQO.getSortValue());
return OperationResultUtils.operationResult(
result, "拖拽排序门店分组", OperationResultUtils.getOperationObject(result));
ServiceResponse<String> result = storeGroupApiService.dragSort(storeGroupQO.getStoreGroupId(),
storeGroupQO.getSortValue());
return OperationResultUtils.operationResult(result, "拖拽排序门店分组",
OperationResultUtils.getOperationObject(result));
}
@RequestMapping("/sort")
public RestResponse sort(@Validated({ StoreGroupQO.SortValidView.class }) StoreGroupQO storeGroupQO) {
ServiceResponse<String> result = storeGroupApiService.sort(transferQoToDTO(storeGroupQO), storeGroupQO.isUp());
return OperationResultUtils.operationResult(
result, "上下排序门店分组", OperationResultUtils.getOperationObject(result));
return OperationResultUtils.operationResult(result, "上下排序门店分组",
OperationResultUtils.getOperationObject(result));
}
@RequestMapping("/remove")
public RestResponse remove(@Validated({ StoreGroupQO.RemoveValidView.class }) StoreGroupQO storeGroupQO) {
ServiceResponse<String> result = storeGroupApiService.remove(storeGroupQO.getStoreGroupId());
return OperationResultUtils.operationResult(
result, OperationResultUtils.LOG_DELETE+ "门店分组", OperationResultUtils.getOperationObject(result));
return OperationResultUtils.operationResult(result, OperationResultUtils.LOG_DELETE + "门店分组",
OperationResultUtils.getOperationObject(result));
}
private StoreGroupDTO transferQoToDTO(StoreGroupQO storeGroupQO) {
......
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