Commit f9d6bf8f authored by zhangfeng's avatar zhangfeng

积分基本信息,积分日志

parent 416de628
...@@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.member.enums; ...@@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.member.enums;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import java.util.Set; import java.util.Set;
import java.util.stream.Stream;
public enum ScoreSourceTypeEnum { public enum ScoreSourceTypeEnum {
MANUAL_OPERATE(1, "人工操作", null, null), MANUAL_OPERATE(1, "人工操作", null, null),
...@@ -53,4 +54,7 @@ public enum ScoreSourceTypeEnum { ...@@ -53,4 +54,7 @@ public enum ScoreSourceTypeEnum {
public static Set<ScoreSourceTypeEnum> getInvalidScoreStatusSourceType() { public static Set<ScoreSourceTypeEnum> getInvalidScoreStatusSourceType() {
return Sets.newHashSet(MANUAL_OPERATE, SYSTEM_EXPIRED); return Sets.newHashSet(MANUAL_OPERATE, SYSTEM_EXPIRED);
} }
public static ScoreSourceTypeEnum parseByValue(int value) {
return Stream.of(values()).filter(e -> e.getValue() == value).findAny().orElse(null);
}
} }
...@@ -59,5 +59,10 @@ ...@@ -59,5 +59,10 @@
<artifactId>yudao-module-customer-core</artifactId> <artifactId>yudao-module-customer-core</artifactId>
<version>${revision}</version> <version>${revision}</version>
</dependency> </dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-reward-api</artifactId>
<version>${revision}</version>
</dependency>
</dependencies> </dependencies>
</project> </project>
package cn.iocoder.yudao.module.member.controller.app.userScore;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
import cn.iocoder.yudao.module.member.api.score.MemberUserScoreApiImpl;
import cn.iocoder.yudao.module.member.controller.app.userScore.vo.AppMemberUserIdQueryVO;
import cn.iocoder.yudao.module.member.controller.app.userScore.vo.AppMemberUserScoreInfoRespVO;
import cn.iocoder.yudao.module.member.controller.app.userScore.vo.AppMemberUserScoreLogRespVO;
import cn.iocoder.yudao.module.member.service.score.MemberUserScoreService;
import cn.iocoder.yudao.module.member.service.scoreLog.MemberUserScoreLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Validated
@RestController
@Api(tags = "用户 APP - 会员积分")
@RequestMapping("/member/user-score")
public class AppMemberUserScoreController {
@Resource
private MemberUserScoreService userScoreService;
@Resource
private MemberUserScoreApiImpl scoreApi;
@Resource
private MemberUserScoreLogService memberUserScoreLogService;
@PostMapping("/info")
@ApiOperation("获得会员积分基本信息")
//@PreAuthenticated
public CommonResult<AppMemberUserScoreInfoRespVO> getUserScoreInfo(@Valid @RequestBody AppMemberUserIdQueryVO idQuery) {
AppMemberUserScoreInfoRespVO scoreInfo = userScoreService.getUserScoreInfo(idQuery);
return success(scoreInfo);
}
@PostMapping("/log")
@ApiOperation("获取会员积分日志列表")
//@PreAuthenticated
public CommonResult<List<AppMemberUserScoreLogRespVO>> getUserScoreLogList(@Valid @RequestBody AppMemberUserIdQueryVO query) {
return success(memberUserScoreLogService.getUserScoreLogList(query));
}
}
package cn.iocoder.yudao.module.member.controller.app.userScore.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
/**
* @author zhaobiyan
*/
@Data
@ApiModel("用户 APP - 会员积分 id查询 VO")
public class AppMemberUserIdQueryVO {
@ApiModelProperty(value = "会员id")
@NotNull
private Long id;
}
\ No newline at end of file
package cn.iocoder.yudao.module.member.controller.app.userScore.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@ApiModel("用户 APP - 会员积分基本信息返回 VO")
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class AppMemberUserScoreInfoRespVO {
@ApiModelProperty(value = "会员id")
private Long id;
@ApiModelProperty(value = "当前积分")
private Integer holdScore;
@ApiModelProperty(value = "已兑换积分")
private Integer usedScore;
@ApiModelProperty(value = "历史总积分")
private Integer totalScore;
@ApiModelProperty(value = "会员等级名称")
private String levelName;
}
package cn.iocoder.yudao.module.member.controller.app.userScore.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Data
@ApiModel("用户 APP - 会员积分日志返回 VO")
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class AppMemberUserScoreLogRespVO {
@ApiModelProperty(value = "积分数量")
private Integer scoreCount;
@ApiModelProperty(value = "操作类型")
private String operateType;
@ApiModelProperty(value = "积分来源")
private String sourceTypeZh;
@ApiModelProperty(value = "积分来源")
private String sourceTypeEn;
@ApiModelProperty(value = "积分规则id")
private Long ruleId;
@ApiModelProperty(value = "积分规则名称中文")
private String ruleNameZh;
@ApiModelProperty(value = "积分规则名称英文")
private String ruleNameEn;
@ApiModelProperty(value = "日志时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private Date createTime;
@ApiModelProperty(value = "描述信息中文")
private String descZh = "";
@ApiModelProperty(value = "描述信息英文")
private String descEn = "";
@ApiModelProperty(value = "礼品兑换数量")
private Integer rewardCount;
}
...@@ -4,6 +4,8 @@ import java.util.*; ...@@ -4,6 +4,8 @@ import java.util.*;
import cn.iocoder.yudao.framework.mybatis.core.service.IService; import cn.iocoder.yudao.framework.mybatis.core.service.IService;
import cn.iocoder.yudao.module.member.api.score.dto.MemberUserScoreUpdateReqDTO; import cn.iocoder.yudao.module.member.api.score.dto.MemberUserScoreUpdateReqDTO;
import cn.iocoder.yudao.module.member.controller.app.userScore.vo.AppMemberUserIdQueryVO;
import cn.iocoder.yudao.module.member.controller.app.userScore.vo.AppMemberUserScoreInfoRespVO;
import cn.iocoder.yudao.module.member.vo.memberUserScore.*; import cn.iocoder.yudao.module.member.vo.memberUserScore.*;
import cn.iocoder.yudao.module.member.dal.dataobject.score.MemberUserScoreDO; import cn.iocoder.yudao.module.member.dal.dataobject.score.MemberUserScoreDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
...@@ -50,4 +52,11 @@ public interface MemberUserScoreService extends IService<MemberUserScoreDO> { ...@@ -50,4 +52,11 @@ public interface MemberUserScoreService extends IService<MemberUserScoreDO> {
List<MemberUserScoreDO> getUserScoreList(MemberUserScoreQueryVO query); List<MemberUserScoreDO> getUserScoreList(MemberUserScoreQueryVO query);
void updateUserScore(MemberUserScoreUpdateReqDTO query); void updateUserScore(MemberUserScoreUpdateReqDTO query);
/**
* 获取会员积分及会员等级信息
* @param id
* @return
*/
AppMemberUserScoreInfoRespVO getUserScoreInfo(AppMemberUserIdQueryVO id);
} }
...@@ -3,12 +3,16 @@ package cn.iocoder.yudao.module.member.service.score; ...@@ -3,12 +3,16 @@ package cn.iocoder.yudao.module.member.service.score;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.service.AbstractService; import cn.iocoder.yudao.framework.mybatis.core.service.AbstractService;
import cn.iocoder.yudao.module.member.api.score.dto.MemberUserScoreUpdateReqDTO; import cn.iocoder.yudao.module.member.api.score.dto.MemberUserScoreUpdateReqDTO;
import cn.iocoder.yudao.module.member.controller.app.userScore.vo.AppMemberUserIdQueryVO;
import cn.iocoder.yudao.module.member.controller.app.userScore.vo.AppMemberUserScoreInfoRespVO;
import cn.iocoder.yudao.module.member.dal.dataobject.score.MemberUserScoreDO; import cn.iocoder.yudao.module.member.dal.dataobject.score.MemberUserScoreDO;
import cn.iocoder.yudao.module.member.dal.mysql.memberUserScore.MemberUserScoreMapper; import cn.iocoder.yudao.module.member.dal.mysql.memberUserScore.MemberUserScoreMapper;
import cn.iocoder.yudao.module.member.enums.ScoreOperateTypeEnum; import cn.iocoder.yudao.module.member.enums.ScoreOperateTypeEnum;
import cn.iocoder.yudao.module.member.enums.ScoreSourceTypeEnum; import cn.iocoder.yudao.module.member.enums.ScoreSourceTypeEnum;
import cn.iocoder.yudao.module.member.service.level.MemberUserLevelConfigService;
import cn.iocoder.yudao.module.member.vo.memberUserScore.MemberUserScoreBackVO; import cn.iocoder.yudao.module.member.vo.memberUserScore.MemberUserScoreBackVO;
import cn.iocoder.yudao.module.member.vo.memberUserScore.MemberUserScoreQueryVO; import cn.iocoder.yudao.module.member.vo.memberUserScore.MemberUserScoreQueryVO;
import cn.iocoder.yudao.module.member.vo.userLevel.MemberUserLevelConfigBaseRespVO;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
...@@ -34,6 +38,8 @@ public class MemberUserScoreServiceImpl extends AbstractService<MemberUserScoreM ...@@ -34,6 +38,8 @@ public class MemberUserScoreServiceImpl extends AbstractService<MemberUserScoreM
@Resource @Resource
private MemberUserScoreMapper userScoreMapper; private MemberUserScoreMapper userScoreMapper;
@Resource
private MemberUserLevelConfigService memberUserLevelConfigService;
@Override @Override
public void deleteUserScore(Long id) { public void deleteUserScore(Long id) {
...@@ -103,6 +109,26 @@ public class MemberUserScoreServiceImpl extends AbstractService<MemberUserScoreM ...@@ -103,6 +109,26 @@ public class MemberUserScoreServiceImpl extends AbstractService<MemberUserScoreM
} }
} }
@Override
public AppMemberUserScoreInfoRespVO getUserScoreInfo(AppMemberUserIdQueryVO id) {
MemberUserScoreDO userScoreDO = userScoreMapper.getByMemberId(id.getId());
if (userScoreDO == null) {
throw exception(MEMBER_ID_IS_NULL);
}
Integer userScoreTotal = userScoreDO.getHoldScore() + userScoreDO.getUsedScore() + userScoreDO.getExpiredScore();
AppMemberUserScoreInfoRespVO infoRespVO = AppMemberUserScoreInfoRespVO.builder()
.holdScore(userScoreDO.getHoldScore())
.id(userScoreDO.getId())
.totalScore(userScoreTotal)
.usedScore(userScoreDO.getUsedScore())
.build();
MemberUserLevelConfigBaseRespVO level = memberUserLevelConfigService.getLevelByCount(userScoreTotal);
if (level != null) {
infoRespVO.setLevelName(level.getName());
}
return infoRespVO;
}
private MemberUserScoreDO initMemberUserScore(Long memberId) { private MemberUserScoreDO initMemberUserScore(Long memberId) {
MemberUserScoreDO memberUserScoreDO = new MemberUserScoreDO(); MemberUserScoreDO memberUserScoreDO = new MemberUserScoreDO();
memberUserScoreDO.setMemberId(memberId); memberUserScoreDO.setMemberId(memberId);
......
...@@ -2,11 +2,15 @@ package cn.iocoder.yudao.module.member.service.scoreLog; ...@@ -2,11 +2,15 @@ package cn.iocoder.yudao.module.member.service.scoreLog;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.service.IService; import cn.iocoder.yudao.framework.mybatis.core.service.IService;
import cn.iocoder.yudao.module.member.controller.app.userScore.vo.AppMemberUserIdQueryVO;
import cn.iocoder.yudao.module.member.controller.app.userScore.vo.AppMemberUserScoreLogRespVO;
import cn.iocoder.yudao.module.member.dal.dataobject.scoreLog.MemberUserScoreLogDO; import cn.iocoder.yudao.module.member.dal.dataobject.scoreLog.MemberUserScoreLogDO;
import cn.iocoder.yudao.module.member.vo.memberUserScoreLog.MemberUserScoreLogBackVO; import cn.iocoder.yudao.module.member.vo.memberUserScoreLog.MemberUserScoreLogBackVO;
import cn.iocoder.yudao.module.member.vo.memberUserScoreLog.MemberUserScoreLogCreateReq; import cn.iocoder.yudao.module.member.vo.memberUserScoreLog.MemberUserScoreLogCreateReq;
import cn.iocoder.yudao.module.member.vo.memberUserScoreLog.MemberUserScoreLogQueryVO; import cn.iocoder.yudao.module.member.vo.memberUserScoreLog.MemberUserScoreLogQueryVO;
import java.util.List;
/** /**
* 会员积分日志 Service 接口 * 会员积分日志 Service 接口
* *
...@@ -19,4 +23,6 @@ public interface MemberUserScoreLogService extends IService<MemberUserScoreLogDO ...@@ -19,4 +23,6 @@ public interface MemberUserScoreLogService extends IService<MemberUserScoreLogDO
Long createScoreLog(MemberUserScoreLogCreateReq createReq); Long createScoreLog(MemberUserScoreLogCreateReq createReq);
MemberUserScoreLogDO getByUniqueId(String uniqueId); MemberUserScoreLogDO getByUniqueId(String uniqueId);
List<AppMemberUserScoreLogRespVO> getUserScoreLogList(AppMemberUserIdQueryVO query);
} }
...@@ -3,12 +3,22 @@ package cn.iocoder.yudao.module.member.service.scoreLog; ...@@ -3,12 +3,22 @@ package cn.iocoder.yudao.module.member.service.scoreLog;
import cn.hutool.core.lang.generator.SnowflakeGenerator; import cn.hutool.core.lang.generator.SnowflakeGenerator;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
import cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils;
import cn.iocoder.yudao.framework.mybatis.core.service.AbstractService; import cn.iocoder.yudao.framework.mybatis.core.service.AbstractService;
import cn.iocoder.yudao.module.member.controller.app.userScore.vo.AppMemberUserIdQueryVO;
import cn.iocoder.yudao.module.member.controller.app.userScore.vo.AppMemberUserScoreLogRespVO;
import cn.iocoder.yudao.module.member.dal.dataobject.scoreLog.MemberUserScoreLogDO; import cn.iocoder.yudao.module.member.dal.dataobject.scoreLog.MemberUserScoreLogDO;
import cn.iocoder.yudao.module.member.dal.mysql.memberUserScoreLog.MemberUserScoreLogMapper; import cn.iocoder.yudao.module.member.dal.mysql.memberUserScoreLog.MemberUserScoreLogMapper;
import cn.iocoder.yudao.module.member.enums.ScoreOperateTypeEnum;
import cn.iocoder.yudao.module.member.enums.ScoreSourceTypeEnum;
import cn.iocoder.yudao.module.member.service.scoreRule.ScoreRuleService;
import cn.iocoder.yudao.module.member.vo.memberUserScoreLog.MemberUserScoreLogBackVO; import cn.iocoder.yudao.module.member.vo.memberUserScoreLog.MemberUserScoreLogBackVO;
import cn.iocoder.yudao.module.member.vo.memberUserScoreLog.MemberUserScoreLogCreateReq; import cn.iocoder.yudao.module.member.vo.memberUserScoreLog.MemberUserScoreLogCreateReq;
import cn.iocoder.yudao.module.member.vo.memberUserScoreLog.MemberUserScoreLogQueryVO; import cn.iocoder.yudao.module.member.vo.memberUserScoreLog.MemberUserScoreLogQueryVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.ScoreRuleBackDetailVO;
import cn.iocoder.yudao.module.reward.api.reward.RedeemRewardApi;
import cn.iocoder.yudao.module.reward.api.reward.dto.RedeemDetailForUserDTO;
import cn.iocoder.yudao.module.system.service.dict.DictTypeService; import cn.iocoder.yudao.module.system.service.dict.DictTypeService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
...@@ -16,7 +26,7 @@ import org.springframework.stereotype.Service; ...@@ -16,7 +26,7 @@ import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import java.util.*;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.MEMBER_ID_IS_NULL; import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.MEMBER_ID_IS_NULL;
...@@ -32,12 +42,12 @@ public class MemberUserScoreLogServiceImpl extends AbstractService<MemberUserSco ...@@ -32,12 +42,12 @@ public class MemberUserScoreLogServiceImpl extends AbstractService<MemberUserSco
@Resource @Resource
private MemberUserScoreLogMapper userScoreLogMapper; private MemberUserScoreLogMapper userScoreLogMapper;
@Resource
private DictTypeService dictTypeService;
@Resource @Resource
private SnowflakeGenerator snowflakeGenerator; private SnowflakeGenerator snowflakeGenerator;
@Resource
private ScoreRuleService scoreRuleService;
@Resource
RedeemRewardApi redeemRewardApi;
@Override @Override
...@@ -75,4 +85,95 @@ public class MemberUserScoreLogServiceImpl extends AbstractService<MemberUserSco ...@@ -75,4 +85,95 @@ public class MemberUserScoreLogServiceImpl extends AbstractService<MemberUserSco
wrapper.eq(MemberUserScoreLogDO::getUniqueId, uniqueId); wrapper.eq(MemberUserScoreLogDO::getUniqueId, uniqueId);
return this.selectOne(wrapper); return this.selectOne(wrapper);
} }
@Override
public List<AppMemberUserScoreLogRespVO> getUserScoreLogList(AppMemberUserIdQueryVO query) {
List<MemberUserScoreLogDO> userScoreLogDOS = userScoreLogMapper.selectList("member_id", query.getId());
if (userScoreLogDOS == null || userScoreLogDOS.isEmpty()) {
return Collections.EMPTY_LIST;
}
ArrayList<AppMemberUserScoreLogRespVO> appMemberUserScoreLogRespVOS = new ArrayList<>();
for (MemberUserScoreLogDO userScoreLogDO : userScoreLogDOS) {
setScoreRuleLogDetail(userScoreLogDO, appMemberUserScoreLogRespVOS);
}
return appMemberUserScoreLogRespVOS;
}
private void setScoreRuleLogDetail(MemberUserScoreLogDO userScoreLogDO, ArrayList<AppMemberUserScoreLogRespVO> appMemberUserScoreLogRespVOS) {
AppMemberUserScoreLogRespVO appMemberUserScoreLogRespVO = new AppMemberUserScoreLogRespVO();
appMemberUserScoreLogRespVO.setScoreCount(userScoreLogDO.getScoreCount());
appMemberUserScoreLogRespVO.setOperateType(userScoreLogDO.getOperateType() == 1 ? "+" : "-");
appMemberUserScoreLogRespVO.setCreateTime(userScoreLogDO.getCreateTime());
// 增加积分日志
if (Objects.equals(userScoreLogDO.getOperateType(), ScoreOperateTypeEnum.ADD.getValue())) {
switch (userScoreLogDO.getSourceType()) {
// 人工操作
case 1:
appMemberUserScoreLogRespVO.setSourceTypeZh(DictFrameworkUtils.getDictDataFromCache("member_score_source", "1").getLabel());
appMemberUserScoreLogRespVO.setSourceTypeEn(DictFrameworkUtils.getDictDataFromCache("member_score_source", "1").getLabelEn());
appMemberUserScoreLogRespVO.setDescZh("人工积分");
appMemberUserScoreLogRespVO.setDescEn("Manually add points");
break;
// 撤销兑换
case 4:
appMemberUserScoreLogRespVO.setSourceTypeZh(DictFrameworkUtils.getDictDataFromCache("member_score_source", "4").getLabel());
appMemberUserScoreLogRespVO.setSourceTypeEn(DictFrameworkUtils.getDictDataFromCache("member_score_source", "4").getLabelEn());
// TODO:补充描述
appMemberUserScoreLogRespVO.setDescZh(DictFrameworkUtils.getDictDataFromCache("member_score_source", "4").getLabel());
appMemberUserScoreLogRespVO.setDescEn(DictFrameworkUtils.getDictDataFromCache("member_score_source", "4").getLabelEn());
break;
// 活动积分
case 5:
case 6:
case 7:
case 8:
ScoreSourceTypeEnum scoreSourceTypeEnum = ScoreSourceTypeEnum.parseByValue(userScoreLogDO.getSourceType());
appMemberUserScoreLogRespVO.setSourceTypeZh(DictFrameworkUtils.getDictDataFromCache("member_score_source", String.valueOf(scoreSourceTypeEnum.getValue())).getLabel());
appMemberUserScoreLogRespVO.setSourceTypeEn(DictFrameworkUtils.getDictDataFromCache("member_score_source", String.valueOf(scoreSourceTypeEnum.getValue())).getLabelEn());
ScoreRuleBackDetailVO scoreRule = scoreRuleService.getScoreRule(userScoreLogDO.getRuleId());
if (scoreRule != null) {
appMemberUserScoreLogRespVO.setRuleId(userScoreLogDO.getRuleId());
appMemberUserScoreLogRespVO.setRuleNameEn(scoreRule.getTitleEn());
appMemberUserScoreLogRespVO.setRuleNameZh(scoreRule.getTitleZh());
appMemberUserScoreLogRespVO.setDescEn(scoreRule.getDescEn());
appMemberUserScoreLogRespVO.setDescZh(scoreRule.getDescZh());
}
break;
}
} else {
// 减少积分日志
switch (userScoreLogDO.getSourceType()) {
// 人工操作
case 1:
appMemberUserScoreLogRespVO.setSourceTypeZh(DictFrameworkUtils.getDictDataFromCache("member_score_source", "1").getLabel());
appMemberUserScoreLogRespVO.setSourceTypeEn(DictFrameworkUtils.getDictDataFromCache("member_score_source", "1").getLabelEn());
appMemberUserScoreLogRespVO.setDescZh("人工积分");
appMemberUserScoreLogRespVO.setDescEn("Manually reduce points");
break;
// 兑换
case 2:
appMemberUserScoreLogRespVO.setSourceTypeZh(DictFrameworkUtils.getDictDataFromCache("member_score_source", "2").getLabel());
appMemberUserScoreLogRespVO.setSourceTypeEn(DictFrameworkUtils.getDictDataFromCache("member_score_source", "2").getLabelEn());
// 查询兑换记录
Map<String, Long> extParam = JsonUtils.parseObject(userScoreLogDO.getExtParam(), HashMap.class);
Long redeemId = extParam.get("redeemId");
if (redeemId != null) {
RedeemDetailForUserDTO redeemDetailForUser = redeemRewardApi.getRedeemDetailForUser(redeemId);
if (redeemDetailForUser != null) {
appMemberUserScoreLogRespVO.setRewardCount(redeemDetailForUser.getRewardCount());
appMemberUserScoreLogRespVO.setDescZh(redeemDetailForUser.getRewardNameZh());
appMemberUserScoreLogRespVO.setDescEn(redeemDetailForUser.getRewardNameEn());
}
}
break;
// 系统过期
case 3:
appMemberUserScoreLogRespVO.setSourceTypeZh(DictFrameworkUtils.getDictDataFromCache("member_score_source", "3").getLabel());
appMemberUserScoreLogRespVO.setSourceTypeEn(DictFrameworkUtils.getDictDataFromCache("member_score_source", "3").getLabelEn());
appMemberUserScoreLogRespVO.setDescZh("系统过期");
appMemberUserScoreLogRespVO.setDescEn("System expiration");
}
}
appMemberUserScoreLogRespVOS.add(appMemberUserScoreLogRespVO);
}
} }
...@@ -11,7 +11,7 @@ import java.util.Date; ...@@ -11,7 +11,7 @@ import java.util.Date;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Data @Data
@ApiModel("管理后台 - 积分规则延期 Response VO") @ApiModel("管理后台 - 积分规则延期 Request VO")
public class ScoreDelayReqVO { public class ScoreDelayReqVO {
@ApiModelProperty(value = "主键", required = true) @ApiModelProperty(value = "主键", required = true)
@NotNull(message = "主键不能为空") @NotNull(message = "主键不能为空")
......
package cn.iocoder.yudao.module.reward.api.reward; package cn.iocoder.yudao.module.reward.api.reward;
import cn.iocoder.yudao.module.reward.api.reward.dto.RedeemDetailForUserDTO;
import cn.iocoder.yudao.module.reward.api.reward.dto.RedeemRewardReqVO; import cn.iocoder.yudao.module.reward.api.reward.dto.RedeemRewardReqVO;
import cn.iocoder.yudao.module.reward.api.reward.dto.RedeemRewardRespDTO; import cn.iocoder.yudao.module.reward.api.reward.dto.RedeemRewardRespDTO;
...@@ -13,4 +14,5 @@ public interface RedeemRewardApi { ...@@ -13,4 +14,5 @@ public interface RedeemRewardApi {
RedeemRewardRespDTO redeemReward(RedeemRewardReqVO redeemRewardReqVO); RedeemRewardRespDTO redeemReward(RedeemRewardReqVO redeemRewardReqVO);
List<RedeemRewardRespDTO> redeemRewards(List<RedeemRewardReqVO> redeemRewardReqVOList); List<RedeemRewardRespDTO> redeemRewards(List<RedeemRewardReqVO> redeemRewardReqVOList);
RedeemDetailForUserDTO getRedeemDetailForUser(Long redeemId);
} }
package cn.iocoder.yudao.module.reward.api.reward.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel("用户 APP - 礼品兑换记录 DTO")
public class RedeemDetailForUserDTO {
@ApiModelProperty(value = "礼品名称中文")
private String rewardNameZh;
@ApiModelProperty(value = "礼品名称英文")
private String rewardNameEn;
@ApiModelProperty(value = "兑换数量")
private Integer rewardCount;
}
...@@ -9,6 +9,7 @@ import cn.iocoder.yudao.module.member.api.user.MemberUserApi; ...@@ -9,6 +9,7 @@ import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
import cn.iocoder.yudao.module.member.api.user.dto.UserRespDTO; import cn.iocoder.yudao.module.member.api.user.dto.UserRespDTO;
import cn.iocoder.yudao.module.member.enums.PlatformTypeEnum; import cn.iocoder.yudao.module.member.enums.PlatformTypeEnum;
import cn.iocoder.yudao.module.member.enums.ScoreSourceTypeEnum; import cn.iocoder.yudao.module.member.enums.ScoreSourceTypeEnum;
import cn.iocoder.yudao.module.reward.api.reward.dto.RedeemDetailForUserDTO;
import cn.iocoder.yudao.module.reward.api.reward.dto.RedeemRewardReqVO; import cn.iocoder.yudao.module.reward.api.reward.dto.RedeemRewardReqVO;
import cn.iocoder.yudao.module.reward.api.reward.dto.RedeemRewardRespDTO; import cn.iocoder.yudao.module.reward.api.reward.dto.RedeemRewardRespDTO;
import cn.iocoder.yudao.module.reward.dal.dataobject.redeem.RewardRedeemDO; import cn.iocoder.yudao.module.reward.dal.dataobject.redeem.RewardRedeemDO;
...@@ -188,6 +189,20 @@ public class RedeemRewardApiImpl implements RedeemRewardApi { ...@@ -188,6 +189,20 @@ public class RedeemRewardApiImpl implements RedeemRewardApi {
return null; return null;
} }
@Override
public RedeemDetailForUserDTO getRedeemDetailForUser(Long redeemId) {
RewardRedeemDO rewardRedeemDO = rewardRedeemMapper.selectById(redeemId);
if (rewardRedeemDO != null) {
RedeemDetailForUserDTO redeemDetailForUserDTO = new RedeemDetailForUserDTO();
redeemDetailForUserDTO.setRewardCount(rewardRedeemDO.getRewardCount());
RewardDO rewardDO = rewardMapper.selectById(rewardRedeemDO.getRewardId());
redeemDetailForUserDTO.setRewardNameEn(rewardDO.getTitleEn());
redeemDetailForUserDTO.setRewardNameZh(rewardDO.getTitleZh());
return redeemDetailForUserDTO;
}
return null;
}
private void verifyMemberUser(RedeemRewardReqVO redeemRewardReqVO, RewardDO rewardDO) { private void verifyMemberUser(RedeemRewardReqVO redeemRewardReqVO, RewardDO rewardDO) {
// 查询会员积分 // 查询会员积分
UserRespDTO memberUser = memberUserApi.getUser(redeemRewardReqVO.getMemberId()); UserRespDTO memberUser = memberUserApi.getUser(redeemRewardReqVO.getMemberId());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment