getBigRegionIdByAreaId
This commit is contained in:
@@ -41,4 +41,11 @@ public class RegionAreaConfigDao {
|
||||
return regionAreaConfigMapper.listAreaByRegionId(regionId);
|
||||
}
|
||||
|
||||
public Long getByWantShopAreaId(Long wantShopAreaId){
|
||||
if (wantShopAreaId == null) {
|
||||
return 0L;
|
||||
}
|
||||
return regionAreaConfigMapper.getByWantShopAreaId(wantShopAreaId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -45,4 +45,6 @@ public interface RegionAreaConfigMapper {
|
||||
|
||||
List<RegionAreaConfigDO> listAreaByRegionId(@Param("regionId") Long regionId);
|
||||
|
||||
Long getByWantShopAreaId(@Param("wantShopAreaId") Long wantShopAreaId);
|
||||
|
||||
}
|
||||
@@ -170,4 +170,10 @@
|
||||
from xfsg_region_area_config
|
||||
where region_id = #{regionId}
|
||||
</select>
|
||||
|
||||
<select id="getByWantShopAreaId" resultType="java.lang.Long">
|
||||
select region_id
|
||||
from xfsg_region_area_config
|
||||
where want_shop_area_id = #{wantShopAreaId}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -6,4 +6,11 @@ public interface RegionService {
|
||||
|
||||
RegionPathNameVO getAllRegionName(Long regionId);
|
||||
|
||||
/**
|
||||
* 根据意向区域找大区id
|
||||
* @param wantShopAreaId
|
||||
* @return
|
||||
*/
|
||||
Long getBigRegionIdByAreaId(Long wantShopAreaId);
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ 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.RegionAreaConfigDao;
|
||||
import com.cool.store.dao.RegionDao;
|
||||
import com.cool.store.entity.RegionDO;
|
||||
import com.cool.store.enums.ErrorCodeEnum;
|
||||
import com.cool.store.exception.ServiceException;
|
||||
@@ -36,6 +38,11 @@ public class RegionServiceImpl implements RegionService {
|
||||
private RedisUtilPool redisUtilPool;
|
||||
@Resource
|
||||
private RegionMapper regionMapper;
|
||||
@Resource
|
||||
private RegionDao regionDao;
|
||||
@Resource
|
||||
private RegionAreaConfigDao regionAreaConfigDao;
|
||||
|
||||
|
||||
@Override
|
||||
public RegionPathNameVO getAllRegionName(Long regionId) {
|
||||
@@ -79,4 +86,32 @@ public class RegionServiceImpl implements RegionService {
|
||||
redisUtilPool.setString(redisConstantUtil.getRegionNameListKey(String.valueOf(regionId)), JSONUtil.toJsonStr(regionPathNameVO), 5 * 60);
|
||||
return regionPathNameVO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据意向区域找大区id
|
||||
* @param wantShopAreaId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Long getBigRegionIdByAreaId(Long wantShopAreaId) {
|
||||
// 根据意向省市获取战区id
|
||||
Long warRegionId = regionAreaConfigDao.getByWantShopAreaId(wantShopAreaId);
|
||||
if(Objects.isNull(warRegionId)){
|
||||
return 0L;
|
||||
}
|
||||
RegionDO warRegion = regionMapper.getByRegionId(warRegionId);
|
||||
if(warRegion == null){
|
||||
throw new ServiceException(ErrorCodeEnum.REGION_NOT_EXIST);
|
||||
}
|
||||
// 根据战区id获取大区id
|
||||
String warRegionPath = warRegion.getRegionPath().substring(1, warRegion.getRegionPath().length() - 1);
|
||||
String[] warRegionIdArr = warRegionPath.split(Constants.FORWARD_SLASH);
|
||||
List<RegionDO> regionDOList = regionMapper.getRegionByRegionIds(Arrays.asList(warRegionIdArr));
|
||||
for (RegionDO regionDO : regionDOList){
|
||||
if(regionDO.getRegionType().equals("大区")){
|
||||
return regionDO.getId();
|
||||
}
|
||||
}
|
||||
return 0L;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user