Przeglądaj źródła

feat: 做任务添加60周岁校验

lixuesong 1 rok temu
rodzic
commit
fc01c10749

+ 13 - 36
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/controller/ApiController.java

@@ -899,9 +899,13 @@ public class ApiController {
 			}
 
 			// 超60周岁是否提醒
-			String ageReminderInfo = this.sixtyYearsOldReminder(sysU);
-			mapOne.put("ageReminder", Boolean.TRUE.equals(sysU.getAgeReminder()) && StrUtil.isNotBlank(ageReminderInfo));
-			mapOne.put("ageReminderInfo", ageReminderInfo);
+			Map<String, String> checkResult = sysUserService.checkSixtyYearsOld(sysU);
+			mapOne.put("ageReminder", Boolean.TRUE.equals(sysU.getAgeReminder()) && CollUtil.isNotEmpty(checkResult));
+			if (CollUtil.isNotEmpty(checkResult)) {
+				mapOne.put("ageReminderInfo", CollUtil.get(checkResult.values(), 0));
+			} else {
+				mapOne.put("ageReminderInfo", null);
+			}
 
 			// 获取发起认证的令牌
 			String randomStr;
@@ -3811,6 +3815,12 @@ public class ApiController {
 					}
 				}
 
+				// 校验超过60周岁,不能做任务
+				Map<String, String> checkResult = sysUserService.checkSixtyYearsOld(BeanUtil.copyProperties(sysUser, UserVO.class));
+				if (CollUtil.isNotEmpty(checkResult) && checkResult.containsKey("OVER")) {
+					throw new RuntimeException(checkResult.get("OVER"));
+				}
+
 				// 查询任务类型启用状态
 				List<WmTaskSubmissionPercentRule> rules = wmTaskSubmissionPercentRuleService.list(Wrappers.<WmTaskSubmissionPercentRule>lambdaQuery()
 						.eq(WmTaskSubmissionPercentRule::getDeptId, sysUser.getDeptId())
@@ -4679,37 +4689,4 @@ public class ApiController {
 
 		return R.ok(sysUserService.updateById(user));
 	}
-
-	/**
-	 * 年龄超60周岁提醒
-	 *
-	 * @param userVO
-	 * @return {@link String}
-	 */
-	private String sixtyYearsOldReminder(UserVO userVO) {
-		String idCardNumber = userVO.getIdCardNumber();
-		if (IdcardUtil.isValidCard(idCardNumber)) {
-			// 当前日期
-			Calendar nowCal = Calendar.getInstance();
-			// 基于生日的日期,60周岁提前半年的时间
-			Calendar halfYearCal = IdcardUtil.getBirthDate(idCardNumber).toCalendar();
-			halfYearCal.add(Calendar.YEAR, 59);
-			halfYearCal.add(Calendar.MONTH, 6);
-			// 基于生日的日期,60周岁的时间
-			Calendar sixtyYearsOldYearCal = IdcardUtil.getBirthDate(idCardNumber).toCalendar();
-			sixtyYearsOldYearCal.add(Calendar.YEAR, 60);
-
-			if (sixtyYearsOldYearCal.compareTo(nowCal) > 0 && halfYearCal.compareTo(nowCal) <= 0) {
-				// 提前半年提醒,不满60周岁,但距离60周岁在半年内
-				return String.format("平台要求人员年龄在年满18岁未满60岁之间,您的账号将于%s年%s月%s日被停用,停用后将无法做任务或者资金结算,请知悉!",
-						sixtyYearsOldYearCal.get(Calendar.YEAR), sixtyYearsOldYearCal.get(Calendar.MONTH) + 1, sixtyYearsOldYearCal.get(Calendar.DAY_OF_MONTH));
-			} else if (sixtyYearsOldYearCal.compareTo(nowCal) <= 0) {
-				// 已超过60周岁
-				return String.format("您的账号已于%s年%s月%s日因年龄超限被停用,请知悉",
-						sixtyYearsOldYearCal.get(Calendar.YEAR), sixtyYearsOldYearCal.get(Calendar.MONTH) + 1, sixtyYearsOldYearCal.get(Calendar.DAY_OF_MONTH));
-			}
-		}
-
-		return null;
-	}
 }

+ 8 - 0
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/service/SysUserService.java

@@ -154,4 +154,12 @@ public interface SysUserService extends IService<SysUser> {
 	 * @param subjectLocation 税源地
 	 */
 	void checkUserInfoToSettle(Collection<Integer> userIds, SubjectLocation subjectLocation);
+
+	/**
+	 * 校验是否超60周岁
+	 *
+	 * @param userVO 用户vo
+	 * @return 结果
+	 */
+	Map<String, String> checkSixtyYearsOld(UserVO userVO);
 }

+ 38 - 0
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/service/impl/SysUserServiceImpl.java

@@ -235,6 +235,44 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
 
 	}
 
+	/**
+	 * 校验是否超60周岁
+	 *
+	 * @param userVO 用户vo
+	 * @return 结果
+	 */
+	@Override
+	public Map<String, String> checkSixtyYearsOld(UserVO userVO) {
+		Map<String, String> result = new HashMap<>();
+
+		String idCardNumber = userVO.getIdCardNumber();
+		if (IdcardUtil.isValidCard(idCardNumber)) {
+			// 当前日期
+			Calendar nowCal = Calendar.getInstance();
+			// 基于生日的日期,60周岁提前半年的时间
+			Calendar halfYearCal = IdcardUtil.getBirthDate(idCardNumber).toCalendar();
+			halfYearCal.add(Calendar.YEAR, 59);
+			halfYearCal.add(Calendar.MONTH, 6);
+			// 基于生日的日期,60周岁的时间
+			Calendar sixtyYearsOldYearCal = IdcardUtil.getBirthDate(idCardNumber).toCalendar();
+			sixtyYearsOldYearCal.add(Calendar.YEAR, 60);
+
+			if (sixtyYearsOldYearCal.compareTo(nowCal) > 0 && halfYearCal.compareTo(nowCal) <= 0) {
+				// 提前半年提醒,不满60周岁,但距离60周岁在半年内
+				String format = String.format("平台要求人员年龄在年满18岁未满60岁之间,您的账号将于%s年%s月%s日被停用,停用后将无法做任务或者资金结算,请知悉!",
+						sixtyYearsOldYearCal.get(Calendar.YEAR), sixtyYearsOldYearCal.get(Calendar.MONTH) + 1, sixtyYearsOldYearCal.get(Calendar.DAY_OF_MONTH));
+				result.put("HALF_YEAR", format);
+			} else if (sixtyYearsOldYearCal.compareTo(nowCal) <= 0) {
+				// 已超过60周岁
+				String format = String.format("您的账号已于%s年%s月%s日因年龄超限被停用,请知悉",
+						sixtyYearsOldYearCal.get(Calendar.YEAR), sixtyYearsOldYearCal.get(Calendar.MONTH) + 1, sixtyYearsOldYearCal.get(Calendar.DAY_OF_MONTH));
+				result.put("OVER", format);
+			}
+		}
+
+		return result;
+	}
+
 	/**
 	 * 封装错误信息
 	 *

+ 6 - 0
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/service/impl/WmTaskContentServiceImpl.java

@@ -540,6 +540,12 @@ public class WmTaskContentServiceImpl extends ServiceImpl<WmTaskContentMapper, W
 		HnqzUser user = SecurityUtils.getUser();
 		UserVO sysU = sysUserService.selectUserVoById(user.getId());
 
+		// 校验超过60周岁,不能做任务
+		Map<String, String> checkResult = sysUserService.checkSixtyYearsOld(sysU);
+		if (CollUtil.isNotEmpty(checkResult) && checkResult.containsKey("OVER")) {
+			throw new RuntimeException(checkResult.get("OVER"));
+		}
+
 		List<WmScorePackageStatus> statusList = checkPackageStatus(sysU.getUserId(), tWmScorePackage.getId());
 
 		// 查询任务类型启用状态

+ 6 - 0
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/service/impl/WmUserSignServiceImpl.java

@@ -108,6 +108,12 @@ public class WmUserSignServiceImpl extends ServiceImpl<WmUserSignMapper, WmUserS
 		}
 		wmUserSign.setTaskTypeId(taskTypeId);
 
+		// 校验超过60周岁,不能做任务
+		Map<String, String> checkResult = sysUserService.checkSixtyYearsOld(sysU);
+		if (CollUtil.isNotEmpty(checkResult) && checkResult.containsKey("OVER")) {
+			throw new RuntimeException(checkResult.get("OVER"));
+		}
+
 		// 查询任务类型启用状态
 		List<WmTaskSubmissionPercentRule> taskTypeRules = wmTaskSubmissionPercentRuleService.list(Wrappers.<WmTaskSubmissionPercentRule>lambdaQuery()
 				.eq(WmTaskSubmissionPercentRule::getDeptId, sysU.getDeptId())