|
|
@@ -134,18 +134,39 @@ public class MyResourceServiceImpl extends ServiceImpl<MyResourceMapper, MyResou
|
|
|
System.out.println("=== 标签关联保存完成 ===");
|
|
|
}
|
|
|
|
|
|
- // 资源录入成功后,为红娘添加积分奖励
|
|
|
+ // 资源录入成功后,为红娘添加积分奖励(阶梯奖励)
|
|
|
if (result && myResource.getMatchmakerId() != null && pointsManageService != null) {
|
|
|
try {
|
|
|
String resourceName = myResource.getName() != null ? myResource.getName() : "未知";
|
|
|
- // 使用规则类型2(上传线索)添加积分
|
|
|
- boolean pointsAdded = pointsManageService.addPointsByRuleType(
|
|
|
+
|
|
|
+ // 查询红娘当日已上传的资源数量(包括刚录入的这条)
|
|
|
+ int todayCount = getTodayResourceCount(myResource.getMatchmakerId());
|
|
|
+
|
|
|
+ // 计算阶梯积分:基础10分,超3人+2分,超10人+5分
|
|
|
+ int basePoints = 10;
|
|
|
+ int bonusPoints = 0;
|
|
|
+ if (todayCount > 10) {
|
|
|
+ bonusPoints = 5; // 超过10人,每个额外+5分
|
|
|
+ } else if (todayCount > 3) {
|
|
|
+ bonusPoints = 2; // 超过3人,每个额外+2分
|
|
|
+ }
|
|
|
+ int totalPoints = basePoints + bonusPoints;
|
|
|
+
|
|
|
+ String reason = "录入资源: " + resourceName + " (今日第" + todayCount + "个";
|
|
|
+ if (bonusPoints > 0) {
|
|
|
+ reason += ",额外奖励+" + bonusPoints;
|
|
|
+ }
|
|
|
+ reason += ")";
|
|
|
+
|
|
|
+ // 直接添加计算后的积分
|
|
|
+ boolean pointsAdded = pointsManageService.addPoints(
|
|
|
myResource.getMatchmakerId(),
|
|
|
- 2, // 规则类型2 = 上传线索
|
|
|
- "录入资源: " + resourceName
|
|
|
+ totalPoints,
|
|
|
+ reason
|
|
|
);
|
|
|
if (pointsAdded) {
|
|
|
- System.out.println("✅ 资源录入积分奖励添加成功,红娘ID: " + myResource.getMatchmakerId());
|
|
|
+ System.out.println("✅ 资源录入积分奖励添加成功,红娘ID: " + myResource.getMatchmakerId() +
|
|
|
+ ",今日第" + todayCount + "个,获得" + totalPoints + "积分");
|
|
|
} else {
|
|
|
System.out.println("⚠️ 资源录入积分奖励添加失败,红娘ID: " + myResource.getMatchmakerId());
|
|
|
}
|
|
|
@@ -158,6 +179,37 @@ public class MyResourceServiceImpl extends ServiceImpl<MyResourceMapper, MyResou
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取红娘当日已上传的资源数量
|
|
|
+ * @param matchmakerId 红娘ID
|
|
|
+ * @return 当日上传数量
|
|
|
+ */
|
|
|
+ private int getTodayResourceCount(Integer matchmakerId) {
|
|
|
+ if (matchmakerId == null) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取今天的开始时间和结束时间
|
|
|
+ java.util.Calendar calendar = java.util.Calendar.getInstance();
|
|
|
+ calendar.set(java.util.Calendar.HOUR_OF_DAY, 0);
|
|
|
+ calendar.set(java.util.Calendar.MINUTE, 0);
|
|
|
+ calendar.set(java.util.Calendar.SECOND, 0);
|
|
|
+ calendar.set(java.util.Calendar.MILLISECOND, 0);
|
|
|
+ Date todayStart = calendar.getTime();
|
|
|
+
|
|
|
+ calendar.add(java.util.Calendar.DAY_OF_MONTH, 1);
|
|
|
+ Date todayEnd = calendar.getTime();
|
|
|
+
|
|
|
+ // 查询当日该红娘上传的资源数量
|
|
|
+ QueryWrapper<MyResource> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("matchmaker_id", matchmakerId)
|
|
|
+ .ge("create_time", todayStart)
|
|
|
+ .lt("create_time", todayEnd);
|
|
|
+
|
|
|
+ long count = this.count(queryWrapper);
|
|
|
+ return (int) count;
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
public Page<MyResource> getResourceList(Integer matchmakerId, String keyword, Integer pageNum, Integer pageSize) {
|