Commit 0904f244 authored by zhangfeng's avatar zhangfeng

客户端积分规则

parent 4de07c1d
package cn.iocoder.yudao.module.member.controller.app.scoreRule;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import cn.iocoder.yudao.module.member.api.ScoreProducerApi;
import cn.iocoder.yudao.module.member.controller.app.scoreRule.vo.AppScoreRuleBackDetailVO;
import cn.iocoder.yudao.module.member.controller.app.scoreRule.vo.AppScoreRuleListBackVO;
import cn.iocoder.yudao.module.member.controller.app.scoreRule.vo.AppScoreRuleListReqVO;
import cn.iocoder.yudao.module.member.service.scoreRule.ScoreRuleService;
import cn.iocoder.yudao.module.member.vo.scoreRule.IdReqVo;
import cn.iocoder.yudao.module.member.vo.scoreRule.ScoreRuleBackVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.ScoreRuleQueryVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.context.ApplicationContext;
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 = "客户端 - 积分规则")
@RequestMapping("/member/score-rule")
public class AppScoreRuleController {
@Resource
private ScoreRuleService scoreRuleService;
@Resource
private ApplicationContext applicationContext;
@Resource
private ScoreProducerApi scoreProducerApi;
@PostMapping("/get")
@ApiOperation("客户端获得积分规则详情")
public CommonResult<AppScoreRuleBackDetailVO> getScoreRule(@Valid @RequestBody IdReqVo idReqVo) {
AppScoreRuleBackDetailVO scoreRuleBackDetailVO = scoreRuleService.appGetScoreRule(idReqVo.getId());
return success(scoreRuleBackDetailVO);
}
@PostMapping("/list")
@ApiOperation("客户端获得积分规则列表")
public CommonResult<List<AppScoreRuleListBackVO>> getScoreRuleList(@Valid @RequestBody AppScoreRuleListReqVO reqVO) {
List<AppScoreRuleListBackVO> list = scoreRuleService.appGetScoreRuleList(reqVO);
return success(list);
}
//@PostMapping("/page")
//@ApiOperation("获得积分规则分页")
//public CommonResult<PageResult<ScoreRuleBackVO>> getScoreRulePage(@Valid @RequestBody ScoreRuleQueryVO query, PageVO page) {
// PageResult<ScoreRuleBackVO> pageResult = scoreRuleService.getScoreRulePage(query, page);
// return success(pageResult);
//}
}
package cn.iocoder.yudao.module.member.controller.app.scoreRule.vo;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleShareExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRulerRecommendExtraVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
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
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel("客户端 - 积分规则详细信息 Response VO")
public class AppScoreRuleBackDetailVO extends AppScoreRuleListBackVO {
@ApiModelProperty(value = "单次获取积分数")
private Integer getScoreOnce;
@ApiModelProperty(value = "累积最高积分")
private Integer maxScoreTotal;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "活动开始时间")
private Date startTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "活动结束时间")
private Date endTime;
@ApiModelProperty(value = "积分有效期")
private Integer scorePeriod;
//@ApiModelProperty(value = "扩展字段原始")
//private String extra;
//@ApiModelProperty(value = "订单V值扩展字段")
//private ScoreRuleOrderVExtraVO extraOrderV;
//@ApiModelProperty(value = "注册扩展字段")
//private ScoreRuleRegisterExtraVO extraRegister;
}
package cn.iocoder.yudao.module.member.controller.app.scoreRule.vo;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleShareExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRulerRecommendExtraVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 积分规则 resp VO
*
* @author 系统管理员
*/
@Data
@ApiModel("客户端 - 积分规则列表 Response VO")
public class AppScoreRuleListBackVO {
@ApiModelProperty(value = "主键", required = true)
private Long id;
@ApiModelProperty(value = "指标类型", required = true)
private Integer type;
@ApiModelProperty(value = "规则标题中文", required = true)
private String titleZh;
@ApiModelProperty(value = "规则标题英文", required = true)
private String titleEn;
@ApiModelProperty(value = "规则说明中文", required = true)
private String descZh;
@ApiModelProperty(value = "规则说明英文", required = true)
private String descEn;
@ApiModelProperty(value = "封面图中文")
private String coverImageZh;
@ApiModelProperty(value = "封面图英文")
private String coverImageEn;
@ApiModelProperty(value = "推荐扩展字段")
private ScoreRulerRecommendExtraVO extraRecommend;
@ApiModelProperty(value = "分享扩展字段")
private ScoreRuleShareExtraVO extraShare;
}
package cn.iocoder.yudao.module.member.controller.app.scoreRule.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
/**
* 积分规则 req VO
* @author 系统管理员
*/
@Data
@ApiModel("客户端 - 积分规则列表 req VO")
public class AppScoreRuleListReqVO {
@ApiModelProperty(value = "平台入口(2APP,3WEB)", required = true)
@NotNull(message = "平台入口不能为空")
private Integer platform;
}
......@@ -6,6 +6,9 @@ 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.controller.app.scoreRule.vo.AppScoreRuleBackDetailVO;
import cn.iocoder.yudao.module.member.controller.app.scoreRule.vo.AppScoreRuleListBackVO;
import cn.iocoder.yudao.module.member.controller.app.scoreRule.vo.AppScoreRuleListReqVO;
import cn.iocoder.yudao.module.member.dal.dataobject.scoreRule.ScoreRuleDO;
import cn.iocoder.yudao.module.member.enums.ScoreRuleTypeEnum;
import cn.iocoder.yudao.module.member.enums.TransportTypeEnum;
......@@ -121,4 +124,18 @@ public interface ScoreRuleService extends IService<ScoreRuleDO> {
ScoreRuleDO getEnableScoreRuleByType(ScoreRuleTypeEnum scoreRuleType, TransportTypeEnum transportType);
List<WarehouseTreeRegionSimpleVO> getWarehouseTreeRegionListSimple();
/**
* 客户端获取积分规则列表
* @param reqVO
* @return
*/
List<AppScoreRuleListBackVO> appGetScoreRuleList(AppScoreRuleListReqVO reqVO);
/**
* 客户端获取积分规则详情
* @param id
* @return
*/
AppScoreRuleBackDetailVO appGetScoreRule(Long id);
}
......@@ -3,11 +3,15 @@ package cn.iocoder.yudao.module.member.service.scoreRule;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.json.JSONUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQuery;
import cn.iocoder.yudao.framework.mybatis.core.service.AbstractService;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import cn.iocoder.yudao.module.depository.service.warehouse.WarehouseService;
import cn.iocoder.yudao.module.depository.vo.warehouse.WarehouseTreeRegionVO;
import cn.iocoder.yudao.module.member.controller.app.scoreRule.vo.AppScoreRuleBackDetailVO;
import cn.iocoder.yudao.module.member.controller.app.scoreRule.vo.AppScoreRuleListBackVO;
import cn.iocoder.yudao.module.member.controller.app.scoreRule.vo.AppScoreRuleListReqVO;
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;
......@@ -22,6 +26,7 @@ import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleRegisterExtraV
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleShareExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRulerRecommendExtraVO;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
......@@ -497,4 +502,39 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
}
return warehouseTreeRegionSimpleVOS;
}
@Override
public List<AppScoreRuleListBackVO> appGetScoreRuleList(AppScoreRuleListReqVO reqVO) {
List<ScoreRuleDO> scoreRuleDOS = scoreRuleMapper.selectList("status", ScoreRuleStatusEnum.ENABLED.getValue());
if (CollectionUtils.isNotEmpty(scoreRuleDOS)) {
List<AppScoreRuleListBackVO> appScoreRuleListBackVOS = new ArrayList<>();
for (ScoreRuleDO scoreRuleDO : scoreRuleDOS) {
// 校验平台入口
if (!Arrays.asList(scoreRuleDO.getShowPlatform().split(",")).contains(String.valueOf(reqVO.getPlatform()))) {
continue;
}
AppScoreRuleListBackVO appScoreRuleListBackVO = new AppScoreRuleListBackVO();
BeanUtils.copyProperties(scoreRuleDO, appScoreRuleListBackVO);
// 推荐和分享设置额外字段
if (scoreRuleDO.getType() == ScoreRuleTypeEnum.RECOMMEND.getValue()) {
ScoreRulerRecommendExtraVO scoreRulerRecommendExtraVO = JsonUtils.parseObject(scoreRuleDO.getExtra(), ScoreRulerRecommendExtraVO.class);
appScoreRuleListBackVO.setExtraRecommend(scoreRulerRecommendExtraVO);
} else if (scoreRuleDO.getType() == ScoreRuleTypeEnum.SHARE.getValue()) {
ScoreRuleShareExtraVO scoreRuleShareExtraVO = JsonUtils.parseObject(scoreRuleDO.getExtra(), ScoreRuleShareExtraVO.class);
appScoreRuleListBackVO.setExtraShare(scoreRuleShareExtraVO);
}
appScoreRuleListBackVOS.add(appScoreRuleListBackVO);
}
return appScoreRuleListBackVOS;
}
return null;
}
@Override
public AppScoreRuleBackDetailVO appGetScoreRule(Long id) {
ScoreRuleBackDetailVO scoreRule = getScoreRule(id);
AppScoreRuleBackDetailVO appScoreRuleBackDetailVO = new AppScoreRuleBackDetailVO();
BeanUtils.copyProperties(scoreRule, appScoreRuleBackDetailVO);
return appScoreRuleBackDetailVO;
}
}
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