Commit d5fc0620 authored by zhangfeng's avatar zhangfeng

feature-member:积分规则接口

parent 3f17a7bd
...@@ -44,5 +44,11 @@ public interface ErrorCodeConstants { ...@@ -44,5 +44,11 @@ public interface ErrorCodeConstants {
ErrorCode SCORE_COUNT_ERROR = new ErrorCode(1004008002, "score.count.error"); ErrorCode SCORE_COUNT_ERROR = new ErrorCode(1004008002, "score.count.error");
ErrorCode MEMBER_SCORE_NOT_ENOUGH = new ErrorCode(1004008002, "member.score.not.enough"); ErrorCode MEMBER_SCORE_NOT_ENOUGH = new ErrorCode(1004008003, "member.score.not.enough");
ErrorCode SCORE_RULE_NOT_EXISTS = new ErrorCode(1004008004, "score.rule.not.exists");
ErrorCode SCORE_RULE_DELETE_ERROR = new ErrorCode(1004008005, "score.rule.delete.error");
ErrorCode SCORE_RULE_UPDATE_ERROR = new ErrorCode(1004008005, "score.rule.update.error");
} }
package cn.iocoder.yudao.module.member.enums;
public enum PlatformTypeEnum {
BACKEND(1, "后台"),
APP(2, "APP"),
WEB(3, "WEB");
private final int value;
private final String name;
PlatformTypeEnum(int value, String name) {
this.value = value;
this.name = name;
}
public int getValue() {
return value;
}
public String getName() {
return name;
}
}
package cn.iocoder.yudao.module.member.enums;
public enum ScoreRuleStatusEnum {
ENABLED(1, "已启用"),
DISABLED(2, "未启用"),
CLOSED(3, "已关闭"),
EXPIRED(4, "已过期");
private final int value;
private final String name;
ScoreRuleStatusEnum(int value, String name) {
this.value = value;
this.name = name;
}
public int getValue() {
return value;
}
public String getName() {
return name;
}
}
package cn.iocoder.yudao.module.member.enums;
public enum ScoreRuleTypeEnum {
ORDER_V(1, "订单V值"),
REGISTER(2, "注册"),
RECOMMEND(3, "推荐"),
SHARE(4, "分享活动");
private final int value;
private final String name;
ScoreRuleTypeEnum(int value, String name) {
this.value = value;
this.name = name;
}
public int getValue() {
return value;
}
public String getName() {
return name;
}
}
package cn.iocoder.yudao.module.member.enums;
public enum YesOrNoTypeEnum {
YES,
NO;
}
package cn.iocoder.yudao.module.member.controller.admin.scoreRule;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.excel.util.ExcelUtils;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import cn.iocoder.yudao.module.member.convert.scoreRule.ScoreRuleConvert;
import cn.iocoder.yudao.module.member.dal.dataobject.scoreRule.ScoreRuleDO;
import cn.iocoder.yudao.module.member.service.scoreRule.ScoreRuleService;
import cn.iocoder.yudao.module.member.vo.scoreRule.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
@Validated
@RestController
@Api(tags = "管理后台 - 积分规则")
@RequestMapping("/member/score-rule")
public class ScoreRuleController {
@Resource
private ScoreRuleService scoreRuleService;
@PostMapping("/create")
@ApiOperation("创建积分规则")
@PreAuthorize("@ss.hasPermission('member:score-rule:create')")
public CommonResult<Long> createScoreRule(@Valid @RequestBody ScoreRuleCreateReqVO createReqVO) {
return success(scoreRuleService.createScoreRule(createReqVO));
}
@PostMapping("/update")
@ApiOperation("更新积分规则")
@PreAuthorize("@ss.hasPermission('member:score-rule:update')")
public CommonResult<Boolean> updateScoreRule(@Valid @RequestBody ScoreRuleUpdateReqVO updateReqVO) {
scoreRuleService.updateScoreRule(updateReqVO);
return success(true);
}
@PostMapping("/delete")
@ApiOperation("删除积分规则")
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
@PreAuthorize("@ss.hasPermission('member:score-rule:delete')")
public CommonResult<Boolean> deleteScoreRule(@NotNull @RequestBody Long id) {
scoreRuleService.deleteScoreRule(id);
return success(true);
}
@PostMapping("/get")
@ApiOperation("获得积分规则详情")
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
@PreAuthorize("@ss.hasPermission('member:score-rule:query')")
public CommonResult<ScoreRuleBackVO> getScoreRule(@NotNull @RequestBody Long id) {
ScoreRuleBackVO scoreRuleBackVO = scoreRuleService.getScoreRule(id);
return success(scoreRuleBackVO);
}
@PostMapping("/list")
@ApiOperation("获得积分规则列表")
@ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
@PreAuthorize("@ss.hasPermission('member:score-rule:query')")
public CommonResult<List<ScoreRuleBackVO>> getScoreRuleList(@NotNull @RequestBody Collection<Long> ids) {
List<ScoreRuleBackVO> list = scoreRuleService.getScoreRuleList(ids);
return success(list);
}
@PostMapping("/page")
@ApiOperation("获得积分规则分页")
@PreAuthorize("@ss.hasPermission('member:score-rule:query')")
public CommonResult<PageResult<ScoreRuleBackVO>> getScoreRulePage(@Valid @RequestBody ScoreRuleQueryVO query, PageVO page) {
PageResult<ScoreRuleBackVO> pageResult = scoreRuleService.getScoreRulePage(query, page);
return success(pageResult);
}
@PostMapping("/status")
@ApiOperation("启用关闭")
@PreAuthorize("@ss.hasPermission('member:score-rule:update')")
public CommonResult<Boolean> updateStatus(@Valid @RequestBody ScoreRuleStatusReqVO scoreRuleStatusReqVO) {
Boolean res = scoreRuleService.updateStatus(scoreRuleStatusReqVO);
return success(res);
}
@PostMapping("/copy")
@ApiOperation("复制规则")
@PreAuthorize("@ss.hasPermission('member:score-rule:create')")
public CommonResult<Long> copyScoreRule(@NotNull @RequestBody Long id) {
Long newId = scoreRuleService.copyScoreRule(id);
return success(id);
}
@PostMapping("/delay")
@ApiOperation("延期规则")
@PreAuthorize("@ss.hasPermission('member:score-rule:update')")
public CommonResult<Boolean> delayScoreRule(@Valid @RequestBody ScoreDelayReqVO scoreDelayReqVO) {
Boolean res = scoreRuleService.delayScoreRule(scoreDelayReqVO);
return success(res);
}
@GetMapping("/export-excel")
@ApiOperation("导出积分规则Excel")
@PreAuthorize("@ss.hasPermission('member:score-rule:export')")
@OperateLog(type = EXPORT)
public void exportScoreRuleExcel(@Valid ScoreRuleQueryVO query,
HttpServletResponse response) throws IOException {
List<ScoreRuleDO> list = scoreRuleService.getScoreRuleList(query);
// 导出 Excel
List<ScoreRuleBackVO> datas = ScoreRuleConvert.INSTANCE.convertList(list);
ExcelUtils.write(response, "积分规则.xls", "数据", ScoreRuleBackVO.class, datas);
}
}
package cn.iocoder.yudao.module.member.convert.scoreRule;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.member.vo.scoreRule.ScoreRuleBackVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.ScoreRuleCreateReqVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.ScoreRuleUpdateReqVO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import cn.iocoder.yudao.module.member.dal.dataobject.scoreRule.ScoreRuleDO;
/**
* 积分规则 DO Convert
* @author 系统管理员
*/
@Mapper
public interface ScoreRuleConvert {
/*****转换MapStruct*****/
ScoreRuleConvert INSTANCE = Mappers.getMapper(ScoreRuleConvert.class);
/***
* 创建VO转实体
* @param bean
* @return
*/
ScoreRuleDO convert(ScoreRuleCreateReqVO bean);
/***
* 修改VO转实体
* @param bean
* @return
*/
ScoreRuleDO convert(ScoreRuleUpdateReqVO bean);
/***
* 实体转返回VO
* @param bean
* @return
*/
ScoreRuleBackVO convert(ScoreRuleDO bean);
/***
* 实体列表转返回VO列表
* @param list
* @return
*/
List<ScoreRuleBackVO> convertList(List<ScoreRuleDO> list);
/***
* 实体分页转返回分页
* @param page
* @return
*/
PageResult<ScoreRuleBackVO> convertPage(PageResult<ScoreRuleDO> page);
}
package cn.iocoder.yudao.module.member.dal.dataobject.scoreRule;
import lombok.*;
import java.util.*;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/**
* 积分规则 DO
*
* @author 系统管理员
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName("score_rule")
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ScoreRuleDO extends BaseDO {
/**
* 主键
*/
@TableId
private Long id;
/**
* 指标类型
*/
private Integer type;
/**
* 规则标题中文
*/
private String titleZh;
/**
* 规则标题英文
*/
private String titleEn;
/**
* 规则说明中文
*/
private String descZh;
/**
* 规则说明英文
*/
private String descEn;
/**
* 封面图中文
*/
private String coverImageZh;
/**
* 封面图英文
*/
private String coverImageEn;
/**
* 单次获取积分数
*/
private Integer getScoreOnce;
/**
* 累积最高积分
*/
private Integer maxScoreTotal;
/**
* 活动开始时间
*/
private Date startTime;
/**
* 活动结束时间
*/
private Date endTime;
/**
* 积分有效期
*/
private Integer socrePeriod;
/**
* 排序值
*/
private Integer orderNum;
/**
* 是否推送
*/
private Integer pushActivity;
/**
* 展示平台
*/
private String showPlatform;
/**
* 活动状态
*/
private Integer status;
/**
* 扩展字段
*/
private String extra;
}
package cn.iocoder.yudao.module.member.dal.mysql.scoreRule;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQuery;
import cn.iocoder.yudao.framework.mybatis.core.mapper.AbstractMapper;
import cn.iocoder.yudao.module.member.dal.dataobject.scoreRule.ScoreRuleDO;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.ScoreRuleQueryVO;
import org.apache.ibatis.annotations.Mapper;
/**
* 积分规则 DO Mapper
* @author 系统管理员
*/
@Mapper
public interface ScoreRuleMapper extends AbstractMapper<ScoreRuleDO> {
@Override
default PageResult<ScoreRuleDO> selectPage(PageVO page, Object object) {
if (object instanceof ScoreRuleQueryVO) {
ScoreRuleQueryVO vo = (ScoreRuleQueryVO)object;
return selectPage(page, new LambdaQuery<ScoreRuleDO>()
.eqIfPresent(ScoreRuleDO::getType, vo.getType())
.eqIfPresent(ScoreRuleDO::getTitleZh, vo.getTitleZh())
.eqIfPresent(ScoreRuleDO::getTitleEn, vo.getTitleEn())
.eqIfPresent(ScoreRuleDO::getDescZh, vo.getDescZh())
.eqIfPresent(ScoreRuleDO::getDescEn, vo.getDescEn())
.eqIfPresent(ScoreRuleDO::getCoverImageZh, vo.getCoverImageZh())
.eqIfPresent(ScoreRuleDO::getCoverImageEn, vo.getCoverImageEn())
.eqIfPresent(ScoreRuleDO::getGetScoreOnce, vo.getGetScoreOnce())
.eqIfPresent(ScoreRuleDO::getMaxScoreTotal, vo.getMaxScoreTotal())
.betweenIfPresent(ScoreRuleDO::getStartTime, vo.getBeginStartTime(), vo.getEndStartTime())
.betweenIfPresent(ScoreRuleDO::getEndTime, vo.getBeginEndTime(), vo.getEndEndTime())
.eqIfPresent(ScoreRuleDO::getSocrePeriod, vo.getSocrePeriod())
.eqIfPresent(ScoreRuleDO::getOrderNum, vo.getOrderNum())
.eqIfPresent(ScoreRuleDO::getPushActivity, vo.getPushActivity())
.eqIfPresent(ScoreRuleDO::getShowPlatform, vo.getShowPlatform())
.eqIfPresent(ScoreRuleDO::getStatus, vo.getStatus())
.eqIfPresent(ScoreRuleDO::getExtra, vo.getExtra())
.betweenIfPresent(ScoreRuleDO::getCreateTime, vo.getBeginCreateTime(), vo.getEndCreateTime())
.orderByDesc(ScoreRuleDO::getId));
}
return null;
}
@Override
default List<ScoreRuleDO> selectList(Object object) {
if (object instanceof ScoreRuleQueryVO) {
ScoreRuleQueryVO vo = (ScoreRuleQueryVO)object;
return selectList(new LambdaQuery<ScoreRuleDO>()
.eqIfPresent(ScoreRuleDO::getType, vo.getType())
.eqIfPresent(ScoreRuleDO::getTitleZh, vo.getTitleZh())
.eqIfPresent(ScoreRuleDO::getTitleEn, vo.getTitleEn())
.eqIfPresent(ScoreRuleDO::getDescZh, vo.getDescZh())
.eqIfPresent(ScoreRuleDO::getDescEn, vo.getDescEn())
.eqIfPresent(ScoreRuleDO::getCoverImageZh, vo.getCoverImageZh())
.eqIfPresent(ScoreRuleDO::getCoverImageEn, vo.getCoverImageEn())
.eqIfPresent(ScoreRuleDO::getGetScoreOnce, vo.getGetScoreOnce())
.eqIfPresent(ScoreRuleDO::getMaxScoreTotal, vo.getMaxScoreTotal())
.betweenIfPresent(ScoreRuleDO::getStartTime, vo.getBeginStartTime(), vo.getEndStartTime())
.betweenIfPresent(ScoreRuleDO::getEndTime, vo.getBeginEndTime(), vo.getEndEndTime())
.eqIfPresent(ScoreRuleDO::getSocrePeriod, vo.getSocrePeriod())
.eqIfPresent(ScoreRuleDO::getOrderNum, vo.getOrderNum())
.eqIfPresent(ScoreRuleDO::getPushActivity, vo.getPushActivity())
.eqIfPresent(ScoreRuleDO::getShowPlatform, vo.getShowPlatform())
.eqIfPresent(ScoreRuleDO::getStatus, vo.getStatus())
.eqIfPresent(ScoreRuleDO::getExtra, vo.getExtra())
.betweenIfPresent(ScoreRuleDO::getCreateTime, vo.getBeginCreateTime(), vo.getEndCreateTime())
.orderByDesc(ScoreRuleDO::getId));
}
return null;
}
}
package cn.iocoder.yudao.module.member.service.scoreRule;
import java.util.*;
import javax.validation.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.service.IService;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import cn.iocoder.yudao.module.member.dal.dataobject.scoreRule.ScoreRuleDO;
import cn.iocoder.yudao.module.member.vo.scoreRule.*;
/**
* 积分规则 Service 接口
*
* @author 系统管理员
*/
public interface ScoreRuleService extends IService<ScoreRuleDO> {
/**
* 创建积分规则
* @param createReqVO 创建信息
* @return 编号
*/
Long createScoreRule(@Valid ScoreRuleCreateReqVO createReqVO);
/**
* 更新积分规则
* @param updateReqVO 更新信息
*/
void updateScoreRule(@Valid ScoreRuleUpdateReqVO updateReqVO);
/**
* 删除积分规则
* @param id 编号
*/
void deleteScoreRule(Long id);
/**
* 获得积分规则
*
* @param id 编号
* @return 积分规则
*/
ScoreRuleBackVO getScoreRule(Long id);
/**
* 获得积分规则列表
*
* @param ids 编号
* @return 积分规则列表
*/
List<ScoreRuleBackVO> getScoreRuleList(Collection<Long> ids);
/**
* 获得积分规则分页
*
* @param page 分页查询
* @param query 查询
* @return 积分规则分页
*/
PageResult<ScoreRuleBackVO> getScoreRulePage(ScoreRuleQueryVO query, PageVO page);
/**
* 获得积分规则列表, 用于 Excel 导出
* @param query 查询
* @return 积分规则列表
*/
List<ScoreRuleDO> getScoreRuleList(ScoreRuleQueryVO query);
/**
* 积分规则启用关闭
* @param scoreRuleStatusReqVO 积分规则状态
* @return
*/
Boolean updateStatus(ScoreRuleStatusReqVO scoreRuleStatusReqVO);
/**
* 积分规则复制
* @param id
* @return
*/
Long copyScoreRule(Long id);
/**
* 积分规则延期
* @param scoreDelayReqVO 积分规则延期
* @return
*/
Boolean delayScoreRule(ScoreDelayReqVO scoreDelayReqVO);
}
package cn.iocoder.yudao.module.member.service.scoreRule;
import java.time.Instant;
import java.util.*;
import javax.annotation.Resource;
import cn.hutool.json.JSONUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.service.AbstractService;
import cn.iocoder.yudao.module.member.convert.scoreRule.ScoreRuleConvert;
import cn.iocoder.yudao.module.member.dal.dataobject.scoreRule.ScoreRuleDO;
import cn.iocoder.yudao.module.member.dal.mysql.scoreRule.ScoreRuleMapper;
import cn.iocoder.yudao.module.member.enums.ScoreRuleStatusEnum;
import cn.iocoder.yudao.module.member.enums.ScoreRuleTypeEnum;
import cn.iocoder.yudao.module.member.vo.scoreRule.*;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleOrderVExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleRegisterExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleShareExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRulerRecommendExtraVO;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*;
/**
* 积分规则 Service 实现类
*
* @author 系统管理员
*/
@Service
@Validated
public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, ScoreRuleDO> implements ScoreRuleService {
@Resource
private ScoreRuleMapper scoreRuleMapper;
@Override
public Long createScoreRule(ScoreRuleCreateReqVO createReqVO) {
ScoreRuleDO scoreRule = ScoreRuleConvert.INSTANCE.convert(createReqVO);
Integer scoreRuleType = scoreRule.getType();
setExtraDO(createReqVO, scoreRuleType, scoreRule);
scoreRuleMapper.insert(scoreRule);
// 返回
return scoreRule.getId();
}
@Override
public void updateScoreRule(ScoreRuleUpdateReqVO updateReqVO) {
// 校验存在
this.validateScoreRuleExists(updateReqVO.getId());
ScoreRuleDO scoreRule = ScoreRuleConvert.INSTANCE.convert(updateReqVO);
setExtraDO(updateReqVO, updateReqVO.getType(), scoreRule);
// 更新
ScoreRuleDO updateObj = ScoreRuleConvert.INSTANCE.convert(updateReqVO);
scoreRuleMapper.updateById(updateObj);
}
/**
* 设置额外信息
*
* @param reqVO 请求实体
* @param scoreRuleType 指标类型
* @param scoreRule 需要填充额外字段的DO
*/
private void setExtraDO(ScoreRuleBaseVO reqVO, Integer scoreRuleType, ScoreRuleDO scoreRule) {
if (scoreRuleType == ScoreRuleTypeEnum.ORDER_V.getValue()) {
scoreRule.setExtra(JSONUtil.toJsonStr(reqVO.getExtraOrderV()));
} else if (scoreRuleType == ScoreRuleTypeEnum.REGISTER.getValue()) {
scoreRule.setExtra(JSONUtil.toJsonStr(reqVO.getExtraRegister()));
} else if (scoreRuleType == ScoreRuleTypeEnum.RECOMMEND.getValue()) {
scoreRule.setExtra(JSONUtil.toJsonStr(reqVO.getExtraRecommend()));
} else if (scoreRuleType == ScoreRuleTypeEnum.SHARE.getValue()) {
scoreRule.setExtra(JSONUtil.toJsonStr(reqVO.getExtraShare()));
} else {
throw exception(SCORE_RULE_NOT_EXISTS);
}
}
@Override
public void deleteScoreRule(Long id) {
ScoreRuleDO scoreRuleDO = scoreRuleMapper.selectById(id);
if (scoreRuleDO == null) {
throw exception(SCORE_RULE_NOT_EXISTS);
}
if (scoreRuleDO.getStatus() == ScoreRuleStatusEnum.ENABLED.getValue()) {
throw exception(SCORE_RULE_DELETE_ERROR);
}
// 删除
scoreRuleMapper.deleteById(id);
}
private void validateScoreRuleExists(Long id) {
if (scoreRuleMapper.selectById(id) == null) {
throw exception(SCORE_RULE_NOT_EXISTS);
}
}
@Override
public ScoreRuleBackVO getScoreRule(Long id) {
ScoreRuleDO scoreRuleDO = scoreRuleMapper.selectById(id);
if (scoreRuleDO == null) {
throw exception(SCORE_RULE_NOT_EXISTS);
}
ScoreRuleBackVO scoreRuleBackVO = ScoreRuleConvert.INSTANCE.convert(scoreRuleDO);
setExtraVO(scoreRuleBackVO);
return scoreRuleBackVO;
}
@Override
public List<ScoreRuleBackVO> getScoreRuleList(Collection<Long> ids) {
List<ScoreRuleDO> scoreRuleDOS = scoreRuleMapper.selectBatchIds(ids);
List<ScoreRuleBackVO> scoreRuleBackVOS = ScoreRuleConvert.INSTANCE.convertList(scoreRuleDOS);
scoreRuleBackVOS.forEach(this::setExtraVO);
return scoreRuleBackVOS;
}
@Override
public PageResult<ScoreRuleBackVO> getScoreRulePage(ScoreRuleQueryVO query, PageVO page) {
PageResult<ScoreRuleDO> pageResult = scoreRuleMapper.selectPage(page, query);
PageResult<ScoreRuleBackVO> scoreRuleBackVOPageResult = ScoreRuleConvert.INSTANCE.convertPage(pageResult);
scoreRuleBackVOPageResult.getList().forEach(this::setExtraVO);
return scoreRuleBackVOPageResult;
}
/**
* 设置返回VO额外信息
*
* @param scoreRuleBackVO VO
*/
private void setExtraVO(ScoreRuleBackVO scoreRuleBackVO) {
if (scoreRuleBackVO.getType() == ScoreRuleTypeEnum.ORDER_V.getValue()) {
scoreRuleBackVO.setExtraOrderV(JSONUtil.toBean(scoreRuleBackVO.getExtra(), ScoreRuleOrderVExtraVO.class));
} else if (scoreRuleBackVO.getType() == ScoreRuleTypeEnum.REGISTER.getValue()) {
scoreRuleBackVO.setExtraRegister(JSONUtil.toBean(scoreRuleBackVO.getExtra(), ScoreRuleRegisterExtraVO.class));
} else if (scoreRuleBackVO.getType() == ScoreRuleTypeEnum.RECOMMEND.getValue()) {
scoreRuleBackVO.setExtraRecommend(JSONUtil.toBean(scoreRuleBackVO.getExtra(), ScoreRulerRecommendExtraVO.class));
} else if (scoreRuleBackVO.getType() == ScoreRuleTypeEnum.SHARE.getValue()) {
scoreRuleBackVO.setExtraShare(JSONUtil.toBean(scoreRuleBackVO.getExtra(), ScoreRuleShareExtraVO.class));
} else {
throw exception(SCORE_RULE_NOT_EXISTS);
}
}
@Override
public List<ScoreRuleDO> getScoreRuleList(ScoreRuleQueryVO query) {
return scoreRuleMapper.selectList(query);
}
@Override
public Boolean updateStatus(ScoreRuleStatusReqVO scoreRuleStatusReqVO) {
ScoreRuleDO scoreRuleDO = scoreRuleMapper.selectById(scoreRuleStatusReqVO.getId());
if (scoreRuleDO == null) {
throw exception(SCORE_RULE_NOT_EXISTS);
}
ScoreRuleDO upScoreRuleDO = new ScoreRuleDO();
upScoreRuleDO.setId(scoreRuleStatusReqVO.getId());
upScoreRuleDO.setStatus(scoreRuleStatusReqVO.getStatus());
int updated = scoreRuleMapper.updateById(upScoreRuleDO);
return updated > 0;
}
@Override
public Long copyScoreRule(Long id) {
ScoreRuleDO scoreRuleDO = scoreRuleMapper.selectById(id);
if (scoreRuleDO == null) {
throw exception(SCORE_RULE_NOT_EXISTS);
}
scoreRuleDO.setStatus(ScoreRuleStatusEnum.DISABLED.getValue());
scoreRuleDO.setId(null);
scoreRuleDO.setCreateTime(null);
scoreRuleDO.setUpdateTime(null);
scoreRuleMapper.insert(scoreRuleDO);
return scoreRuleDO.getId();
}
@Override
public Boolean delayScoreRule(ScoreDelayReqVO delayReqVO) {
ScoreRuleDO scoreRuleDO = scoreRuleMapper.selectById(delayReqVO.getId());
if (scoreRuleDO == null) {
throw exception(SCORE_RULE_NOT_EXISTS);
}
if (scoreRuleDO.getStatus() != ScoreRuleStatusEnum.ENABLED.getValue()) {
throw exception(SCORE_RULE_UPDATE_ERROR);
}
Instant now = Instant.now();
//结束时间不能小于当前时间
if (!delayReqVO.getEndTime().toInstant().isAfter(now)) {
throw exception(SCORE_RULE_UPDATE_ERROR);
}
ScoreRuleDO upScoreRuleDO = new ScoreRuleDO();
upScoreRuleDO.setId(delayReqVO.getId());
upScoreRuleDO.setEndTime(delayReqVO.getEndTime());
int updated = scoreRuleMapper.updateById(upScoreRuleDO);
return updated > 0;
}
}
package cn.iocoder.yudao.module.member.vo.scoreRule;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotNull;
import java.util.Date;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Data
@ApiModel("管理后台 - 积分规则延期 Response VO")
public class ScoreDelayReqVO {
@ApiModelProperty(value = "主键", required = true)
@NotNull(message = "主键不能为空")
private Long id;
@ApiModelProperty(value = "结束时间", required = true)
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@NotNull(message = "结束时间不能为空")
private Date endTime;
}
package cn.iocoder.yudao.module.member.vo.scoreRule;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleOrderVExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleRegisterExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleShareExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRulerRecommendExtraVO;
import com.baomidou.dynamic.datasource.annotation.DS;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import com.alibaba.excel.annotation.ExcelProperty;
import org.springframework.format.annotation.DateTimeFormat;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
/**
* 积分规则 Response VO
* @author 系统管理员
*/
@Data
@ApiModel("管理后台 - 积分规则 Response VO")
public class ScoreRuleBackVO {
@ExcelProperty("主键")
@ApiModelProperty(value = "主键", required = true)
private Long id;
@ExcelProperty("指标类型")
@ApiModelProperty(value = "指标类型", required = true)
private Integer type;
@ExcelProperty("规则标题中文")
@ApiModelProperty(value = "规则标题中文", required = true)
private String titleZh;
@ExcelProperty("规则标题英文")
@ApiModelProperty(value = "规则标题英文", required = true)
private String titleEn;
@ExcelProperty("规则说明中文")
@ApiModelProperty(value = "规则说明中文", required = true)
private String descZh;
@ExcelProperty("规则说明英文")
@ApiModelProperty(value = "规则说明英文", required = true)
private String descEn;
@ExcelProperty("封面图中文")
@ApiModelProperty(value = "封面图中文")
private String coverImageZh;
@ExcelProperty("封面图英文")
@ApiModelProperty(value = "封面图英文")
private String coverImageEn;
@ExcelProperty("单次获取积分数")
@ApiModelProperty(value = "单次获取积分数", required = true)
private Integer getScoreOnce;
@ExcelProperty("累积最高积分")
@ApiModelProperty(value = "累积最高积分", required = true)
private Integer maxScoreTotal;
@ExcelProperty("活动开始时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "活动开始时间", required = true)
private Date startTime;
@ExcelProperty("活动结束时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "活动结束时间", required = true)
private Date endTime;
@ExcelProperty("积分有效期")
@ApiModelProperty(value = "积分有效期", required = true)
private Integer socrePeriod;
@ExcelProperty("排序值")
@ApiModelProperty(value = "排序值", required = true)
private Integer orderNum;
@ExcelProperty("是否推送")
@ApiModelProperty(value = "是否推送", required = true)
private Integer pushActivity;
@ExcelProperty("展示平台")
@ApiModelProperty(value = "展示平台", required = true)
private String showPlatform;
@ExcelProperty("活动状态")
@ApiModelProperty(value = "活动状态", required = true)
private Integer status;
@ExcelProperty("创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "创建时间", required = true)
private Date createTime;
@ApiModelProperty(value = "扩展字段原始")
private String extra;
@ApiModelProperty(value = "订单V值扩展字段")
private ScoreRuleOrderVExtraVO extraOrderV;
@ApiModelProperty(value = "注册扩展字段")
private ScoreRuleRegisterExtraVO extraRegister;
@ApiModelProperty(value = "推荐扩展字段")
private ScoreRulerRecommendExtraVO extraRecommend;
@ApiModelProperty(value = "分享扩展字段")
private ScoreRuleShareExtraVO extraShare;
}
package cn.iocoder.yudao.module.member.vo.scoreRule;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleOrderVExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleRegisterExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleShareExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRulerRecommendExtraVO;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import javax.validation.constraints.*;
import org.springframework.format.annotation.DateTimeFormat;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
/**
* 积分规则 Base VO,提供给添加、修改、详细的子 VO 使用
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
*/
@Data
public class ScoreRuleBaseVO {
@ApiModelProperty(value = "指标类型(1订单V值,2注册,3推荐,4分享)", required = true)
@NotNull(message = "指标类型不能为空")
private Integer type;
@ApiModelProperty(value = "规则标题中文", required = true)
@NotNull(message = "规则标题中文不能为空")
private String titleZh;
@ApiModelProperty(value = "规则标题英文", required = true)
@NotNull(message = "规则标题英文不能为空")
private String titleEn;
@ApiModelProperty(value = "规则说明中文", required = true)
@NotNull(message = "规则说明中文不能为空")
private String descZh;
@ApiModelProperty(value = "规则说明英文", required = true)
@NotNull(message = "规则说明英文不能为空")
private String descEn;
@ApiModelProperty(value = "封面图中文")
private String coverImageZh;
@ApiModelProperty(value = "封面图英文")
private String coverImageEn;
@ApiModelProperty(value = "单次获取积分数,订单V值中代表单次最高获取积分数", required = true)
@NotNull(message = "单次获取积分数不能为空")
private Integer getScoreOnce;
@ApiModelProperty(value = "累积最高积分(注册直接传null)", required = true)
private Integer maxScoreTotal;
@ApiModelProperty(value = "活动开始时间", required = true)
@NotNull(message = "活动开始时间不能为空")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private Date startTime;
@ApiModelProperty(value = "活动结束时间", required = true)
@NotNull(message = "活动结束时间不能为空")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private Date endTime;
@ApiModelProperty(value = "积分有效期(天)", required = true)
@NotNull(message = "积分有效期不能为空")
private Integer scorePeriod;
@ApiModelProperty(value = "排序值", required = true)
@NotNull(message = "排序值不能为空")
private Integer orderNum;
@ApiModelProperty(value = "是否推送(0是,1否)", required = true)
@NotNull(message = "是否推送不能为空")
private Integer pushActivity = 0;
@ApiModelProperty(value = "展示平台(1后台,2APP,3WEB)可多选,示例(1,2,3)", required = true)
@NotNull(message = "展示平台不能为空")
private String showPlatform;
@ApiModelProperty(value = "活动状态(1已启用,2未启用,3已关闭,4已过期)", required = true)
@NotNull(message = "活动状态不能为空")
private Integer status;
@ApiModelProperty(value = "订单V值扩展字段")
private ScoreRuleOrderVExtraVO extraOrderV;
@ApiModelProperty(value = "注册扩展字段")
private ScoreRuleRegisterExtraVO extraRegister;
@ApiModelProperty(value = "推荐扩展字段")
private ScoreRulerRecommendExtraVO extraRecommend;
@ApiModelProperty(value = "分享扩展字段")
private ScoreRuleShareExtraVO extraShare;
}
package cn.iocoder.yudao.module.member.vo.scoreRule;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleOrderVExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleRegisterExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleShareExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRulerRecommendExtraVO;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import javax.validation.constraints.*;
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel("管理后台 - 积分规则创建 Request VO")
public class ScoreRuleCreateReqVO extends ScoreRuleBaseVO {
}
package cn.iocoder.yudao.module.member.vo.scoreRule;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Data
@ApiModel("管理后台 - 积分规则查询 VO")
public class ScoreRuleQueryVO {
@ApiModelProperty(value = "指标类型")
private Integer type;
@ApiModelProperty(value = "规则标题中文")
private String titleZh;
@ApiModelProperty(value = "规则标题英文")
private String titleEn;
@ApiModelProperty(value = "规则说明中文")
private String descZh;
@ApiModelProperty(value = "规则说明英文")
private String descEn;
@ApiModelProperty(value = "封面图中文")
private String coverImageZh;
@ApiModelProperty(value = "封面图英文")
private String coverImageEn;
@ApiModelProperty(value = "单次获取积分数")
private Integer getScoreOnce;
@ApiModelProperty(value = "累积最高积分")
private Integer maxScoreTotal;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始活动开始时间")
private Date beginStartTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束活动开始时间")
private Date endStartTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始活动结束时间")
private Date beginEndTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束活动结束时间")
private Date endEndTime;
@ApiModelProperty(value = "积分有效期")
private Integer socrePeriod;
@ApiModelProperty(value = "排序值")
private Integer orderNum;
@ApiModelProperty(value = "是否推送")
private Integer pushActivity;
@ApiModelProperty(value = "展示平台")
private String showPlatform;
@ApiModelProperty(value = "活动状态")
private Integer status;
@ApiModelProperty(value = "扩展字段")
private String extra;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始创建时间")
private Date beginCreateTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束创建时间")
private Date endCreateTime;
}
package cn.iocoder.yudao.module.member.vo.scoreRule;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
@Data
@ApiModel("管理后台 - 启用关闭规则 VO")
public class ScoreRuleStatusReqVO {
@ApiModelProperty(value = "主键", required = true)
@NotNull(message = "主键不能为空")
private Long id;
@ApiModelProperty(value = "状态(1已启用,2未启用,3已关闭,4已过期)", required = true)
@NotNull(message = "状态不能为空")
private Integer status;
}
package cn.iocoder.yudao.module.member.vo.scoreRule;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleOrderVExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleRegisterExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleShareExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRulerRecommendExtraVO;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import javax.validation.constraints.*;
@ApiModel("管理后台 - 积分规则更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ScoreRuleUpdateReqVO extends ScoreRuleBaseVO {
@ApiModelProperty(value = "主键", required = true)
@NotNull(message = "主键不能为空")
private Long id;
}
package cn.iocoder.yudao.module.member.vo.scoreRule.extra;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
@ApiModel("管理后台 - 订单V值额外字段 VO")
public class ScoreRuleOrderVExtraVO {
@ApiModelProperty(value = "是否首单(0是,1否)默认否", required = true)
private Integer firstOrder = 1;
@ApiModelProperty(value = "运输方式(1海运拼柜,3专线空运)字典有", required = true)
private Integer transportType;
@ApiModelProperty(value = "目的国,可多选,逗号拼接", required = true)
private String targetCountry;
@ApiModelProperty(value = "目的城市,可多选,逗号拼接", required = true)
private String targetCity;
@ApiModelProperty(value = "提货点,可多选,逗号拼接", required = true)
private String receiveAddr;
@ApiModelProperty(value = "渠道,运输方式选择海运时,渠道隐藏,可多选,逗号拼接")
private String channel;
@ApiModelProperty(value = "积分规则列表", required = true)
private List<OrderVRule> orderVRule;
@ApiModelProperty(value = "订单入口(1后台,2APP,3WEB)可多选,逗号拼", required = true)
private String orderEntry;
@Data
public static class OrderVRule {
@ApiModelProperty(value = "起始重量/体积")
private Integer low;
@ApiModelProperty(value = "截止重量/体积")
private Integer high;
@ApiModelProperty(value = "积分")
private Integer score;
}
}
package cn.iocoder.yudao.module.member.vo.scoreRule.extra;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel("管理后台 - 注册额外字段 VO")
public class ScoreRuleRegisterExtraVO {
@ApiModelProperty(value = "注册平台(2APP,3WEB)可多选,逗号拼", required = true)
private String registerPlatform ;
}
package cn.iocoder.yudao.module.member.vo.scoreRule.extra;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel("管理后台 - 分享额外字段 VO")
public class ScoreRuleShareExtraVO {
@ApiModelProperty(value = "中文活动内容", required = true)
private String activityDescZh ;
@ApiModelProperty(value = "英文活动内容", required = true)
private String activityDescEn ;
@ApiModelProperty(value = "活动链接", required = true)
private String activityUrl ;
@ApiModelProperty(value = "是否分享(0是,1否)默认是", required = true)
private String shareStatus ;
}
package cn.iocoder.yudao.module.member.vo.scoreRule.extra;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel("管理后台 - 推荐额外字段 VO")
public class ScoreRulerRecommendExtraVO {
@ApiModelProperty(value = "中文分享文案", required = true)
private String shareContentZh ;
@ApiModelProperty(value = "英文分享文案", required = true)
private String shareContentEn ;
@ApiModelProperty(value = "是否分享(0是,1否)默认是", required = true)
private Integer shareStatus = 0;
}
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