Commit bbeb5727 by guojuxing

总店ID查询分店

parent da86f32d
......@@ -11,6 +11,9 @@ import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.gic.commons.util.EntityUtil;
import com.gic.enterprise.web.vo.wm.WmBranchVO;
import com.gic.weimob.api.dto.WeimobStoreGicInfoDTO;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.StringUtils;
......@@ -89,6 +92,37 @@ public class WmStoreSyncController {
*/
private static final String STORE_BRANCH_REDIS_KEY = "enterprise:weimob4:init:branch:";
@RequestMapping("list-store")
public RestResponse listStore(StoreSearchDTO storeSearchDTO) {
//todo 过滤已同步过的门店
return ResultControllerUtils.commonResult(storeApiService.listStore(storeSearchDTO, 0, 1000));
}
/**
* 查询分店
* @param wmMallStoreId
* @param storeId
* @return
*/
@RequestMapping("list-sub-by-store-code")
public RestResponse listSubByStoreCode(Integer wmMallStoreId, Integer storeId) {
StoreDTO storeDTO = getByStoreId(UserDetailUtils.getUserDetail().getEnterpriseId(), storeId);
if (storeDTO == null) {
return RestResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "门店不存在");
}
List<StoreDTO> list = getStoreList(storeDTO.getStoreInfoId().toString(), true);
Map<String, String> map = list.stream().collect(Collectors.toMap(e -> e.getStoreInfoId().toString(), StoreDTO::getStoreName));
ServiceResponse<List<WeimobStoreGicInfoDTO>> result = weimobStoreSiteService.listStoreId(wmMallStoreId, storeDTO.getStoreInfoId());
if (result.isSuccess()) {
List<WeimobStoreGicInfoDTO> subStoreList = result.getResult();
if (CollectionUtils.isNotEmpty(subStoreList)) {
List<WmBranchVO> voList = EntityUtil.changeEntityListNew(WmBranchVO.class, subStoreList);
voList.forEach(vo -> vo.setStoreName(map.get(vo.getStoreInfoId().toString())));
return RestResponse.success(voList);
}
}
return RestResponse.success();
}
/**
*
......@@ -208,9 +242,14 @@ public class WmStoreSyncController {
if (storeId == null) {
return RestResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "参数为空");
}
StoreDTO storeDTO = getByStoreId(UserDetailUtils.getUserDetail().getEnterpriseId(), storeId);
if (storeDTO == null) {
return RestResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "门店不存在");
}
wmStoreSyncLogApiService.deleteLogic(storeId, wmMallStoreId);
ServiceResponse<Void> weimobResult = weimobStoreSiteService.deleteStoreRel(wmMallStoreId, storeId);
ServiceResponse<Void> weimobResult = weimobStoreSiteService.deleteStoreRel(wmMallStoreId, storeDTO.getStoreInfoId());
LOGGER.info("微盟中间件删除门店关联关系结果:{}", JSON.toJSONString(weimobResult));
if (!weimobResult.isSuccess()) {
return RestResponse.failure(weimobResult.getCode(), weimobResult.getMessage());
......@@ -895,4 +934,12 @@ public class WmStoreSyncController {
}
return storeIdList;
}
private StoreDTO getByStoreId(Integer enterpriseId, Integer storeId) {
ServiceResponse<StoreDTO> response = storeApiService.getStoreById(enterpriseId, storeId);
if (response.isSuccess()) {
return response.getResult();
}
return null;
}
}
package com.gic.enterprise.web.vo.wm;
import java.io.Serializable;
import java.util.Date;
public class WmBranchVO implements Serializable{
private static final long serialVersionUID = 2272635530786898016L;
private Integer storeInfoId;
private String storeCode;
private Date time;
private String storeName;
public Integer getStoreInfoId() {
return storeInfoId;
}
public WmBranchVO setStoreInfoId(Integer storeInfoId) {
this.storeInfoId = storeInfoId;
return this;
}
public String getStoreCode() {
return storeCode;
}
public WmBranchVO setStoreCode(String storeCode) {
this.storeCode = storeCode;
return this;
}
public Date getTime() {
return time;
}
public WmBranchVO setTime(Date time) {
this.time = time;
return this;
}
public String getStoreName() {
return storeName;
}
public WmBranchVO setStoreName(String storeName) {
this.storeName = storeName;
return this;
}
}
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