Эх сурвалжийг харах

feat: 积分包终止调整3

lixuesong 1 жил өмнө
parent
commit
22f8535d20

+ 6 - 0
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/controller/WmScorePackageController.java

@@ -2075,6 +2075,12 @@ public class WmScorePackageController {
 			return R.failed("参数错误");
 		}
 
+		String cacheKey = CacheConstants.TERMINATE_PACKAGE_KEY + wmScorePackage.getId();
+		Boolean absent = redisTemplate.opsForValue().setIfAbsent(cacheKey, JSONUtil.toJsonStr(wmScorePackage), 3L, TimeUnit.SECONDS);
+		if (Boolean.FALSE.equals(absent)) {
+			return R.failed("正在处理");
+		}
+
 		return R.ok(wmScorePackageService.terminatePackageForDept(wmScorePackage.getId(),
 				UpmsType.TerminatePackageType.getByEnableType(wmScorePackage.getEnableType())));
 	}

+ 7 - 1
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/service/impl/WmScorePackageServiceImpl.java

@@ -20,6 +20,7 @@ import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.util.DesensitizedUtil;
+import cn.hutool.core.util.NumberUtil;
 import cn.hutool.core.util.RandomUtil;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.csp.sentinel.util.StringUtil;
@@ -2885,7 +2886,6 @@ public class WmScorePackageServiceImpl extends ServiceImpl<WmScorePackageMapper,
 	@Transactional(rollbackFor = Exception.class)
 	public Boolean terminatePackageForPersonal(String packageId, UpmsType.TerminatePackageType terminatePackageType) {
 		Integer userId = SecurityUtils.getUser().getId();
-		Integer deptId = SecurityUtils.getUser().getDeptId();
 		LocalDateTime now = LocalDateTime.now();
 
 		// 查询积分包
@@ -3021,6 +3021,12 @@ public class WmScorePackageServiceImpl extends ServiceImpl<WmScorePackageMapper,
 		if (!StrUtil.equalsAny(scorePackage.getTypeid(), "0", "1", "2")) {
 			throw new RuntimeException("请选择企业承接的大包");
 		}
+		if (ScorePackageStatusEnum.TERMINATED.val().equals(scorePackage.getScorePackageStatus())) {
+			throw new RuntimeException("积分包已终止");
+		}
+		if (scorePackage.getKfpjf() <= 0) {
+			throw new RuntimeException("积分包已全部分派");
+		}
 
 		log.info("当前积分包终止前数据:{}", scorePackage);
 		if (UpmsType.TerminatePackageType.ALL.equals(terminatePackageType)) {