签到:签到后增加用户积分、经验

This commit is contained in:
owen 2023-10-01 09:53:54 +08:00
parent a04a3a27a9
commit 4f03635fcd
14 changed files with 112 additions and 67 deletions

View File

@ -788,7 +788,7 @@ CREATE TABLE `member_level_record` (
`user_id` bigint NOT NULL DEFAULT 0 COMMENT '用户编号',
`level_id` bigint NOT NULL DEFAULT 0 COMMENT '等级编号',
`level` int NOT NULL DEFAULT 0 COMMENT '会员等级',
`discount_percent` tinyint NOT NULL DEFAULT 100 COMMENT '享受折扣',
`discount_percent` int NOT NULL DEFAULT 100 COMMENT '享受折扣',
`experience` int NOT NULL DEFAULT 0 COMMENT '升级经验',
`user_experience` int NOT NULL DEFAULT 0 COMMENT '会员此时的经验',
`remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '备注',
@ -888,7 +888,8 @@ DROP TABLE IF EXISTS `member_sign_in_config`;
CREATE TABLE `member_sign_in_config` (
`id` int NOT NULL AUTO_INCREMENT COMMENT '编号',
`day` int NOT NULL COMMENT '第几天',
`point` int NOT NULL COMMENT '奖励积分',
`point` int NOT NULL DEFAULT 0 COMMENT '奖励积分',
`experience` int NOT NULL DEFAULT 0 COMMENT '奖励经验',
`status` tinyint NOT NULL COMMENT '状态',
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
@ -903,18 +904,18 @@ CREATE TABLE `member_sign_in_config` (
-- Records of member_sign_in_config
-- ----------------------------
BEGIN;
INSERT INTO `member_sign_in_config` (`id`, `day`, `point`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (1, 1, 10, 0, '', '2023-08-20 01:38:56', '', '2023-08-20 01:38:56', b'0', 0);
INSERT INTO `member_sign_in_config` (`id`, `day`, `point`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (2, 2, 20, 0, '', '2023-08-20 01:38:56', '', '2023-08-20 01:38:56', b'0', 0);
INSERT INTO `member_sign_in_config` (`id`, `day`, `point`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (3, 7, 1001, 0, '', '2023-08-20 01:38:56', '', '2023-08-20 01:38:56', b'0', 0);
INSERT INTO `member_sign_in_config` (`id`, `day`, `point`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (4, 6, 12121, 0, '', '2023-08-20 01:38:56', '', '2023-08-20 01:38:56', b'0', 0);
INSERT INTO `member_sign_in_config` (`id`, `day`, `point`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (5, 2, 12, 0, '', '2023-08-20 01:38:56', '', '2023-08-20 01:38:56', b'0', 0);
INSERT INTO `member_sign_in_config` (`id`, `day`, `point`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (6, 1, 10, 0, '1', '2023-08-20 19:20:42', '1', '2023-08-20 19:20:56', b'0', 1);
INSERT INTO `member_sign_in_config` (`id`, `day`, `point`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (7, 7, 22, 0, '1', '2023-08-20 19:20:48', '1', '2023-08-20 19:20:48', b'0', 1);
INSERT INTO `member_sign_in_config` (`id`, `day`, `point`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (8, 2, 3, 0, '1', '2023-08-21 20:22:44', '1', '2023-08-21 20:22:44', b'0', 1);
INSERT INTO `member_sign_in_config` (`id`, `day`, `point`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (9, 3, 4, 0, '1', '2023-08-21 20:22:48', '1', '2023-08-21 20:22:48', b'0', 1);
INSERT INTO `member_sign_in_config` (`id`, `day`, `point`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (10, 4, 5, 0, '1', '2023-08-21 20:22:51', '1', '2023-08-21 20:22:51', b'0', 1);
INSERT INTO `member_sign_in_config` (`id`, `day`, `point`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (11, 5, 6, 0, '1', '2023-08-21 20:22:56', '1', '2023-08-21 20:22:56', b'0', 1);
INSERT INTO `member_sign_in_config` (`id`, `day`, `point`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (12, 6, 7, 0, '1', '2023-08-21 20:22:59', '1', '2023-08-21 20:22:59', b'0', 1);
INSERT INTO `member_sign_in_config` (`id`, `day`, `point`, `experience`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (1, 1, 10, 10, 0, '', '2023-08-20 01:38:56', '', '2023-08-20 01:38:56', b'0', 0);
INSERT INTO `member_sign_in_config` (`id`, `day`, `point`, `experience`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (2, 2, 20, 20, 0, '', '2023-08-20 01:38:56', '', '2023-08-20 01:38:56', b'0', 0);
INSERT INTO `member_sign_in_config` (`id`, `day`, `point`, `experience`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (3, 7, 1001, 1001, 0, '', '2023-08-20 01:38:56', '', '2023-08-20 01:38:56', b'0', 0);
INSERT INTO `member_sign_in_config` (`id`, `day`, `point`, `experience`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (4, 6, 12121, 12121, 0, '', '2023-08-20 01:38:56', '', '2023-08-20 01:38:56', b'0', 0);
INSERT INTO `member_sign_in_config` (`id`, `day`, `point`, `experience`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (5, 3, 12, 12, 0, '', '2023-08-20 01:38:56', '', '2023-08-20 01:38:56', b'0', 0);
INSERT INTO `member_sign_in_config` (`id`, `day`, `point`, `experience`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (6, 1, 10, 10, 0, '1', '2023-08-20 19:20:42', '1', '2023-08-20 19:20:56', b'0', 1);
INSERT INTO `member_sign_in_config` (`id`, `day`, `point`, `experience`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (7, 7, 22, 22, 0, '1', '2023-08-20 19:20:48', '1', '2023-08-20 19:20:48', b'0', 1);
INSERT INTO `member_sign_in_config` (`id`, `day`, `point`, `experience`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (8, 2, 3, 3, 0, '1', '2023-08-21 20:22:44', '1', '2023-08-21 20:22:44', b'0', 1);
INSERT INTO `member_sign_in_config` (`id`, `day`, `point`, `experience`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (9, 3, 4, 4, 0, '1', '2023-08-21 20:22:48', '1', '2023-08-21 20:22:48', b'0', 1);
INSERT INTO `member_sign_in_config` (`id`, `day`, `point`, `experience`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (10, 4, 5, 5, 0, '1', '2023-08-21 20:22:51', '1', '2023-08-21 20:22:51', b'0', 1);
INSERT INTO `member_sign_in_config` (`id`, `day`, `point`, `experience`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (11, 5, 6, 6, 0, '1', '2023-08-21 20:22:56', '1', '2023-08-21 20:22:56', b'0', 1);
INSERT INTO `member_sign_in_config` (`id`, `day`, `point`, `experience`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (12, 6, 7, 7, 0, '1', '2023-08-21 20:22:59', '1', '2023-08-21 20:22:59', b'0', 1);
COMMIT;
-- ----------------------------
@ -925,7 +926,8 @@ CREATE TABLE `member_sign_in_record` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '签到自增id',
`user_id` int NULL DEFAULT NULL COMMENT '签到用户',
`day` int NULL DEFAULT NULL COMMENT '第几天签到',
`point` int NULL DEFAULT NULL COMMENT '签到的分数',
`point` int NOT NULL DEFAULT 0 COMMENT '签到的积分',
`experience` int NOT NULL DEFAULT 0 COMMENT '签到的经验',
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
@ -935,6 +937,8 @@ CREATE TABLE `member_sign_in_record` (
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '签到记录';
CREATE INDEX user_id_index ON member_sign_in_record (user_id);
-- ----------------------------
-- Records of member_sign_in_record
-- ----------------------------

View File

@ -38,6 +38,7 @@ public interface ErrorCodeConstants {
//========== 签到配置 1-004-009-000 ==========
ErrorCode SIGN_IN_CONFIG_NOT_EXISTS = new ErrorCode(1_004_009_000, "签到天数规则不存在");
ErrorCode SIGN_IN_CONFIG_EXISTS = new ErrorCode(1_004_009_001, "签到天数规则已存在");
ErrorCode SIGN_IN_CONFIG_AWARD_EMPTY = new ErrorCode(1_004_009_002, "签到奖励积分和经验不能同时为空");
//========== 签到配置 1-004-010-000 ==========
ErrorCode SIGN_IN_RECORD_TODAY_EXISTS = new ErrorCode(1_004_010_000,"今日已签到,请勿重复签到");

View File

@ -6,6 +6,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.PositiveOrZero;
/**
* 签到规则 Base VO提供给添加修改详细的子 VO 使用
@ -20,8 +21,14 @@ public class MemberSignInConfigBaseVO {
@Schema(description = "奖励积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
@NotNull(message = "奖励积分不能为空")
@PositiveOrZero(message = "奖励积分不能小于 0")
private Integer point;
@Schema(description = "奖励经验", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
@NotNull(message = "奖励经验不能为空")
@PositiveOrZero(message = "奖励经验不能小于 0")
private Integer experience;
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "状态不能为空")
@InEnum(CommonStatusEnum.class)

View File

@ -21,7 +21,7 @@ public class MemberSignInRecordRespVO {
@Schema(description = "第几天签到", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Integer day;
@Schema(description = "签到的", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
@Schema(description = "签到的", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
private Integer point;
@Schema(description = "签到时间", requiredMode = Schema.RequiredMode.REQUIRED)

View File

@ -1,13 +1,10 @@
package cn.iocoder.yudao.module.member.controller.app.signin;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.member.convert.signin.MemberSignInRecordConvert;
import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO;
import cn.iocoder.yudao.module.member.service.signin.MemberSignInRecordService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@ -33,13 +30,4 @@ public class AppMemberSignInController {
return success(signInRecordService.getSignInRecordSummary(getLoginUserId()));
}
// TODO @xiaqing泛型
// TODO @xiaqing合并到 AppMemberSignInRecordController createSignInRecord 里哈
@Operation(summary = "会员签到")
@PostMapping("/create")
public CommonResult create(){
MemberSignInRecordDO recordDO = signInRecordService.createSignRecord(getLoginUserId());
return success(MemberSignInRecordConvert.INSTANCE.coverRecordToAppRecordVo(recordDO));
}
}

View File

@ -18,7 +18,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
@ -50,16 +49,12 @@ public class AppMemberSignInRecordController {
return success(respVO);
}
// TODO 芋艿临时 mock => UserSignController.info
@PostMapping("/create")
@Operation(summary = "签到")
@PreAuthenticated
public CommonResult<AppMemberSignInRecordRespVO> createSignInRecord() {
AppMemberSignInRecordRespVO respVO = new AppMemberSignInRecordRespVO()
.setPoint(10)
.setDay(10)
.setCreateTime(LocalDateTime.now());
return success(respVO);
MemberSignInRecordDO recordDO = signInRecordService.createSignRecord(getLoginUserId());
return success(MemberSignInRecordConvert.INSTANCE.coverRecordToAppRecordVo(recordDO));
}
@GetMapping("/page")

View File

@ -12,9 +12,12 @@ public class AppMemberSignInRecordRespVO {
@Schema(description = "第几天签到", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Integer day;
@Schema(description = "签到的", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
@Schema(description = "签到的", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
private Integer point;
@Schema(description = "签到的经验", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
private Integer experience;
@Schema(description = "签到时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime createTime;

View File

@ -15,6 +15,9 @@ public class AppMemberSignInRecordRespVO {
@Schema(description = "签到的分数", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
private Integer point;
@Schema(description = "签到的经验", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
private Integer experience;
@Schema(description = "签到时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime createTime;

View File

@ -35,6 +35,10 @@ public class MemberSignInConfigDO extends BaseDO {
* 奖励积分
*/
private Integer point;
/**
* 奖励经验
*/
private Integer experience;
/**
* 状态

View File

@ -35,10 +35,12 @@ public class MemberSignInRecordDO extends BaseDO {
*/
private Integer day;
/**
* 签到的
* 签到的
*/
private Integer point;
// TODO 疯狂签到的经验
/**
* 签到的经验
*/
private Integer experience;
}

View File

@ -239,7 +239,8 @@ public class MemberLevelServiceImpl implements MemberLevelService {
// 1. 创建经验记录
MemberUserDO user = memberUserService.getUser(userId);
int userExperience = NumberUtil.max(user.getExperience() + experience, 0); // 防止扣出负数
Integer userExperience = ObjUtil.defaultIfNull(user.getExperience(), 0);
userExperience = NumberUtil.max(userExperience + experience, 0); // 防止扣出负数
MemberLevelRecordDO levelRecord = new MemberLevelRecordDO()
.setUserId(user.getId())
.setExperience(experience)

View File

@ -66,6 +66,9 @@ public class MemberPointRecordServiceImpl implements MemberPointRecordService {
@Override
@Transactional(rollbackFor = Exception.class)
public void createPointRecord(Long userId, Integer point, MemberPointBizTypeEnum bizType, String bizId) {
if (point == 0) {
return;
}
// 1. 校验用户积分余额
MemberUserDO user = memberUserService.getUser(userId);
Integer userPoint = ObjectUtil.defaultIfNull(user.getPoint(), 0);

View File

@ -11,10 +11,10 @@ import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.SIGN_IN_CONFIG_EXISTS;
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.SIGN_IN_CONFIG_NOT_EXISTS;
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*;
/**
* 签到规则 Service 实现类
@ -30,6 +30,8 @@ public class MemberSignInConfigServiceImpl implements MemberSignInConfigService
@Override
public Long createSignInConfig(MemberSignInConfigCreateReqVO createReqVO) {
// 校验奖励积分奖励经验
validatePointAndExperience(createReqVO.getPoint(), createReqVO.getExperience());
// 判断是否重复插入签到天数
validateSignInConfigDayDuplicate(createReqVO.getDay(), null);
@ -42,6 +44,8 @@ public class MemberSignInConfigServiceImpl implements MemberSignInConfigService
@Override
public void updateSignInConfig(MemberSignInConfigUpdateReqVO updateReqVO) {
// 校验奖励积分奖励经验
validatePointAndExperience(updateReqVO.getPoint(), updateReqVO.getExperience());
// 校验存在
validateSignInConfigExists(updateReqVO.getId());
// 判断是否重复插入签到天数
@ -84,6 +88,13 @@ public class MemberSignInConfigServiceImpl implements MemberSignInConfigService
}
}
private void validatePointAndExperience(Integer point, Integer experience) {
// 奖励积分经验 至少要配置一个否则没有意义
if (Objects.equals(point, 0) && Objects.equals(experience, 0)) {
throw exception(SIGN_IN_CONFIG_AWARD_EMPTY);
}
}
@Override
public MemberSignInConfigDO getSignInConfig(Long id) {
return memberSignInConfigMapper.selectById(id);

View File

@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.member.service.signin;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
@ -13,8 +14,13 @@ import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO
import cn.iocoder.yudao.module.member.dal.mysql.signin.MemberSignInConfigMapper;
import cn.iocoder.yudao.module.member.dal.mysql.signin.MemberSignInRecordMapper;
import cn.iocoder.yudao.module.member.enums.ErrorCodeConstants;
import cn.iocoder.yudao.module.member.enums.MemberExperienceBizTypeEnum;
import cn.iocoder.yudao.module.member.enums.point.MemberPointBizTypeEnum;
import cn.iocoder.yudao.module.member.service.level.MemberLevelService;
import cn.iocoder.yudao.module.member.service.point.MemberPointRecordService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated;
@ -40,6 +46,10 @@ public class MemberSignInRecordServiceImpl implements MemberSignInRecordService
private MemberSignInRecordMapper signInRecordMapper;
@Resource
private MemberSignInConfigMapper signInConfigMapper;
@Resource
private MemberPointRecordService pointRecordService;
@Resource
private MemberLevelService memberLevelService;
@Resource
private MemberUserApi memberUserApi;
@ -113,6 +123,7 @@ public class MemberSignInRecordServiceImpl implements MemberSignInRecordService
}
@Override
@Transactional(rollbackFor = Exception.class)
public MemberSignInRecordDO createSignRecord(Long userId) {
// 获取当前用户签到的最大天数
// TODO @xiaqingdb 操作dou封装到 mapper
@ -124,39 +135,51 @@ public class MemberSignInRecordServiceImpl implements MemberSignInRecordService
// 判断是否重复签到
validSignDay(maxSignDay);
// TODO @xiaqing可以使用 // 进行注释
/**1.查询出当前签到的天数**/
// 1. 查询出当前签到的天数
MemberSignInRecordDO sign = new MemberSignInRecordDO().setUserId(userId); // TODO @xiaqing应该使用 record 变量会更合适
sign.setDay(1); // 设置签到初始化天数
sign.setPoint(0); // 设置签到分数默认为 0
sign.setPoint(0); // 设置签到积分默认为 0
sign.setExperience(0); // 设置签到经验默认为 0
// 如果不为空则修改当前签到对应的天数
// TODO @xiaqing应该是要判断连续哈就是昨天
if (maxSignDay != null) {
sign.setDay(maxSignDay.getDay() + 1);
}
/**2.获取签到对应的分数**/
// 2. 获取签到对应的积分数
// 获取所有的签到规则按照天数排序只获取启用的 TODO @xiaqing不要使用 signInConfigMapper 直接查询而是要通过 SigninConfigService
List<MemberSignInConfigDO> configDOList = signInConfigMapper.selectList(new LambdaQueryWrapperX<MemberSignInConfigDO>()
.eq(MemberSignInConfigDO::getStatus, CommonStatusEnum.ENABLE.getStatus())
.orderByAsc(MemberSignInConfigDO::getDay));
// 如果签到的天数大于最大启用的规则天数直接给最大签到的分数
// 如果签到的天数大于最大启用的规则天数直接给最大签到的分数
// TODO @xiaqing超过最大配置的天数应该直接重置到第一天哈
MemberSignInConfigDO lastConfig = configDOList.get(configDOList.size() - 1);
if (sign.getDay() > lastConfig.getDay()) {
sign.setPoint(lastConfig.getPoint());
sign.setExperience(lastConfig.getExperience());
} else {
configDOList.forEach(el -> {
// 循环匹配对应天数设置对应分数
// 循环匹配对应天数设置对应分数
// TODO @xiaqing使用 equals另外这种不应该去遍历比较从可读性来说应该 CollUtil.findOne()
if (el.getDay() == sign.getDay()) {
sign.setPoint(el.getPoint());
sign.setExperience(el.getExperience());
}
});
}
// 3. 插入当前签到获取的分数
// 3. 插入签到记录
signInRecordMapper.insert(sign);
// 4. 增加积分
if (!ObjectUtils.equalsAny(sign.getPoint(), null, 0)) {
pointRecordService.createPointRecord(userId, sign.getPoint(), MemberPointBizTypeEnum.SIGN, String.valueOf(sign.getId()));
}
// 5. 增加经验
if (!ObjectUtils.equalsAny(sign.getPoint(), null, 0)) {
memberLevelService.addExperience(userId, sign.getExperience(), MemberExperienceBizTypeEnum.SIGN_IN, String.valueOf(sign.getId()));
}
return sign;
}