数据处理代码+同步加盟商
This commit is contained in:
@@ -69,6 +69,7 @@ public enum UserRoleEnum {
|
||||
|
||||
JING_DONG_OPERATIONS_CUSTOMER(500000000L,"京东运营大区客服"),
|
||||
JING_DONG_HEADQUARTERS_BUILD_CUSTOMER(510000000L,"京东总部建店客服"),
|
||||
FRANCHISEES(530000000L,"加盟商")
|
||||
;
|
||||
|
||||
private Long code;
|
||||
|
||||
@@ -59,7 +59,7 @@ public class RedisUtilPool {
|
||||
try {
|
||||
result = execute();
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException("Redis execute exception", e);
|
||||
throw new RuntimeException("Redis execute exception", e);
|
||||
} finally {
|
||||
if (jedis != null) {
|
||||
jedis.close();
|
||||
|
||||
@@ -195,4 +195,10 @@ public class RegionDao {
|
||||
}
|
||||
return regionMapper.getSubRegionByParentIdAndRegionType(regionId, regionType);
|
||||
}
|
||||
public List<RegionDO> getRegionByNameListAndIsPath (List<String> name){
|
||||
if (CollectionUtils.isEmpty(name)){
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
return regionMapper.getRegionByNameListAndIsPath(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.cool.store.dao;
|
||||
|
||||
import com.cool.store.constants.CommonConstants;
|
||||
import com.cool.store.dto.FranchiseReportDTO;
|
||||
import com.cool.store.dto.IsCreateStoreDTO;
|
||||
import com.cool.store.dto.LicenseSyncDTO;
|
||||
import com.cool.store.dto.Preparation.PreparationDTO;
|
||||
import com.cool.store.dto.openPreparation.OpenPlanShopInfoDTO;
|
||||
@@ -307,4 +308,30 @@ public class ShopInfoDAO {
|
||||
example.createCriteria().andEqualTo("lineId", lineId).andIn("shopStatus", shopStatus).andEqualTo("deleted", false);
|
||||
return shopInfoMapper.selectByExample(example);
|
||||
}
|
||||
/**
|
||||
* @Auther: wangshuo
|
||||
* @Date: 2025/7/11
|
||||
* @description:查询建店资料完成并且已经在标品已经建店是门店
|
||||
*/
|
||||
public List<IsCreateStoreDTO> selectIsCreateStore(){
|
||||
return shopInfoMapper.selectIsCreateStore();
|
||||
}
|
||||
/**
|
||||
* @Auther: wangshuo
|
||||
* @Date: 2025/7/11
|
||||
* @description: 查询未建店
|
||||
*/
|
||||
public List<ShopInfoDO> selectByNotCreateStore(List<Long> isCreateShopIds){
|
||||
Example example = new Example(ShopInfoDO.class);
|
||||
example.createCriteria().
|
||||
andNotIn("id", isCreateShopIds).andNotEqualTo("shopStatus", 2).andEqualTo("deleted", false)
|
||||
.andNotEqualTo("region_id",459);
|
||||
return shopInfoMapper.selectByExample(example);
|
||||
}
|
||||
public Integer updateManagerRegionId(List<ShopInfoDO> shopList){
|
||||
if (CollectionUtils.isEmpty(shopList)){
|
||||
return 0;
|
||||
}
|
||||
return shopInfoMapper.updateManagerRegionId(shopList);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,4 +113,6 @@ public interface RegionMapper {
|
||||
RegionDO getRegionInfoBySynDingDeptId(@Param("synDingDeptId") Long synDingDeptId);
|
||||
|
||||
List<RegionResponse> getSubRegionByParentIdAndRegionType( @Param("regionId")Long regionId, @Param("regionType")String regionType);
|
||||
|
||||
List<RegionDO> getRegionByNameListAndIsPath(@Param("regionNameList") List<String> regionNameList);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.cool.store.mapper;
|
||||
|
||||
import com.cool.store.dto.FranchiseReportDTO;
|
||||
import com.cool.store.dto.IsCreateStoreDTO;
|
||||
import com.cool.store.dto.LicenseSyncDTO;
|
||||
import com.cool.store.dto.Preparation.PreparationDTO;
|
||||
import com.cool.store.dto.openPreparation.OpenPlanShopInfoDTO;
|
||||
@@ -142,4 +143,7 @@ public interface ShopInfoMapper extends Mapper<ShopInfoDO> {
|
||||
Integer updateShopCity(@Param("list") List<ShopInfoDO> list);
|
||||
|
||||
List<FranchiseReportDTO> getShopFranchiseReportList(@Param("request") FranchiseReportRequest request);
|
||||
|
||||
List<IsCreateStoreDTO> selectIsCreateStore();
|
||||
Integer updateManagerRegionId(@Param("list") List<ShopInfoDO> shopList);
|
||||
}
|
||||
|
||||
@@ -428,6 +428,17 @@
|
||||
and parent_id = #{regionId}
|
||||
and region_type = #{regionType}
|
||||
</select>
|
||||
<select id="getRegionByNameListAndIsPath" resultType="com.cool.store.entity.RegionDO">
|
||||
select <include refid="fields"/>
|
||||
from region_${enterpriseId}
|
||||
where deleted = 0
|
||||
<if test="regionNameList != null and regionNameList.size() >0">
|
||||
and name in (
|
||||
<foreach collection="regionNameList" separator="," item="region">#{region}</foreach>
|
||||
)
|
||||
</if>
|
||||
and region_type = 'path'
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -543,13 +543,20 @@
|
||||
and xsi.shop_name Like concat("%",#{keyWord},"%") or xsi.store_num Like concat("%",#{keyWord},"%")
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectIsCreateStore" resultType="com.cool.store.entity.ShopInfoDO">
|
||||
SELECT a.`shop_name` ,a.`shop_code` ,b.*
|
||||
<select id="selectIsCreateStore" resultType="com.cool.store.dto.IsCreateStoreDTO">
|
||||
|
||||
SELECT a.id as shopId, c.parent_id as `pid`
|
||||
FROM xfsg_shop_info a
|
||||
LEFT JOIN store_214ac5a3a517472a87268e02a2e6410a b ON a.shop_code = b.store_num
|
||||
LEFT JOIN xfsg_shop_stage_info c ON c.shop_id = a.id
|
||||
WHERE b.store_num is not null and a.shop_code is not null and a.deleted =0 and a.shop_status != 2 and a.shop_code != '' and c.shop_sub_stage_status in (1560)
|
||||
|
||||
LEFT JOIN `region_214ac5a3a517472a87268e02a2e6410a` c on b.region_id = c.`id`
|
||||
WHERE b.store_num is not null
|
||||
and a.shop_code is not null
|
||||
and a.deleted =0
|
||||
and a.shop_status != 2
|
||||
and a.shop_code != ""
|
||||
and c.deleted = 0
|
||||
and b.is_delete = 'effective'
|
||||
and a.region_id != 459
|
||||
</select>
|
||||
|
||||
<update id="batchUpdate" parameterType="list">
|
||||
@@ -573,4 +580,9 @@
|
||||
update xfsg_shop_info set shop_name = #{item.shopName}, province =#{item.province}, city = #{item.city}, district=#{item.district}, detail_address = #{item.detailAddress} where id = #{item.id}
|
||||
</foreach>
|
||||
</update>
|
||||
<update id="updateManagerRegionId">
|
||||
<foreach collection="list" item="item" separator=";">
|
||||
update xfsg_shop_info set manager_region_id = #{item.managerRegionId} where id = #{item.id}
|
||||
</foreach>
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.cool.store.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author: WangShuo
|
||||
* @Date: 2025/07/11/16:02
|
||||
* @Version 1.0
|
||||
* @注释:
|
||||
*/
|
||||
@Data
|
||||
public class IsCreateStoreDTO {
|
||||
|
||||
private Long shopId;
|
||||
|
||||
private Long pid;
|
||||
|
||||
private String pidName;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.cool.store.request;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cool.store.userholder.CurrentUser;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
@@ -88,4 +89,11 @@ public class StoreRequestBody {
|
||||
private Long brandId;
|
||||
|
||||
private String eid;
|
||||
//加盟商手机号
|
||||
private String partnerMobile;
|
||||
|
||||
private String partnerName;
|
||||
//加盟商职位 id
|
||||
private Long partnerRoleId;
|
||||
|
||||
}
|
||||
|
||||
@@ -81,5 +81,6 @@ public interface DataHandlerServer {
|
||||
* @Date: 2025/7/11
|
||||
* @description:处理老数据 已经建店并且在标品中也建店的数据 处理所属管理区域
|
||||
*/
|
||||
void dataHandlerCreateStore();
|
||||
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user