Commit 3eec995d by 刘宇峰

特约店、围栏bug修复

1 parent c44066ad
......@@ -54,7 +54,7 @@ public enum ResultEnum {
/**
* 特约店围栏管理相关业务异常错误码,错误信息 1214开头
*/
TRIAL_DRIVE_SHOP_EXISTED(121430001, "此特约店已存在"),
TRIAL_DRIVE_SHOP_EXISTED(121430001, "特约店已存在"),
TRIAL_DRIVE_SHOP_FENCE_EXISTED(121430002, "特约店围栏名称已存在")
;
......
......@@ -22,6 +22,8 @@ public interface TrialDriveShopMapper extends CommonBaseMapper<TrialDriveShop> {
TrialDriveShop selectById(@Param("id") Long id);
TrialDriveShop selectByUserId(@Param("userId") Long userId);
/**
* 逻辑删除
*
......
......@@ -32,6 +32,8 @@ import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
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 java.util.Date;
......@@ -40,8 +42,12 @@ import java.util.stream.Collectors;
@Slf4j
@Service
@RefreshScope
public class TrialDriveShopService {
@Value("${specialshop.user.level:4}")
private Integer shopUserLevel;
@Autowired
private TrialDriveShopMapper trialDriveShopMapper;
......@@ -145,16 +151,30 @@ public class TrialDriveShopService {
* @param updateFlag
*/
public void checkTrialDriveShop(TrialDriveShopBO shopBO, boolean updateFlag) {
//1、特约店和账号
//2、特约店和特约店围栏
//1、特约店和账号一一对应
//2、特约店和特约店围栏一一对应
TrialDriveShop shop = trialDriveShopMapper.selectByUserId(shopBO.getSpecialShopId());
if (updateFlag) {
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());
if (existedFence != null && !trialDriveShop.getFenceId().equals(existedFence.getId())) {
throw new AdminException(ResultEnum.TRIAL_DRIVE_SHOP_FENCE_EXISTED);
}
} else {
//账号已经新建过特约店围栏
if (shop != null) {
throw new AdminException(ResultEnum.TRIAL_DRIVE_SHOP_EXISTED);
}
//名称已存在
ElectricFence existedFence = electricFenceMapper.selectByFenceNameAndBizType(shopBO.getFenceName(), BizFenceTypeEnum.TRIAL_DRIVE_SHOP.getCode());
if (existedFence != null) {
throw new AdminException(ResultEnum.TRIAL_DRIVE_SHOP_FENCE_EXISTED);
......@@ -207,6 +227,7 @@ public class TrialDriveShopService {
//围栏信息
detailsDTO.setFenceName(fence.getFenceName());
detailsDTO.setAddress(fence.getAnalysisAddress());
if (StringUtils.isNotEmpty(fence.getLnglat())) {
detailsDTO.setLng(fence.getLnglat().split(",")[0]);
detailsDTO.setLat(fence.getLnglat().split(",")[1]);
......@@ -241,7 +262,7 @@ public class TrialDriveShopService {
}
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>>() {
}.getType());
return orgList;
......@@ -295,6 +316,7 @@ public class TrialDriveShopService {
/**
* 判断是否是特约店 true 是
*
* @return
*/
public boolean isShopUser() {
......@@ -302,5 +324,5 @@ public class TrialDriveShopService {
boolean userFlag = shopOrgIds.contains(ShieldContextHolder.getDepartmentId());
return userFlag;
}
}
......@@ -108,6 +108,14 @@
and ttds.id = #{id}
</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
<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!