Browse Source

Merge branch 'release'

master
wanghaoran 11 months ago
parent
commit
192a16c565
1 changed files with 32 additions and 24 deletions
  1. +32
    -24
      tuoheng-api/src/main/java/com/tuoheng/api/service/points/receive/ReceivePonitsService.java

+ 32
- 24
tuoheng-api/src/main/java/com/tuoheng/api/service/points/receive/ReceivePonitsService.java View File

@@ -48,6 +48,16 @@ public class ReceivePonitsService {
return result;
}

WestreamKnowUser westreamKnowUser = westreamKnowUserMapper.selectOne(new LambdaQueryWrapper<WestreamKnowUser>()
.eq(WestreamKnowUser::getTenantId, request.getTenantId())
.eq(WestreamKnowUser::getOpenid, request.getOpenid())
.eq(WestreamKnowUser::getKnowId, request.getKnowId())
.eq(WestreamKnowUser::getMark, MarkEnum.VALID.getCode()));
if (ObjectUtil.isNotEmpty(westreamKnowUser)) {
log.info("您已获得过积分了,仅能获取一次积分。");
return JsonResult.error("您已获得过积分了,仅能获取一次积分。");
}

ThDict dict = dictMapper.selectOne(new LambdaQueryWrapper<ThDict>()
.eq(ThDict::getTenantId, request.getTenantId())
.eq(ThDict::getCode, DictEnum.POINTS_RULE.getCode())
@@ -70,7 +80,7 @@ public class ReceivePonitsService {
ThDictData dailyLimitWestreamSubmitDictData = dictDataMapper.selectOne(new LambdaQueryWrapper<ThDictData>()
.eq(ThDictData::getTenantId, request.getTenantId())
.eq(ThDictData::getDictId, dict.getId())
.eq(ThDictData::getName, DictDataEnum.DAILY_LIMIT_WESTREAM_SUBMIT.getCode())
.eq(ThDictData::getName, DictDataEnum.DAILY_LIMIT_WESTREAM_KNOW.getCode())
.eq(ThDictData::getMark, MarkEnum.VALID.getCode()));
if (ObjectUtil.isEmpty(dailyLimitWestreamSubmitDictData)) {
log.info("领取积分,每日上报最大限额字典项不存在,tenantId:{}, dictDataName:{}", request.getTenantId(), DictDataEnum.DAILY_LIMIT_WESTREAM_SUBMIT.getCode());
@@ -87,9 +97,20 @@ public class ReceivePonitsService {
Integer totalPointsByToDay = userPointsDetailMapper.selectTotalPointsByToDay(request.getOpenid(), pointsTime, changeName);
if (ObjectUtil.isNotEmpty(totalPointsByToDay)) {
if (totalPointsByToDay >= dailyLimitWestreamSubmit) {
log.info("领取积分,已超过每日积分上限,totalPointsByToDay:{}, dailyLimitWestreamSubmit:{}", totalPointsByToDay, dailyLimitWestreamSubmit);
return JsonResult.error("已超过每日积分上限");
log.info("领取积分,已超过每日领取积分上限,totalPointsByToDay:{}, dailyLimitWestreamSubmit:{}", totalPointsByToDay, dailyLimitWestreamSubmit);
return JsonResult.error("今日积分已领取或已超过每日积分上限");
}
} else {
totalPointsByToDay = 0;
}
Integer points = 0;
if (ObjectUtil.isNotEmpty(dictData)) {
points = Integer.parseInt(dictData.getValue());

}
if ((points + totalPointsByToDay) > dailyLimitWestreamSubmit) {
log.info("此次领取积分,加上今天已领积分,已超过每日积分上限,points:{},totalPointsByToDay:{}, dailyLimitWestreamSubmit:{}", points, totalPointsByToDay, dailyLimitWestreamSubmit);
return JsonResult.error("今日积分已领取或已超过每日积分上限");
}

WestreamUser westreamUser = westreamUserMapper.selectOne(new LambdaQueryWrapper<WestreamUser>()
@@ -101,22 +122,13 @@ public class ReceivePonitsService {
return JsonResult.error("该用户不存在");
}

WestreamKnowUser westreamKnowUser = westreamKnowUserMapper.selectOne(new LambdaQueryWrapper<WestreamKnowUser>()
.eq(WestreamKnowUser::getTenantId, request.getTenantId())
.eq(WestreamKnowUser::getOpenid, request.getOpenid())
.eq(WestreamKnowUser::getKnowId, request.getKnowId())
.eq(WestreamKnowUser::getMark, MarkEnum.VALID.getCode()));
if (ObjectUtil.isNotEmpty(westreamKnowUser)) {
return JsonResult.error("您已获得过积分了,仅能获取一次积分。");
} else {
westreamKnowUser = new WestreamKnowUser();
westreamKnowUser.setTenantId(request.getTenantId());
westreamKnowUser.setOpenid(request.getOpenid());
westreamKnowUser.setKnowId(request.getKnowId());
westreamKnowUser.setCreateUser(0);
westreamKnowUser.setCreateTime(DateUtils.now());
westreamKnowUserMapper.insert(westreamKnowUser);
}
westreamKnowUser = new WestreamKnowUser();
westreamKnowUser.setTenantId(request.getTenantId());
westreamKnowUser.setOpenid(request.getOpenid());
westreamKnowUser.setKnowId(request.getKnowId());
westreamKnowUser.setCreateUser(0);
westreamKnowUser.setCreateTime(DateUtils.now());
westreamKnowUserMapper.insert(westreamKnowUser);

UserPointsDetail userPointsDetail = new UserPointsDetail();
userPointsDetail.setTenantId(request.getTenantId());
@@ -125,11 +137,7 @@ public class ReceivePonitsService {
userPointsDetail.setChangeName("阅读知识");
userPointsDetail.setType(1);
userPointsDetail.setCreateTime(DateUtils.now());
Integer points = 0;
if (ObjectUtil.isNotEmpty(dictData)) {
points = Integer.parseInt(dictData.getValue());
userPointsDetail.setPointsChange(points);
}
userPointsDetail.setPointsChange(points);
userPointsDetail.setPointsTime(DateUtils.now());

Integer row = userPointsDetailMapper.insert(userPointsDetail);

Loading…
Cancel
Save