Merge branch 'cc_20250710_userRegion' into 'master'
Cc 20250710 user region See merge request hangzhou/java/custom_zxjp!131
This commit is contained in:
@@ -76,4 +76,11 @@ public interface DataHandlerServer {
|
||||
*/
|
||||
Boolean batchStatusRefreshYls(BatchStatusRefreshDTO batchStatusRefreshDTO);
|
||||
|
||||
/**
|
||||
* @Auther: wangshuo
|
||||
* @Date: 2025/7/11
|
||||
* @description:处理老数据 已经建店并且在标品中也建店的数据 处理所属管理区域
|
||||
*/
|
||||
void dataHandlerCreateStore();
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.cool.store.service;
|
||||
|
||||
import com.cool.store.entity.RegionDO;
|
||||
import com.cool.store.response.RegionResponse;
|
||||
import com.cool.store.vo.RegionPathNameVO;
|
||||
|
||||
import java.util.List;
|
||||
@@ -40,4 +41,11 @@ public interface RegionService {
|
||||
*/
|
||||
List<String> getSubRegionIdsByRegionIds(List<String> regionIds);
|
||||
|
||||
/**
|
||||
* @Auther: wangshuo
|
||||
* @Date: 2025/7/11
|
||||
* @description:获取管理区域下的所有子区域(门店-大区,加盟分部)
|
||||
*/
|
||||
List<RegionResponse> getSubRegionByParentId(Long regionId);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.cool.store.service;
|
||||
|
||||
/**
|
||||
* @Author: WangShuo
|
||||
* @Date: 2025/07/10/17:14
|
||||
* @Version 1.0
|
||||
* @注释:
|
||||
*/
|
||||
public interface SyncMainSysServer {
|
||||
|
||||
void syncStore(Long shopId);
|
||||
}
|
||||
@@ -3,9 +3,11 @@ 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.*;
|
||||
import com.cool.store.dto.region.BigRegionDTO;
|
||||
import com.cool.store.entity.*;
|
||||
import com.cool.store.enums.*;
|
||||
import com.cool.store.enums.point.PayBusinessTypeEnum;
|
||||
@@ -14,6 +16,7 @@ import com.cool.store.enums.point.ShopSubStageEnum;
|
||||
import com.cool.store.enums.point.ShopSubStageStatusEnum;
|
||||
import com.cool.store.exception.ServiceException;
|
||||
import com.cool.store.mapper.*;
|
||||
import com.cool.store.request.QueryBigRegionRequest;
|
||||
import com.cool.store.service.*;
|
||||
import com.cool.store.utils.StringUtil;
|
||||
import com.cool.store.utils.easyExcel.EasyExcelUtil;
|
||||
@@ -46,6 +49,12 @@ import static com.cool.store.utils.poi.DateUtils.YYYY_MM_DD;
|
||||
@Service
|
||||
@Slf4j
|
||||
public class DataHandlerServerImpl implements DataHandlerServer {
|
||||
@Resource
|
||||
private RegionMapper regionMapper;
|
||||
@Resource
|
||||
private BigRegionDAO bigRegionDAO;
|
||||
@Resource
|
||||
private RegionDao regionDao;
|
||||
@Resource
|
||||
private LinePayService linePayService;
|
||||
@Resource
|
||||
@@ -88,6 +97,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 +1154,97 @@ public class DataHandlerServerImpl implements DataHandlerServer {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
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<BigRegionDTO> bigRegionDTOS = bigRegionDAO.queryAllBigRegion(null);
|
||||
Map<Long, BigRegionDTO> bigRegionDTOMap = bigRegionDTOS.stream().collect(Collectors.toMap(BigRegionDTO::getRegionId, x -> x));
|
||||
//XX大区 正烧鸡
|
||||
List<Long> storeManageIds = bigRegionDTOS.stream().filter(x -> x.getStoreManageRegionId() != null).map(BigRegionDTO::getStoreManageRegionId).collect(Collectors.toList());
|
||||
//加盟分部
|
||||
List<Long> branchStoreManageIds = bigRegionDTOS.stream().filter(x -> x.getStoreManageRegionId() == null).map(BigRegionDTO::getRegionId).collect(Collectors.toList());
|
||||
|
||||
//查询门店-XX大区下面的管理督导
|
||||
List<RegionDO> manageRegionList = regionDao.getSubRegionByParentIdsAndRegionType(storeManageIds, "path");
|
||||
Map<String, RegionDO> manageRegionMap = manageRegionList.stream().collect(Collectors.toMap(regionDO -> regionDO.getName(), Function.identity()));
|
||||
//查询加盟分部下的管理督导
|
||||
List<RegionDO> branchStoreManageList = regionDao.getSubRegionByParentIdsAndRegionType(branchStoreManageIds, "path");
|
||||
Map<String, RegionDO> branchStoreManageMap = branchStoreManageList.stream().collect(Collectors.toMap(regionDO -> regionDO.getName(), Function.identity()));
|
||||
|
||||
List<Long> isShopIds = isCreateStore.stream().map(IsCreateStoreDTO::getShopId).collect(Collectors.toList());
|
||||
//未建店
|
||||
List<ShopInfoDO> shopInfoDOS = shopInfoDAO.selectByNotCreateStore(isShopIds);
|
||||
//List<ShopInfoDO> shopInfoDOS = Collections.singletonList(shopInfoDAO.getShopInfo(414L));
|
||||
Set<String> investUserIds = shopInfoDOS.stream().map(ShopInfoDO::getInvestmentManager).collect(Collectors.toSet());
|
||||
Map<String, String> userNameMap = enterpriseUserDAO.getUserNameMap(new ArrayList<>(investUserIds));
|
||||
List<ImportOaOldShopDataErrorDTO> errorList = new ArrayList<>();
|
||||
|
||||
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(), "门店招商经理未找到");
|
||||
errorDTO.setShopName(shopInfoDO.getShopName());
|
||||
errorList.add(errorDTO);
|
||||
continue;
|
||||
}
|
||||
BigRegionDTO bigRegionDTO = bigRegionDTOMap.get(shopInfoDO.getRegionId());
|
||||
RegionDO regionDO;
|
||||
if (bigRegionDTO==null){
|
||||
log.info("门店所属大区未找到 shopId:{}",shopInfoDO.getId());
|
||||
ImportOaOldShopDataErrorDTO errorDTO = new ImportOaOldShopDataErrorDTO(shopInfoDO.getShopCode(), "门店所属大区未找到");
|
||||
errorDTO.setShopName(shopInfoDO.getShopName());
|
||||
errorList.add(errorDTO);
|
||||
continue;
|
||||
}
|
||||
if (bigRegionDTO.getStoreManageRegionId()!=null){
|
||||
regionDO = manageRegionMap.get(name);
|
||||
}else{
|
||||
regionDO= branchStoreManageMap.get(name);
|
||||
}
|
||||
if (Objects.isNull(regionDO)||!Long.valueOf(regionDO.getParentId()).equals(bigRegionDTO.getStoreManageRegionId())){
|
||||
log.info("门店所属管理区域未找到 shopId:{}",shopInfoDO.getId());
|
||||
ImportOaOldShopDataErrorDTO errorDTO = new ImportOaOldShopDataErrorDTO(shopInfoDO.getShopCode(), "门店所属管理区域未找到");
|
||||
errorDTO.setShopName(shopInfoDO.getShopName());
|
||||
errorList.add(errorDTO);
|
||||
continue;
|
||||
}
|
||||
shopInfoDO.setManagerRegionId(regionDO.getId());
|
||||
updateList.add(shopInfoDO);
|
||||
}
|
||||
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.setFileUrl(url);
|
||||
importTaskDO.setStatus(ImportTaskStatusEnum.ERROR.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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -3,13 +3,16 @@ package com.cool.store.service.impl;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cool.store.constants.CommonConstants;
|
||||
import com.cool.store.dao.BigRegionDAO;
|
||||
import com.cool.store.dao.RegionAreaConfigDao;
|
||||
import com.cool.store.dao.RegionDao;
|
||||
import com.cool.store.entity.BigRegionDO;
|
||||
import com.cool.store.entity.RegionDO;
|
||||
import com.cool.store.enums.ErrorCodeEnum;
|
||||
import com.cool.store.enums.ThirdRegionTypeEnum;
|
||||
import com.cool.store.exception.ServiceException;
|
||||
import com.cool.store.mapper.RegionMapper;
|
||||
import com.cool.store.response.RegionResponse;
|
||||
import com.cool.store.service.RegionService;
|
||||
import com.cool.store.utils.RedisConstantUtil;
|
||||
import com.cool.store.utils.RedisUtilPool;
|
||||
@@ -48,6 +51,8 @@ public class RegionServiceImpl implements RegionService {
|
||||
@Resource
|
||||
private RegionAreaConfigDao regionAreaConfigDao;
|
||||
|
||||
@Resource
|
||||
private BigRegionDAO bigRegionDAO;
|
||||
|
||||
@Override
|
||||
public RegionPathNameVO getAllRegionName(Long regionId) {
|
||||
@@ -158,4 +163,19 @@ public class RegionServiceImpl implements RegionService {
|
||||
}
|
||||
return regionIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RegionResponse> getSubRegionByParentId(Long regionId) {
|
||||
if (Objects.isNull(regionId)){
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
BigRegionDO byRegionId = bigRegionDAO.getByRegionId(regionId);
|
||||
if (byRegionId.getStoreManageRegionId()==null){
|
||||
regionId=byRegionId.getRegionId();
|
||||
}else {
|
||||
regionId=byRegionId.getStoreManageRegionId();
|
||||
}
|
||||
return regionMapper.getSubRegionByParentIdAndRegionType(regionId,"path");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -196,6 +196,7 @@ public class ShopServiceImpl implements ShopService {
|
||||
List<ShopStageInfoDO> subStageList = shopStageInfoDAO.getSubStageList(shopIds, ShopSubStageEnum.SHOP_STAGE_8.getShopSubStage());
|
||||
Map<Long, ShopStageInfoDO> stageMap = subStageList.stream().collect(Collectors.toMap(ShopStageInfoDO::getShopId, Function.identity()));
|
||||
List<Long> regionIds = shopList.stream().map(ShopInfoDO::getRegionId).collect(Collectors.toList());
|
||||
regionIds.addAll(Optional.of(shopList).orElse(Collections.emptyList()).stream().map(ShopInfoDO::getManagerRegionId).collect(Collectors.toList()));
|
||||
Map<Long, String> regionNameMap = regionDao.getRegionNameMap(regionIds);
|
||||
List<String> investmentManagerIds = shopList.stream().map(ShopInfoDO::getInvestmentManager).collect(Collectors.toList());
|
||||
Map<String, EnterpriseUserDO> userInfoMap = enterpriseUserDAO.getUserInfoMap(investmentManagerIds);
|
||||
@@ -390,10 +391,15 @@ public class ShopServiceImpl implements ShopService {
|
||||
}
|
||||
EnterpriseUserDO invest = enterpriseUserDAO.getUserInfoById(shopInfo.getInvestmentManager());
|
||||
List<ScheduleDTO> shopContractActualCompletionTime = shopStageInfoDAO.getScheduleList(Collections.singletonList(shopId));
|
||||
RegionNode shopRegion = regionMapper.getRegionByRegionId(shopInfo.getRegionId().toString());
|
||||
RegionDO shopRegion = regionDao.getRegionById(shopInfo.getRegionId());
|
||||
RegionDO mapperRegionByRegionId = regionDao.getRegionById(shopInfo.getManagerRegionId());
|
||||
String wantShopArea = hyOpenAreaInfoDAO.selectNameMapById(shopInfo.getWantShopAreaId());
|
||||
HyOpenAreaInfoDO hyOpenAreaInfoDO = hyOpenAreaInfoDAO.selectById(shopInfo.getWantShopAreaId());
|
||||
BranchShopDetailResponse response = new BranchShopDetailResponse();
|
||||
response.setManagerRegionId(shopInfo.getManagerRegionId());
|
||||
if (Objects.nonNull(mapperRegionByRegionId)) {
|
||||
response.setManagerRegionName(mapperRegionByRegionId.getName());
|
||||
}
|
||||
response.setUsername(lineInfo.getUsername());
|
||||
response.setMobile(lineInfo.getMobile());
|
||||
response.setShopId(shopId);
|
||||
@@ -433,6 +439,7 @@ public class ShopServiceImpl implements ShopService {
|
||||
shopInfo.setJoinMode(request.getJoinMode());
|
||||
shopInfo.setFranchiseBrand(request.getFranchiseBrand());
|
||||
shopInfo.setStoreType(request.getStoreType());
|
||||
shopInfo.setManagerRegionId(request.getManagerRegionId());
|
||||
return shopInfoDAO.updateShopInfo(shopInfo);
|
||||
}
|
||||
|
||||
@@ -514,6 +521,7 @@ public class ShopServiceImpl implements ShopService {
|
||||
return new PageInfo<>();
|
||||
}
|
||||
List<Long> regionIds = preparations.stream().map(PreparationDTO::getRegionId).collect(Collectors.toList());
|
||||
regionIds.addAll(Optional.of(preparations).orElse(Collections.emptyList()).stream().map(PreparationDTO::getManagerRegionId).collect(Collectors.toList()));
|
||||
List<Long> wantShopAreaIds = preparations.stream().map(PreparationDTO::getWantShopAreaId).collect(Collectors.toList());
|
||||
List<String> investmentManagerIds = preparations.stream().map(PreparationDTO::getInvestmentManager).collect(Collectors.toList());
|
||||
List<Long> shopIds = preparations.stream().map(PreparationDTO::getId).collect(Collectors.toList());
|
||||
@@ -548,6 +556,8 @@ public class ShopServiceImpl implements ShopService {
|
||||
response.setShopStatus(ShopStatusEnum.getDesc(dto.getShopStatus()));
|
||||
response.setCreateTime(dto.getCreateTime());
|
||||
response.setDays();
|
||||
response.setManagerRegionId(dto.getManagerRegionId());
|
||||
response.setManagerRegionName(regionNameMap.getOrDefault(dto.getManagerRegionId(), ""));
|
||||
responses.add(response);
|
||||
}
|
||||
pageInfo.setList(responses);
|
||||
@@ -606,7 +616,7 @@ public class ShopServiceImpl implements ShopService {
|
||||
Integer pageSize = request.getPageSize();
|
||||
String storeName = request.getStoreName();
|
||||
LineInfoDO lineInfoDO = lineInfoDAO.getLineInfo(lineId);
|
||||
PageInfo<MiniShopsResponse> storeListByMobile = storeService.getStoreListByMobile(lineInfoDO.getMobile(), pageNum, pageSize, storeName,request.getStoreNum());
|
||||
PageInfo<MiniShopsResponse> storeListByMobile = storeService.getStoreListByMobile(lineInfoDO.getMobile(), pageNum, pageSize, storeName, request.getStoreNum());
|
||||
if (CollectionUtils.isEmpty(storeListByMobile.getList())) {
|
||||
return new PageInfo<>(new ArrayList<>());
|
||||
}
|
||||
|
||||
@@ -44,6 +44,8 @@ import static com.cool.store.enums.point.ShopSubStageStatusEnum.*;
|
||||
@Slf4j
|
||||
public class SignFranchiseServiceImpl implements SignFranchiseService, AuditResultService {
|
||||
|
||||
@Resource
|
||||
private RegionDao regionDao;
|
||||
@Resource
|
||||
private PointInfoDAO pointInfoDAO;
|
||||
@Resource
|
||||
@@ -267,6 +269,7 @@ public class SignFranchiseServiceImpl implements SignFranchiseService, AuditResu
|
||||
|
||||
private void updateShopAndPoint(AddSignFranchiseRequest request, ShopInfoDO shopInfoDO, PointInfoDO pointInfoById) {
|
||||
//店铺信息
|
||||
shopInfoDO.setManagerRegionId(request.getManagerRegionId());
|
||||
shopInfoDO.setRegionId(request.getRegionId());
|
||||
shopInfoDO.setShopName(request.getShopName());
|
||||
shopInfoDO.setDetailAddress(request.getDetailAddress());
|
||||
@@ -460,7 +463,10 @@ public class SignFranchiseServiceImpl implements SignFranchiseService, AuditResu
|
||||
//证照办理
|
||||
LicenseTransactDO licenseTransactDO = applyLicenseMapper.selectByShopId(shopId);
|
||||
|
||||
RegionDO regionInfo = regionMapper.getByRegionId(shopInfoDO.getRegionId());
|
||||
RegionDO regionInfo = regionDao.selectById(shopInfoDO.getRegionId());
|
||||
|
||||
RegionDO managerRegion = regionDao.selectById(shopInfoDO.getManagerRegionId());
|
||||
|
||||
|
||||
// if (Objects.nonNull(pointInfoDO)) {
|
||||
// // addSignFranchiseResponse.setStoreAddress(pointInfoDO.getAddress());
|
||||
@@ -478,6 +484,10 @@ public class SignFranchiseServiceImpl implements SignFranchiseService, AuditResu
|
||||
addSignFranchiseResponse.setProvinceCode(shopInfoDO.getProvinceCode());
|
||||
addSignFranchiseResponse.setCityCode(shopInfoDO.getCityCode());
|
||||
addSignFranchiseResponse.setDistrictCode(shopInfoDO.getDistrictCode());
|
||||
addSignFranchiseResponse.setManagerRegionId(shopInfoDO.getManagerRegionId());
|
||||
if (Objects.nonNull(managerRegion)){
|
||||
addSignFranchiseResponse.setManagerRegionName(managerRegion.getName());
|
||||
}
|
||||
if (Objects.nonNull(signFranchiseDO)) {
|
||||
addSignFranchiseResponse.setId(signFranchiseDO.getId());
|
||||
addSignFranchiseResponse.setShopId(signFranchiseDO.getShopId());
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
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.*;
|
||||
import com.cool.store.exception.ServiceException;
|
||||
import com.cool.store.mapper.FranchiseFeeMapper;
|
||||
import com.cool.store.mapper.SignFranchiseMapper;
|
||||
import com.cool.store.mq.producer.SimpleMessageService;
|
||||
import com.cool.store.request.StoreRequestBody;
|
||||
import com.cool.store.service.OperationLogService;
|
||||
import com.cool.store.service.SyncMainSysServer;
|
||||
import com.cool.store.service.UserAuthMappingService;
|
||||
import com.cool.store.utils.poi.StringUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.cool.store.enums.AuditExecuteEnum.FRANCHISEES;
|
||||
import static com.cool.store.enums.ExtendFieldTypeEnum.*;
|
||||
|
||||
/**
|
||||
* @Author: WangShuo
|
||||
* @Date: 2025/07/10/17:14
|
||||
* @Version 1.0
|
||||
* @注释:
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class SyncMainSysServerImpl implements SyncMainSysServer {
|
||||
@Resource
|
||||
private BigRegionDAO bigRegionDAO;
|
||||
@Value("${spring.profiles.active}")
|
||||
private String active;
|
||||
@Resource
|
||||
private SimpleMessageService simpleMessageService;
|
||||
@Resource
|
||||
private SignFranchiseMapper signFranchiseMapper;
|
||||
@Resource
|
||||
private BuildInformationDAO buildInformationDAO;
|
||||
@Resource
|
||||
private PointInfoDAO pointInfoDAO;
|
||||
@Resource
|
||||
FranchiseFeeMapper franchiseFeeMapper;
|
||||
@Resource
|
||||
private OperationLogDAO operationLogDAO;
|
||||
@Resource
|
||||
private OrderSysInfoDAO orderSysInfoDAO;
|
||||
@Resource
|
||||
private ShopStageInfoDAO shopStageInfoDAO;
|
||||
@Resource
|
||||
private PreparationServiceImpl preparationService;
|
||||
@Resource
|
||||
private UserAuthMappingService userAuthMappingService;
|
||||
@Resource
|
||||
private CommonService commonService;
|
||||
@Resource
|
||||
private ShopInfoDAO shopInfoDAO;
|
||||
@Resource
|
||||
private LineInfoDAO lineInfoDAO;
|
||||
@Value("${mybatis.configuration.variables.enterpriseId}")
|
||||
private String eid;
|
||||
@Resource
|
||||
private StoreDao storeDao;
|
||||
|
||||
@Override
|
||||
@Async
|
||||
public void syncStore(Long shopId) {
|
||||
StoreRequestBody requestBody = new StoreRequestBody();
|
||||
ShopInfoDO shopInfo = shopInfoDAO.getShopInfo(shopId);
|
||||
StoreDO storeDO = storeDao.getByStoreNum(shopInfo.getShopCode());
|
||||
if (Objects.nonNull(storeDO)) {
|
||||
throw new ServiceException(ErrorCodeEnum.STORE_IS_EXIST);
|
||||
}
|
||||
LineInfoDO lineInfoDO = lineInfoDAO.getLineInfo(shopInfo.getLineId());
|
||||
PointInfoDO pointInfoDO = pointInfoDAO.getPointInfoById(shopInfo.getPointId());
|
||||
BuildInformationDO buildInformationDO = buildInformationDAO.selectOneByShopId(shopId);
|
||||
SignFranchiseDO signFranchiseDO = signFranchiseMapper.selectByShopId(shopId);
|
||||
|
||||
requestBody.setStore_name(shopInfo.getShopName());
|
||||
requestBody.setStore_num(shopInfo.getShopCode());
|
||||
requestBody.setProvince(shopInfo.getProvince());
|
||||
requestBody.setCity(shopInfo.getCity());
|
||||
requestBody.setCounty(shopInfo.getDistrict());
|
||||
requestBody.setLocation_address(shopInfo.getDetailAddress());
|
||||
requestBody.setStore_address(shopInfo.getDetailAddress());
|
||||
if (shopInfo.getManagerRegionId() == null) {
|
||||
BigRegionDO byRegionId = bigRegionDAO.getByRegionId(shopInfo.getRegionId());
|
||||
if (byRegionId != null) {
|
||||
requestBody.setStore_area(byRegionId.getStoreManageRegionId() == null
|
||||
? shopInfo.getRegionId().toString() : shopInfo.getManagerRegionId().toString());
|
||||
} else {
|
||||
requestBody.setStore_area(shopInfo.getRegionId().toString());
|
||||
}
|
||||
} else {
|
||||
requestBody.setStore_area(shopInfo.getManagerRegionId().toString());
|
||||
}
|
||||
//未开业
|
||||
requestBody.setStore_status("not_open");
|
||||
if (pointInfoDO != null) {
|
||||
requestBody.setStore_acreage(pointInfoDO.getPointArea());
|
||||
requestBody.setLongitude_latitude(pointInfoDO.getLongitude() + "," + pointInfoDO.getLatitude());
|
||||
}
|
||||
requestBody.setTelephone(buildInformationDO.getBusinessMobile());
|
||||
if (StringUtils.isNotBlank(buildInformationDO.getBusinessHours())) {
|
||||
try {
|
||||
String[] times = buildInformationDO.getBusinessHours().split("~");
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm");
|
||||
LocalTime startTime = LocalTime.parse(times[0], formatter);
|
||||
LocalTime endTime = LocalTime.parse(times[1], formatter);
|
||||
String startMillis = String.valueOf(startTime.toSecondOfDay() * 1000L);
|
||||
String endMillis = String.valueOf(endTime.toSecondOfDay() * 1000L);
|
||||
requestBody.setBusiness_hours(startMillis + "," + endMillis);
|
||||
} catch (Exception e) {
|
||||
log.info("时间转换异常:{},shopId:{},time:{}", e.getMessage(), shopId.toString(), buildInformationDO.getBusinessHours());
|
||||
}
|
||||
}
|
||||
Map<String, ExtendFieldTypeEnum> configMapByActive = ExtendFieldTypeEnum.getConfigMapByActive(active);
|
||||
Map<String, String> extendField = new HashMap<>();
|
||||
extendField.put(configMapByActive.get(ONLINE_STORE_MANAGER_MOBILE.getMsg()).getKey(), "");
|
||||
extendField.put(configMapByActive.get(ONLINE_SIGNATORY_NAME_1.getMsg()).getKey(), signFranchiseDO.getPartnershipSignatoryFirst());
|
||||
extendField.put(configMapByActive.get(ONLINE_SIGNATORY_MOBILE_1.getMsg()).getKey(), lineInfoDO.getMobile());
|
||||
extendField.put(configMapByActive.get(ONLINE_SIGNATORY_NAME_2.getMsg()).getKey(), signFranchiseDO.getPartnershipSignatorySecond());
|
||||
extendField.put(configMapByActive.get(ONLINE_SIGNATORY_MOBILE_2.getMsg()).getKey(), signFranchiseDO.getPartnershipSignatorySecondMobile());
|
||||
extendField.put(configMapByActive.get(ONLINE_ORDER_NAME.getMsg()).getKey(), buildInformationDO.getCShopName());
|
||||
extendField.put(configMapByActive.get(ONLINE_JOIN_MODE.getMsg()).getKey(), JoinModeEnum.getByCode(shopInfo.getJoinMode()));
|
||||
extendField.put(configMapByActive.get(ONLINE_STORE_TYPE.getMsg()).getKey(), StoreTypeEnum.getMessage(shopInfo.getStoreType()));
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user