@@ -27,7 +27,7 @@ public class ReceivePonitsRequest { | |||
private String openid; | |||
/** | |||
* 活知ID | |||
* 知识ID | |||
*/ | |||
private Integer knowId; | |||
@@ -0,0 +1,30 @@ | |||
package com.tuoheng.api.enums; | |||
import lombok.Getter; | |||
/** | |||
* @Author xiaoying | |||
* @Date 2023/7/10 9:27 | |||
*/ | |||
public enum DictDataEnum { | |||
VOLUNTEER_ACTIVITY("volunteer_activity", "志愿者活动"), | |||
TIKTOK("tiktok", "关注抖音"), | |||
VIDEO("video", "学习视频"), | |||
WESTREAM_KNOW("westream_know", "阅读知识"), | |||
DAILY_LIMIT_WESTREAM_KNOW("daily_limit_westream_know", "阅读知识每日最大限额"), | |||
WESTREAM_SUBMIT("westream_submit", "我要上"), | |||
DAILY_LIMIT_WESTREAM_SUBMIT("daily_limit_westream_submit", "我要上报每日最大限额"),; | |||
DictDataEnum(String code, String description) { | |||
this.code = code; | |||
this.description = description; | |||
} | |||
@Getter | |||
private String code; | |||
@Getter | |||
private String description; | |||
} |
@@ -1,25 +0,0 @@ | |||
package com.tuoheng.api.enums; | |||
import lombok.Getter; | |||
/** | |||
* @Author xiaoying | |||
* @Date 2023/7/10 9:27 | |||
*/ | |||
public enum DictDateEnum { | |||
VOLUNTEER_ACTIVITY("volunteer_activity", "志愿者活动"), | |||
TIKTOK("tiktok", "关注抖音"), | |||
VIDEO("video", "学习视频"); | |||
DictDateEnum(String code, String description) { | |||
this.code = code; | |||
this.description = description; | |||
} | |||
@Getter | |||
private String code; | |||
@Getter | |||
private String description; | |||
} |
@@ -8,12 +8,11 @@ import com.tuoheng.api.constants.DictConstants; | |||
import com.tuoheng.api.entity.domain.*; | |||
import com.tuoheng.api.entity.request.OnlineNumQuery; | |||
import com.tuoheng.api.entity.request.WestreamUserQuery; | |||
import com.tuoheng.api.enums.DictDateEnum; | |||
import com.tuoheng.api.enums.DictDataEnum; | |||
import com.tuoheng.api.mapper.*; | |||
import com.tuoheng.api.service.IWestreamUserService; | |||
import com.tuoheng.api.utils.PointsTitleConstants; | |||
import com.tuoheng.common.common.BaseServiceImpl; | |||
import com.tuoheng.common.config.CommonConfig; | |||
import com.tuoheng.common.utils.CommonUtils; | |||
import com.tuoheng.common.utils.JsonResult; | |||
import com.tuoheng.common.utils.StringUtils; | |||
@@ -184,9 +183,9 @@ public class WestreamUserServiceImpl extends BaseServiceImpl<WestreamUserMapper, | |||
ThDictData param1 = new ThDictData(); | |||
ThDictData param2 = new ThDictData(); | |||
ThDictData param3 = new ThDictData(); | |||
param1.setName(DictDateEnum.TIKTOK.getDescription()); | |||
param2.setName(DictDateEnum.VIDEO.getDescription()); | |||
param3.setName(DictDateEnum.VOLUNTEER_ACTIVITY.getDescription()); | |||
param1.setName(DictDataEnum.TIKTOK.getDescription()); | |||
param2.setName(DictDataEnum.VIDEO.getDescription()); | |||
param3.setName(DictDataEnum.VOLUNTEER_ACTIVITY.getDescription()); | |||
thDictData.add(param1); | |||
thDictData.add(param2); | |||
thDictData.add(param3); | |||
@@ -198,14 +197,14 @@ public class WestreamUserServiceImpl extends BaseServiceImpl<WestreamUserMapper, | |||
.eq(ThDictData::getDictId, thDict.getId()) | |||
.eq(ThDictData::getMark, 1)); | |||
for (ThDictData thDictDatum : thDictData) { | |||
if (DictDateEnum.TIKTOK.getCode().equals(thDictDatum.getName())) { | |||
thDictDatum.setNote(DictDateEnum.TIKTOK.getDescription()); | |||
if (DictDataEnum.TIKTOK.getCode().equals(thDictDatum.getName())) { | |||
thDictDatum.setNote(DictDataEnum.TIKTOK.getDescription()); | |||
} | |||
if (DictDateEnum.VIDEO.getCode().equals(thDictDatum.getName())) { | |||
thDictDatum.setNote(DictDateEnum.VIDEO.getDescription()); | |||
if (DictDataEnum.VIDEO.getCode().equals(thDictDatum.getName())) { | |||
thDictDatum.setNote(DictDataEnum.VIDEO.getDescription()); | |||
} | |||
if (DictDateEnum.VOLUNTEER_ACTIVITY.getCode().equals(thDictDatum.getName())) { | |||
thDictDatum.setNote(DictDateEnum.VOLUNTEER_ACTIVITY.getDescription()); | |||
if (DictDataEnum.VOLUNTEER_ACTIVITY.getCode().equals(thDictDatum.getName())) { | |||
thDictDatum.setNote(DictDataEnum.VOLUNTEER_ACTIVITY.getDescription()); | |||
} | |||
} | |||
thDictData = thDictData.stream().filter(t -> StringUtils.isNotEmpty(t.getNote())).collect(Collectors.toList()); |
@@ -2,10 +2,9 @@ package com.tuoheng.api.service.points.receive; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.tuoheng.api.constants.DictConstants; | |||
import com.tuoheng.api.conver.WestreamSubmitConverMapper; | |||
import com.tuoheng.api.entity.domain.*; | |||
import com.tuoheng.api.entity.request.ReceivePonitsRequest; | |||
import com.tuoheng.api.enums.DictDataEnum; | |||
import com.tuoheng.api.enums.DictEnum; | |||
import com.tuoheng.api.enums.MarkEnum; | |||
import com.tuoheng.api.mapper.*; | |||
@@ -43,7 +42,7 @@ public class ReceivePonitsService { | |||
public JsonResult receive(ReceivePonitsRequest request) { | |||
JsonResult result = this.check(request); | |||
if (0 != result.getCode()) { | |||
log.info("全民护河领取:校验失败:{}", result.getMsg()); | |||
log.info("全民护河领取积分:校验失败:{}", result.getMsg()); | |||
return result; | |||
} | |||
@@ -52,62 +51,65 @@ public class ReceivePonitsService { | |||
.eq(WestreamKnowUser::getOpenid, request.getOpenid()) | |||
.eq(WestreamKnowUser::getKnowId, request.getKnowId()) | |||
.eq(WestreamKnowUser::getMark, MarkEnum.VALID.getCode())); | |||
if (ObjectUtil.isNotEmpty(westreamKnowUser)) { | |||
return JsonResult.success("已经领取,不用重复领取"); | |||
return JsonResult.success("已经领取积分,不用重复领取"); | |||
} | |||
WestreamUser westreamUser = westreamUserMapper.selectOne(new LambdaQueryWrapper<WestreamUser>() | |||
.eq(WestreamUser::getTenantId, request.getTenantId()) | |||
.eq(WestreamUser::getOpenid, request.getOpenid()) | |||
.eq(WestreamUser::getMark, MarkEnum.VALID.getCode())); | |||
if (ObjectUtil.isEmpty(westreamUser)) { | |||
log.info("领取积分,该用户不存在,tenantId:{}, openid:{}", request.getTenantId(), request.getOpenid()); | |||
return JsonResult.success("该用户不存在"); | |||
} | |||
ThDict dict = dictMapper.selectOne(new LambdaQueryWrapper<ThDict>() | |||
.eq(ThDict::getTenantId, request.getTenantId()) | |||
.eq(ThDict::getCode, DictEnum.POINTS_RULE.getCode()) | |||
.eq(ThDict::getMark, MarkEnum.VALID.getCode())); | |||
if (ObjectUtil.isEmpty(dict)) { | |||
log.info("领取积分,该字典类型不存在,tenantId:{}, dictCode:{}", request.getTenantId(), DictEnum.POINTS_RULE.getCode()); | |||
return JsonResult.success("积分规则未设置"); | |||
} | |||
ThDictData dictData = dictDataMapper.selectOne(new LambdaQueryWrapper<ThDictData>() | |||
.eq(ThDictData::getTenantId, request.getTenantId()) | |||
.eq(ThDictData::getDictId, dict.getId()) | |||
.eq(ThDictData::getName, "") | |||
.eq(ThDictData::getName, DictDataEnum.WESTREAM_KNOW.getCode()) | |||
.eq(ThDictData::getMark, MarkEnum.VALID.getCode())); | |||
if (ObjectUtil.isEmpty(dictData)) { | |||
log.info("领取积分,该字典项不存在,tenantId:{}, dictDataName:{}", request.getTenantId(), DictDataEnum.WESTREAM_KNOW.getCode()); | |||
return JsonResult.success("积分规则未设置"); | |||
} | |||
UserPointsDetail userPointsDetail = new UserPointsDetail(); | |||
userPointsDetail.setTenantId(request.getTenantId()); | |||
userPointsDetail.setOpenid(request.getOpenid()); | |||
userPointsDetail.setChangeName(westreamUser.getNickname()); | |||
userPointsDetail.setNickname(westreamUser.getNickname()); | |||
Integer points = 0; | |||
if (ObjectUtil.isNotEmpty(dictData)) { | |||
userPointsDetail.setPointsChange(Integer.parseInt(dictData.getValue())); | |||
points = Integer.parseInt(dictData.getValue()); | |||
userPointsDetail.setPointsChange(points); | |||
} | |||
userPointsDetail.setPointsTime(DateUtils.now()); | |||
Integer row = userPointsDetailMapper.insert(userPointsDetail); | |||
if (row <= 0) { | |||
return JsonResult.error("领取积分失败"); | |||
return JsonResult.error("领取积分,失败"); | |||
} | |||
westreamUser.setMallPoints(westreamUser.getMallPoints() + 0); | |||
if (ObjectUtil.isEmpty(westreamUser.getMallPoints())) { | |||
westreamUser.setMallPoints(points); | |||
} else { | |||
westreamUser.setMallPoints(westreamUser.getMallPoints() + points); | |||
} | |||
row = westreamUserMapper.updateById(westreamUser); | |||
if (row <= 0) { | |||
return JsonResult.error("领取积分,修改用户总积分失败"); | |||
} | |||
return JsonResult.success(); | |||
} | |||