|
|
@@ -52,8 +52,6 @@ public class SysCustomerDataService {
|
|
|
|
|
|
private final SysUserMapper sysUserMapper;
|
|
|
|
|
|
- private final SysParamMapper sysParamMapper;
|
|
|
-
|
|
|
private final RedisMQTemplate redisMQTemplate;
|
|
|
|
|
|
private final RedisTemplate<String, Object> stringSetRedisTemplate;
|
|
|
@@ -219,16 +217,20 @@ public class SysCustomerDataService {
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void claimCustomer(Long customerId) throws BusinessException {
|
|
|
|
|
|
- SysParamEntity sysParamEntity =
|
|
|
- sysParamMapper.selectOne(
|
|
|
- new LambdaQueryWrapper<>(SysParamEntity.class)
|
|
|
- );
|
|
|
- if (sysParamEntity == null) {
|
|
|
- throw new BusinessException(400, "参数配置未设置");
|
|
|
+// SysParamEntity sysParamEntity =
|
|
|
+// sysParamMapper.selectOne(
|
|
|
+// new LambdaQueryWrapper<>(SysParamEntity.class)
|
|
|
+// );
|
|
|
+// if (sysParamEntity == null) {
|
|
|
+// throw new BusinessException(400, "参数配置未设置");
|
|
|
+// }
|
|
|
+ SysUserEntity sysUserEntity = sysUserMapper.selectById(UserContextHolder.getUserId());
|
|
|
+ if (sysUserEntity == null) {
|
|
|
+ throw new BusinessException(400, "用户不存在");
|
|
|
}
|
|
|
// 客户持有上限判断
|
|
|
- if(!UserContextHolder.getUserContext().getRoles().contains("Admin")){
|
|
|
- if (sysParamEntity.getHoldTopCount() != null && sysParamEntity.getHoldTopCount() > 0) {
|
|
|
+ if (!UserContextHolder.getUserContext().getRoles().contains("Admin")) {
|
|
|
+ if (sysUserEntity.getHoldTopCount() != null && sysUserEntity.getHoldTopCount() > 0) {
|
|
|
long customerCount =
|
|
|
sysCustomerDataMapper.selectCount(
|
|
|
new LambdaQueryWrapper<>(SysCustomerDataEntity.class)
|
|
|
@@ -237,7 +239,7 @@ public class SysCustomerDataService {
|
|
|
)
|
|
|
.eq(SysCustomerDataEntity::getClaimUserId, UserContextHolder.getUserId())
|
|
|
);
|
|
|
- if (customerCount > 0 && customerCount > sysParamEntity.getHoldTopCount()) {
|
|
|
+ if (customerCount > 0 && customerCount > sysUserEntity.getHoldTopCount()) {
|
|
|
throw new BusinessException(400, "认领数量已超过设定的持有数量上限,不能再进行认领操作");
|
|
|
}
|
|
|
}
|
|
|
@@ -292,8 +294,8 @@ public class SysCustomerDataService {
|
|
|
sysCustomerOperLogMapper.insert(logEntity);
|
|
|
|
|
|
//添加自动退回定时任务
|
|
|
- if (sysParamEntity.getBackPublicDayCount() != null && sysParamEntity.getBackPublicDayCount() > 0) {
|
|
|
- Integer backPublicDayCount = sysParamEntity.getBackPublicDayCount();//单位为 天
|
|
|
+ if (sysUserEntity.getBackPublicDayCount() != null && sysUserEntity.getBackPublicDayCount() > 0) {
|
|
|
+ Integer backPublicDayCount = sysUserEntity.getBackPublicDayCount();//单位为 天
|
|
|
DateTime date = DateUtil.date();
|
|
|
//结束的时间
|
|
|
DateTime dateTime = DateUtil.offsetDay(date, backPublicDayCount);
|
|
|
@@ -329,15 +331,19 @@ public class SysCustomerDataService {
|
|
|
}
|
|
|
}
|
|
|
// 每日手动退回公海上限判断
|
|
|
- if(!UserContextHolder.getUserContext().getRoles().contains("Admin")){
|
|
|
- SysParamEntity sysParamEntity =
|
|
|
- sysParamMapper.selectOne(
|
|
|
- new LambdaQueryWrapper<>(SysParamEntity.class)
|
|
|
- );
|
|
|
- if (sysParamEntity == null) {
|
|
|
- throw new BusinessException(400, "参数配置未设置");
|
|
|
+ if (!UserContextHolder.getUserContext().getRoles().contains("Admin")) {
|
|
|
+// SysParamEntity sysParamEntity =
|
|
|
+// sysParamMapper.selectOne(
|
|
|
+// new LambdaQueryWrapper<>(SysParamEntity.class)
|
|
|
+// );
|
|
|
+// if (sysParamEntity == null) {
|
|
|
+// throw new BusinessException(400, "参数配置未设置");
|
|
|
+// }
|
|
|
+ SysUserEntity sysUserEntity = sysUserMapper.selectById(UserContextHolder.getUserId());
|
|
|
+ if (sysUserEntity == null) {
|
|
|
+ throw new BusinessException(400, "用户不存在");
|
|
|
}
|
|
|
- if (sysParamEntity.getDayBackTopCount() != null && sysParamEntity.getDayBackTopCount() > 0) {
|
|
|
+ if (sysUserEntity.getDayBackTopCount() != null && sysUserEntity.getDayBackTopCount() > 0) {
|
|
|
String key = "return_customer_data_" + sysCustomerDataEntity.getClaimUserId();
|
|
|
//先从redis中获取当日退回公海次数
|
|
|
Object count = stringSetRedisTemplate.opsForValue().get(key);
|
|
|
@@ -350,9 +356,9 @@ public class SysCustomerDataService {
|
|
|
stringSetRedisTemplate.opsForValue().set(key, 1, between, TimeUnit.SECONDS);
|
|
|
}
|
|
|
} else {
|
|
|
- if ((Integer) count <= sysParamEntity.getDayBackTopCount()) {
|
|
|
+ if ((Integer) count <= sysUserEntity.getDayBackTopCount()) {
|
|
|
stringSetRedisTemplate.opsForValue().increment(key);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
throw new BusinessException(400, "操作失败,已超过每日手动退回公海上限");
|
|
|
}
|
|
|
}
|