|
@ -12,11 +12,13 @@ import com.epmet.commons.tools.page.PageData; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
import com.epmet.dao.PointAdditiveRuleDao; |
|
|
import com.epmet.dao.PointAdditiveRuleDao; |
|
|
|
|
|
import com.epmet.dao.PointApplyDao; |
|
|
import com.epmet.dto.CategorydetailResultDTO; |
|
|
import com.epmet.dto.CategorydetailResultDTO; |
|
|
import com.epmet.dto.PointAdditiveRuleDTO; |
|
|
import com.epmet.dto.PointAdditiveRuleDTO; |
|
|
import com.epmet.dto.form.*; |
|
|
import com.epmet.dto.form.*; |
|
|
import com.epmet.dto.result.List4ApplyResultDTO; |
|
|
import com.epmet.dto.result.List4ApplyResultDTO; |
|
|
import com.epmet.entity.PointAdditiveRuleEntity; |
|
|
import com.epmet.entity.PointAdditiveRuleEntity; |
|
|
|
|
|
import com.epmet.entity.PointApplyEntity; |
|
|
import com.epmet.redis.PointAdditiveRuleRedis; |
|
|
import com.epmet.redis.PointAdditiveRuleRedis; |
|
|
import com.epmet.service.PointAdditiveRuleService; |
|
|
import com.epmet.service.PointAdditiveRuleService; |
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
@ -39,6 +41,9 @@ public class PointAdditiveRuleServiceImpl extends BaseServiceImpl<PointAdditiveR |
|
|
@Autowired |
|
|
@Autowired |
|
|
private PointAdditiveRuleRedis pointAdditiveRuleRedis; |
|
|
private PointAdditiveRuleRedis pointAdditiveRuleRedis; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private PointApplyDao pointApplyDao; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public PageData<PointAdditiveRuleDTO> page(Map<String, Object> params) { |
|
|
public PageData<PointAdditiveRuleDTO> page(Map<String, Object> params) { |
|
|
IPage<PointAdditiveRuleEntity> page = baseDao.selectPage( |
|
|
IPage<PointAdditiveRuleEntity> page = baseDao.selectPage( |
|
@ -88,6 +93,31 @@ public class PointAdditiveRuleServiceImpl extends BaseServiceImpl<PointAdditiveR |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public void delete(String[] ids) { |
|
|
public void delete(String[] ids) { |
|
|
// 逻辑删除(@TableLogic 注解)
|
|
|
// 逻辑删除(@TableLogic 注解)
|
|
|
|
|
|
for(String id : ids){ |
|
|
|
|
|
PointAdditiveRuleEntity entity = baseDao.selectById(id); |
|
|
|
|
|
if(null == entity){ |
|
|
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "未查到相关信息。","未查到相关信息。"); |
|
|
|
|
|
} |
|
|
|
|
|
if(PointAddRuleEnum.CATEGORY_TYPE.getCode().equals(entity.getType())){ |
|
|
|
|
|
//分类判断是否有下级
|
|
|
|
|
|
PointAdditiveRuleEntity queryData = new PointAdditiveRuleEntity(); |
|
|
|
|
|
queryData.setPid(entity.getId()); |
|
|
|
|
|
QueryWrapper<PointAdditiveRuleEntity> wrapper = new QueryWrapper<>(queryData); |
|
|
|
|
|
List<PointAdditiveRuleEntity> applyList = baseDao.selectList(wrapper); |
|
|
|
|
|
if(CollectionUtils.isNotEmpty(applyList)){ |
|
|
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "请先删除下级的积分规则。","请先删除下级的积分规则。"); |
|
|
|
|
|
} |
|
|
|
|
|
}else{ |
|
|
|
|
|
//判断其规则下面是否有待审核的积分申请,如果有则不允许修改/删除
|
|
|
|
|
|
PointApplyEntity queryData = new PointApplyEntity(); |
|
|
|
|
|
queryData.setRuleId(entity.getId()); |
|
|
|
|
|
QueryWrapper<PointApplyEntity> wrapper = new QueryWrapper<>(queryData); |
|
|
|
|
|
List<PointApplyEntity> applyList = pointApplyDao.selectList(wrapper); |
|
|
|
|
|
if(CollectionUtils.isNotEmpty(applyList)){ |
|
|
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "该规则下有积分申请尚未完成,请处理完成后再执行该操作。","该规则下有积分申请尚未完成,请处理完成后再执行该操作。"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -214,7 +244,7 @@ public class PointAdditiveRuleServiceImpl extends BaseServiceImpl<PointAdditiveR |
|
|
} |
|
|
} |
|
|
if(PointAddRuleEnum.CATEGORY_TYPE.getCode().equals(dto.getType())){ |
|
|
if(PointAddRuleEnum.CATEGORY_TYPE.getCode().equals(dto.getType())){ |
|
|
//类别
|
|
|
//类别
|
|
|
PointAdditiveRuleEntity isExist = baseDao.selectEntityByName(null,dto.getCustomerId(),dto.getCategoryName(),null); |
|
|
PointAdditiveRuleEntity isExist = baseDao.selectEntityByName(dto.getId(),dto.getCustomerId(),dto.getCategoryName(),null); |
|
|
if(isExist != null){ |
|
|
if(isExist != null){ |
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "该名称已存在","该名称已存在"); |
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "该名称已存在","该名称已存在"); |
|
|
} |
|
|
} |
|
@ -224,10 +254,20 @@ public class PointAdditiveRuleServiceImpl extends BaseServiceImpl<PointAdditiveR |
|
|
} |
|
|
} |
|
|
}else if(PointAddRuleEnum.RULE_TYPE.getCode().equals(dto.getType())){ |
|
|
}else if(PointAddRuleEnum.RULE_TYPE.getCode().equals(dto.getType())){ |
|
|
//规则
|
|
|
//规则
|
|
|
PointAdditiveRuleEntity isExist = baseDao.selectEntityByName(null,dto.getCustomerId(),null,dto.getRuleName()); |
|
|
//判断名称重复
|
|
|
|
|
|
PointAdditiveRuleEntity isExist = baseDao.selectEntityByName(dto.getId(),dto.getCustomerId(),null,dto.getRuleName()); |
|
|
if(isExist != null){ |
|
|
if(isExist != null){ |
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "该名称已存在","该名称已存在"); |
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "该名称已存在","该名称已存在"); |
|
|
} |
|
|
} |
|
|
|
|
|
//判断其规则下面是否有待审核的积分申请,如果有则不允许修改/删除
|
|
|
|
|
|
PointApplyEntity queryData = new PointApplyEntity(); |
|
|
|
|
|
queryData.setRuleId(entity.getId()); |
|
|
|
|
|
QueryWrapper<PointApplyEntity> wrapper = new QueryWrapper<>(queryData); |
|
|
|
|
|
List<PointApplyEntity> applyList = pointApplyDao.selectList(wrapper); |
|
|
|
|
|
if(CollectionUtils.isNotEmpty(applyList)){ |
|
|
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "该规则下有积分申请尚未完成,请处理完成后再执行该操作。","该规则下有积分申请尚未完成,请处理完成后再执行该操作。"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
entity.setRuleName(dto.getRuleName()); |
|
|
entity.setRuleName(dto.getRuleName()); |
|
|
entity.setPointValue(dto.getPointValue()); |
|
|
entity.setPointValue(dto.getPointValue()); |
|
|
entity.setApplyFlag(dto.getApplyFlag()); |
|
|
entity.setApplyFlag(dto.getApplyFlag()); |
|
|