数据处理代码+同步加盟商

This commit is contained in:
shuo.wang
2025-07-14 10:09:16 +08:00
parent 5a0dd61af8
commit 2b0c1a6404
14 changed files with 189 additions and 11 deletions

View File

@@ -81,5 +81,6 @@ public interface DataHandlerServer {
* @Date: 2025/7/11
* @description:处理老数据 已经建店并且在标品中也建店的数据 处理所属管理区域
*/
void dataHandlerCreateStore();
}

View File

@@ -3,6 +3,7 @@ package com.cool.store.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.cool.store.constants.CommonConstants;
import com.cool.store.context.CurrentUserHolder;
import com.cool.store.context.LoginUserInfo;
import com.cool.store.dao.*;
import com.cool.store.dto.*;
@@ -46,6 +47,8 @@ import static com.cool.store.utils.poi.DateUtils.YYYY_MM_DD;
@Service
@Slf4j
public class DataHandlerServerImpl implements DataHandlerServer {
@Resource
private RegionDao regionDao;
@Resource
private LinePayService linePayService;
@Resource
@@ -88,6 +91,8 @@ public class DataHandlerServerImpl implements DataHandlerServer {
private ShopAccountDAO shopAccountDAO;
@Resource
private SignFranchiseDAO signFranchiseDAO;
@Resource
private EnterpriseUserDAO enterpriseUserDAO;
@Value("${mybatis.configuration.variables.enterpriseId}")
private String eid;
@@ -1143,6 +1148,82 @@ public class DataHandlerServerImpl implements DataHandlerServer {
return true;
}
@Override
public void dataHandlerCreateStore() {
//已经创建了的门店
List<IsCreateStoreDTO> isCreateStore = shopInfoDAO.selectIsCreateStore();
List<ShopInfoDO> updateList = new ArrayList<>();
for (IsCreateStoreDTO isCreateStoreDTO:isCreateStore){
ShopInfoDO shopInfoDO = new ShopInfoDO();
shopInfoDO.setId(isCreateStoreDTO.getShopId());
shopInfoDO.setManagerRegionId(isCreateStoreDTO.getPid());
updateList.add(shopInfoDO);
}
List<Long> isShopIds = isCreateStore.stream().map(IsCreateStoreDTO::getShopId).collect(Collectors.toList());
//未建店
List<ShopInfoDO> shopInfoDOS = shopInfoDAO.selectByNotCreateStore(isShopIds);
Set<String> investUserIds = shopInfoDOS.stream().map(ShopInfoDO::getInvestmentManager).collect(Collectors.toSet());
Map<String, String> userNameMap = enterpriseUserDAO.getUserNameMap(new ArrayList<>(investUserIds));
Set<String> nameSet = userNameMap.keySet();
List<RegionDO> regionDOList = regionDao.getRegionByNameListAndIsPath(new ArrayList<>(nameSet));
Set<Long> parentIdSet = new HashSet<>();
regionDOList.forEach(regionDO -> parentIdSet.add(Long.valueOf(regionDO.getParentId())));
Map<Long, String> parentRegionNameMap = regionDao.getRegionNameMap(new ArrayList<>(parentIdSet));
Map<Long, String> shopRegionNameMap = regionDao.getRegionNameMap(new ArrayList<>(shopInfoDOS.stream().map(ShopInfoDO::getRegionId).collect(Collectors.toSet())));
List<ImportOaOldShopDataErrorDTO> errorList = new ArrayList<>();
Map<String, List<RegionDO>> regionName = regionDOList.stream().collect(Collectors.groupingBy(RegionDO::getName));
for (ShopInfoDO shopInfoDO : shopInfoDOS){
String name = userNameMap.getOrDefault(shopInfoDO.getInvestmentManager(),"");
if (StringUtils.isBlank(name)){
log.info("门店招商经理未找到 shopId{}",shopInfoDO.getId());
ImportOaOldShopDataErrorDTO errorDTO = new ImportOaOldShopDataErrorDTO(shopInfoDO.getShopCode(), "门店招商经理未找到");
continue;
}
List<RegionDO> regionList = regionName.getOrDefault(name, new ArrayList<>());
if (CollectionUtils.isEmpty(regionList)){
log.info("门店所属管理区域未找到 shopId{}",shopInfoDO.getId());
ImportOaOldShopDataErrorDTO errorDTO = new ImportOaOldShopDataErrorDTO(shopInfoDO.getShopCode(), "门店所属管理区域未找到");
continue;
}
for (RegionDO regionDO : regionList){
String parentRegionNameMapOrDefault = parentRegionNameMap.getOrDefault(Long.valueOf(regionDO.getParentId()), "");
String shopRegionName = shopRegionNameMap.getOrDefault(regionDO.getId(), "");
if (StringUtils.isNotBlank(parentRegionNameMapOrDefault)&&StringUtils.isNotBlank(shopRegionName)
&&(parentRegionNameMapOrDefault.equals("门店"+shopRegionName)||parentRegionNameMapOrDefault.equals(shopRegionName))){
shopInfoDO.setManagerRegionId(regionDO.getId());
updateList.add(shopInfoDO);
break;
}
}
}
shopInfoDAO.updateManagerRegionId(updateList);
if (CollectionUtils.isNotEmpty(errorList)) {
String url = null;
try {
url = easyExcelUtil.exportExcel(ImportOaOldShopDataErrorDTO.class, errorList, null,
FileTypeEnum.IMPORT_OA_OLD_SHOP_STAGE_DATA.getDesc() + DateUtils.parseDateToStr(SPECIAL_DATE_START_1, new Date()),
FileTypeEnum.IMPORT_OA_OLD_SHOP_STAGE_DATA.getDesc() + DateUtils.parseDateToStr(SPECIAL_DATE_START_1, new Date()));
} catch (Exception e) {
log.info("导出同步门店数据错误列表失败 errorList:{}", JSONObject.toJSONString(errorList));
}
ImportTaskDO importTaskDO = new ImportTaskDO();
importTaskDO.setFileName("同步门店数据错误列表");
importTaskDO.setFileType(FileTypeEnum.IMPORT_FITMENT_SHOP_STAGE.getFileType());
importTaskDO.setIsImport(true);
importTaskDO.setFileType(url);
importTaskDO.setStatus(ImportTaskStatusEnum.PROGRESS.getCode());
importTaskDO.setCreateUserId(CurrentUserHolder.getUserId());
importTaskDO.setCreateName(CurrentUserHolder.getUser().getName());
importTaskDO.setCreateTime(System.currentTimeMillis());
importTaskMapper.insert(eid, importTaskDO);
}
}
private static @NotNull ShopStageInfoDO getShopStageInfoDO(ShopSubStageEnum shopSubStageEnum, ShopStageInfoDO shopStageInfoDO, ShopSubStageStatusEnum shopSubStageStatus) {
ShopStageEnum shopStageEnum = shopSubStageEnum.getShopStageEnum();
ShopStageInfoDO shopStageInfo = new ShopStageInfoDO();

View File

@@ -12,10 +12,7 @@ import com.cool.store.mapper.FranchiseFeeMapper;
import com.cool.store.mapper.SignFranchiseMapper;
import com.cool.store.request.AuditRequest;
import com.cool.store.request.OrderSysInfoRequest;
import com.cool.store.service.OperationLogService;
import com.cool.store.service.OrderSysInfoService;
import com.cool.store.service.SignFranchiseService;
import com.cool.store.service.UserAuthMappingService;
import com.cool.store.service.*;
import com.cool.store.utils.poi.StringUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Value;
@@ -40,6 +37,8 @@ import static com.cool.store.enums.point.ShopSubStageStatusEnum.*;
public class OrderSysInfoServiceImpl implements OrderSysInfoService {
@Resource
private SyncMainSysServer syncMainSysServer;
@Resource
FranchiseFeeMapper franchiseFeeMapper;
@Resource
@@ -246,12 +245,14 @@ public class OrderSysInfoServiceImpl implements OrderSysInfoService {
if (!flag && SHOP_SUB_STAGE_STATUS_154.equals(nowStatus)) {
shopStageInfoDAO.updateShopStageInfo(request.getShopId(), SHOP_SUB_STAGE_STATUS_156);
stageCompletion(request.getShopId());
syncMainSysServer.syncStore(request.getShopId());
return CommonConstants.ONE;
} else {
shopStageInfoDAO.updateShopStageInfo(request.getShopId(), nextStatus);
if (SHOP_SUB_STAGE_STATUS_156.equals(nextStatus)){
stageCompletion(request.getShopId());
syncMainSysServer.syncStore(request.getShopId());
}
return CommonConstants.ONE;
}

View File

@@ -1,6 +1,7 @@
package com.cool.store.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.cool.store.context.CurrentUserHolder;
import com.cool.store.dao.*;
import com.cool.store.entity.*;
import com.cool.store.enums.*;
@@ -23,6 +24,7 @@ import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Map;
import static com.cool.store.enums.AuditExecuteEnum.FRANCHISEES;
import static com.cool.store.enums.ExtendFieldTypeEnum.*;
/**
@@ -66,7 +68,7 @@ public class SyncMainSysServerImpl implements SyncMainSysServer {
private String eid;
@Override
//@Async
@Async
public void syncStore(Long shopId) {
StoreRequestBody requestBody = new StoreRequestBody();
ShopInfoDO shopInfo = shopInfoDAO.getShopInfo(shopId);
@@ -115,6 +117,9 @@ public class SyncMainSysServerImpl implements SyncMainSysServer {
extendField.put(configMapByActive.get(ONLINE_BRAND.getMsg()).getKey(), FranchiseBrandEnum.getDescByCode(shopInfo.getFranchiseBrand()));
requestBody.setExtend_field(JSONObject.toJSONString(extendField));
requestBody.setEid(eid);
requestBody.setPartnerName(lineInfoDO.getUsername());
requestBody.setPartnerMobile(lineInfoDO.getMobile());
requestBody.setPartnerRoleId(UserRoleEnum.FRANCHISEES.getCode());
simpleMessageService.send(JSONObject.toJSONString(requestBody), RocketMqTagEnum.ZXJP_CREATE_STORE);
}