Commit 3eec995d by 刘宇峰

特约店、围栏bug修复

1 parent c44066ad
...@@ -54,7 +54,7 @@ public enum ResultEnum { ...@@ -54,7 +54,7 @@ public enum ResultEnum {
/** /**
* 特约店围栏管理相关业务异常错误码,错误信息 1214开头 * 特约店围栏管理相关业务异常错误码,错误信息 1214开头
*/ */
TRIAL_DRIVE_SHOP_EXISTED(121430001, "此特约店已存在"), TRIAL_DRIVE_SHOP_EXISTED(121430001, "特约店已存在"),
TRIAL_DRIVE_SHOP_FENCE_EXISTED(121430002, "特约店围栏名称已存在") TRIAL_DRIVE_SHOP_FENCE_EXISTED(121430002, "特约店围栏名称已存在")
; ;
......
...@@ -22,6 +22,8 @@ public interface TrialDriveShopMapper extends CommonBaseMapper<TrialDriveShop> { ...@@ -22,6 +22,8 @@ public interface TrialDriveShopMapper extends CommonBaseMapper<TrialDriveShop> {
TrialDriveShop selectById(@Param("id") Long id); TrialDriveShop selectById(@Param("id") Long id);
TrialDriveShop selectByUserId(@Param("userId") Long userId);
/** /**
* 逻辑删除 * 逻辑删除
* *
......
...@@ -32,6 +32,8 @@ import org.apache.commons.collections4.CollectionUtils; ...@@ -32,6 +32,8 @@ import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date; import java.util.Date;
...@@ -40,8 +42,12 @@ import java.util.stream.Collectors; ...@@ -40,8 +42,12 @@ import java.util.stream.Collectors;
@Slf4j @Slf4j
@Service @Service
@RefreshScope
public class TrialDriveShopService { public class TrialDriveShopService {
@Value("${specialshop.user.level:4}")
private Integer shopUserLevel;
@Autowired @Autowired
private TrialDriveShopMapper trialDriveShopMapper; private TrialDriveShopMapper trialDriveShopMapper;
...@@ -145,16 +151,30 @@ public class TrialDriveShopService { ...@@ -145,16 +151,30 @@ public class TrialDriveShopService {
* @param updateFlag * @param updateFlag
*/ */
public void checkTrialDriveShop(TrialDriveShopBO shopBO, boolean updateFlag) { public void checkTrialDriveShop(TrialDriveShopBO shopBO, boolean updateFlag) {
//1、特约店和账号 //1、特约店和账号一一对应
//2、特约店和特约店围栏 //2、特约店和特约店围栏一一对应
TrialDriveShop shop = trialDriveShopMapper.selectByUserId(shopBO.getSpecialShopId());
if (updateFlag) { if (updateFlag) {
TrialDriveShop trialDriveShop = trialDriveShopMapper.selectById(shopBO.getId()); TrialDriveShop trialDriveShop = trialDriveShopMapper.selectById(shopBO.getId());
//编辑的审核 选了已经建了特约店围栏的特约店(账号)
if (shop != null && !shop.getId().equals(trialDriveShop.getId())) {
throw new AdminException(ResultEnum.TRIAL_DRIVE_SHOP_EXISTED);
}
//名称已存在
ElectricFence existedFence = electricFenceMapper.selectByFenceNameAndBizType(shopBO.getFenceName(), BizFenceTypeEnum.TRIAL_DRIVE_SHOP.getCode()); ElectricFence existedFence = electricFenceMapper.selectByFenceNameAndBizType(shopBO.getFenceName(), BizFenceTypeEnum.TRIAL_DRIVE_SHOP.getCode());
if (existedFence != null && !trialDriveShop.getFenceId().equals(existedFence.getId())) { if (existedFence != null && !trialDriveShop.getFenceId().equals(existedFence.getId())) {
throw new AdminException(ResultEnum.TRIAL_DRIVE_SHOP_FENCE_EXISTED); throw new AdminException(ResultEnum.TRIAL_DRIVE_SHOP_FENCE_EXISTED);
} }
} else { } else {
//账号已经新建过特约店围栏
if (shop != null) {
throw new AdminException(ResultEnum.TRIAL_DRIVE_SHOP_EXISTED);
}
//名称已存在
ElectricFence existedFence = electricFenceMapper.selectByFenceNameAndBizType(shopBO.getFenceName(), BizFenceTypeEnum.TRIAL_DRIVE_SHOP.getCode()); ElectricFence existedFence = electricFenceMapper.selectByFenceNameAndBizType(shopBO.getFenceName(), BizFenceTypeEnum.TRIAL_DRIVE_SHOP.getCode());
if (existedFence != null) { if (existedFence != null) {
throw new AdminException(ResultEnum.TRIAL_DRIVE_SHOP_FENCE_EXISTED); throw new AdminException(ResultEnum.TRIAL_DRIVE_SHOP_FENCE_EXISTED);
...@@ -207,6 +227,7 @@ public class TrialDriveShopService { ...@@ -207,6 +227,7 @@ public class TrialDriveShopService {
//围栏信息 //围栏信息
detailsDTO.setFenceName(fence.getFenceName()); detailsDTO.setFenceName(fence.getFenceName());
detailsDTO.setAddress(fence.getAnalysisAddress());
if (StringUtils.isNotEmpty(fence.getLnglat())) { if (StringUtils.isNotEmpty(fence.getLnglat())) {
detailsDTO.setLng(fence.getLnglat().split(",")[0]); detailsDTO.setLng(fence.getLnglat().split(",")[0]);
detailsDTO.setLat(fence.getLnglat().split(",")[1]); detailsDTO.setLat(fence.getLnglat().split(",")[1]);
...@@ -241,7 +262,7 @@ public class TrialDriveShopService { ...@@ -241,7 +262,7 @@ public class TrialDriveShopService {
} }
public List<Organization> getShopOrgs() { public List<Organization> getShopOrgs() {
R<List<Organization>> orgListR = organizationService.getSpecialLevelOrganizations(4); R<List<Organization>> orgListR = organizationService.getSpecialLevelOrganizations(shopUserLevel);
List<Organization> orgList = orgListR.getDataList(new TypeToken<List<Organization>>() { List<Organization> orgList = orgListR.getDataList(new TypeToken<List<Organization>>() {
}.getType()); }.getType());
return orgList; return orgList;
...@@ -295,6 +316,7 @@ public class TrialDriveShopService { ...@@ -295,6 +316,7 @@ public class TrialDriveShopService {
/** /**
* 判断是否是特约店 true 是 * 判断是否是特约店 true 是
*
* @return * @return
*/ */
public boolean isShopUser() { public boolean isShopUser() {
......
...@@ -108,6 +108,14 @@ ...@@ -108,6 +108,14 @@
and ttds.id = #{id} and ttds.id = #{id}
</select> </select>
<select id="selectByUserId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_trial_drive_shop ttds
where ttds.del_flag = 0
and ttds.created_by = #{userId}
</select>
<select id="selectByShopName" resultMap="BaseResultMap"> <select id="selectByShopName" resultMap="BaseResultMap">
select select
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!