Commit 8526f66c authored by zhangfeng's avatar zhangfeng

feature-reward:补充功能

parent 042ebb13
...@@ -26,12 +26,8 @@ public interface RewardMapper extends AbstractMapper<RewardDO> { ...@@ -26,12 +26,8 @@ public interface RewardMapper extends AbstractMapper<RewardDO> {
.eqIfPresent(RewardDO::getTitleFr, vo.getTitle()) .eqIfPresent(RewardDO::getTitleFr, vo.getTitle())
.eqIfPresent(RewardDO::getPointsRequire, vo.getPointsRequire()) .eqIfPresent(RewardDO::getPointsRequire, vo.getPointsRequire())
.eqIfPresent(RewardDO::getNodeId, vo.getNodeId()) .eqIfPresent(RewardDO::getNodeId, vo.getNodeId())
.eqIfPresent(RewardDO::getExchangeCount, vo.getExchangeCount())
.eqIfPresent(RewardDO::getQuantityRemain, vo.getQuantityRemain()) .eqIfPresent(RewardDO::getQuantityRemain, vo.getQuantityRemain())
.betweenIfPresent(RewardDO::getStartTime, vo.getBeginStartTime(), vo.getEndStartTime())
.betweenIfPresent(RewardDO::getEndTime, vo.getBeginEndTime(), vo.getEndEndTime())
.eqIfPresent(RewardDO::getPickMethod, vo.getPickMethod()) .eqIfPresent(RewardDO::getPickMethod, vo.getPickMethod())
.eqIfPresent(RewardDO::getAllowCount, vo.getAllowCount())
.eqIfPresent(RewardDO::getStatus, vo.getStatus()) .eqIfPresent(RewardDO::getStatus, vo.getStatus())
.betweenIfPresent(RewardDO::getCreateTime, vo.getBeginCreateTime(), vo.getEndCreateTime()) .betweenIfPresent(RewardDO::getCreateTime, vo.getBeginCreateTime(), vo.getEndCreateTime())
.orderByDesc(RewardDO::getId)); .orderByDesc(RewardDO::getId));
...@@ -51,12 +47,8 @@ public interface RewardMapper extends AbstractMapper<RewardDO> { ...@@ -51,12 +47,8 @@ public interface RewardMapper extends AbstractMapper<RewardDO> {
.eqIfPresent(RewardDO::getTitleFr, vo.getTitle()) .eqIfPresent(RewardDO::getTitleFr, vo.getTitle())
.eqIfPresent(RewardDO::getPointsRequire, vo.getPointsRequire()) .eqIfPresent(RewardDO::getPointsRequire, vo.getPointsRequire())
.eqIfPresent(RewardDO::getNodeId, vo.getNodeId()) .eqIfPresent(RewardDO::getNodeId, vo.getNodeId())
.eqIfPresent(RewardDO::getExchangeCount, vo.getExchangeCount())
.eqIfPresent(RewardDO::getQuantityRemain, vo.getQuantityRemain()) .eqIfPresent(RewardDO::getQuantityRemain, vo.getQuantityRemain())
.betweenIfPresent(RewardDO::getStartTime, vo.getBeginStartTime(), vo.getEndStartTime())
.betweenIfPresent(RewardDO::getEndTime, vo.getBeginEndTime(), vo.getEndEndTime())
.eqIfPresent(RewardDO::getPickMethod, vo.getPickMethod()) .eqIfPresent(RewardDO::getPickMethod, vo.getPickMethod())
.eqIfPresent(RewardDO::getAllowCount, vo.getAllowCount())
.eqIfPresent(RewardDO::getStatus, vo.getStatus()) .eqIfPresent(RewardDO::getStatus, vo.getStatus())
.betweenIfPresent(RewardDO::getCreateTime, vo.getBeginCreateTime(), vo.getEndCreateTime()) .betweenIfPresent(RewardDO::getCreateTime, vo.getBeginCreateTime(), vo.getEndCreateTime())
.orderByDesc(RewardDO::getId)); .orderByDesc(RewardDO::getId));
......
...@@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.reward.service.reward; ...@@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.reward.service.reward;
import java.util.*; import java.util.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQuery;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO; import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
...@@ -11,6 +13,7 @@ import cn.iocoder.yudao.module.reward.dal.dataobject.reward.RewardDO; ...@@ -11,6 +13,7 @@ import cn.iocoder.yudao.module.reward.dal.dataobject.reward.RewardDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.reward.convert.reward.RewardConvert; import cn.iocoder.yudao.module.reward.convert.reward.RewardConvert;
import cn.iocoder.yudao.module.reward.dal.mysql.reward.RewardMapper; import cn.iocoder.yudao.module.reward.dal.mysql.reward.RewardMapper;
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.reward.enums.ErrorCodeConstants.*; import static cn.iocoder.yudao.module.reward.enums.ErrorCodeConstants.*;
import static com.baomidou.mybatisplus.core.toolkit.IdWorker.getId; import static com.baomidou.mybatisplus.core.toolkit.IdWorker.getId;
...@@ -31,10 +34,10 @@ public class RewardServiceImpl extends AbstractService<RewardMapper, RewardDO> i ...@@ -31,10 +34,10 @@ public class RewardServiceImpl extends AbstractService<RewardMapper, RewardDO> i
public Long create(RewardCreateReqVO createReqVO) { public Long create(RewardCreateReqVO createReqVO) {
// 插入 // 插入
RewardDO rewardDO = RewardConvert.INSTANCE.convert(createReqVO); RewardDO rewardDO = RewardConvert.INSTANCE.convert(createReqVO);
rewardDO.setCode("111"); rewardDO.setCode(generateRewardCode());
int id = rewardMapper.insert(rewardDO); rewardMapper.insert(rewardDO);
// 返回 // 返回
return (long)id; return rewardDO.getId();
} }
@Override @Override
...@@ -72,7 +75,20 @@ public class RewardServiceImpl extends AbstractService<RewardMapper, RewardDO> i ...@@ -72,7 +75,20 @@ public class RewardServiceImpl extends AbstractService<RewardMapper, RewardDO> i
@Override @Override
public PageResult<RewardDO> getPage(RewardQueryVO query, PageVO page) { public PageResult<RewardDO> getPage(RewardQueryVO query, PageVO page) {
return rewardMapper.selectPage(page, query);
PageResult<RewardDO> rewardDOPageResult = rewardMapper.selectPage(page, new LambdaQuery<RewardDO>()
.eqIfPresent(RewardDO::getCode, query.getCode())
.eqIfPresent(RewardDO::getTitleZh, query.getTitle())
.eqIfPresent(RewardDO::getTitleEn, query.getTitle())
.eqIfPresent(RewardDO::getTitleFr, query.getTitle())
.eqIfPresent(RewardDO::getPointsRequire, query.getPointsRequire())
.eqIfPresent(RewardDO::getNodeId, query.getNodeId())
.eqIfPresent(RewardDO::getQuantityRemain, query.getQuantityRemain())
.eqIfPresent(RewardDO::getPickMethod, query.getPickMethod())
.eqIfPresent(RewardDO::getStatus, query.getStatus())
.betweenIfPresent(RewardDO::getCreateTime, query.getBeginCreateTime(), query.getEndCreateTime())
.orderByDesc(RewardDO::getId));
return rewardDOPageResult;
} }
@Override @Override
...@@ -81,7 +97,8 @@ public class RewardServiceImpl extends AbstractService<RewardMapper, RewardDO> i ...@@ -81,7 +97,8 @@ public class RewardServiceImpl extends AbstractService<RewardMapper, RewardDO> i
} }
//生成礼品ID //生成礼品ID
private String generateRewardCode(){ private String generateRewardCode() {
return String.valueOf(getId()); String uuid = UUID.randomUUID().toString().replaceAll("-", "");
return uuid.substring(0, 12).toUpperCase();
} }
} }
...@@ -15,8 +15,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ ...@@ -15,8 +15,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@Data @Data
public class RewardBaseVO { public class RewardBaseVO {
@ApiModelProperty(value = "礼品ID", required = true) @ApiModelProperty(value = "礼品ID")
@NotNull(message = "礼品ID不能为空")
private String code; private String code;
@ApiModelProperty(value = "中文名称") @ApiModelProperty(value = "中文名称")
...@@ -37,19 +36,16 @@ public class RewardBaseVO { ...@@ -37,19 +36,16 @@ public class RewardBaseVO {
@ApiModelProperty(value = "法文礼品图片") @ApiModelProperty(value = "法文礼品图片")
private String imgFr; private String imgFr;
@ApiModelProperty(value = "兑换所需积分", required = true) @ApiModelProperty(value = "兑换所需积分")
@NotNull(message = "兑换所需积分不能为空")
private Integer pointsRequire; private Integer pointsRequire;
@ApiModelProperty(value = "兑换网点", required = true) @ApiModelProperty(value = "兑换网点")
@NotNull(message = "兑换网点不能为空")
private Integer nodeId; private Integer nodeId;
@ApiModelProperty(value = "已兑换次数") @ApiModelProperty(value = "已兑换次数")
private Integer exchangeCount; private Integer exchangeCount;
@ApiModelProperty(value = "剩余数量", required = true) @ApiModelProperty(value = "剩余数量")
@NotNull(message = "剩余数量不能为空")
private Integer quantityRemain; private Integer quantityRemain;
@ApiModelProperty(value = "活动开始时间") @ApiModelProperty(value = "活动开始时间")
...@@ -60,12 +56,10 @@ public class RewardBaseVO { ...@@ -60,12 +56,10 @@ public class RewardBaseVO {
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private Date endTime; private Date endTime;
@ApiModelProperty(value = "领取方式(1上门领取,2包邮到家,3邮寄到付)", required = true) @ApiModelProperty(value = "领取方式(1上门领取,2包邮到家,3邮寄到付)")
@NotNull(message = "领取方式(1上门领取,2包邮到家,3邮寄到付)不能为空")
private Integer pickMethod; private Integer pickMethod;
@ApiModelProperty(value = "允许兑换次数", required = true) @ApiModelProperty(value = "允许兑换次数")
@NotNull(message = "允许兑换次数不能为空")
private Integer allowCount; private Integer allowCount;
@ApiModelProperty(value = "中文备注") @ApiModelProperty(value = "中文备注")
...@@ -77,8 +71,7 @@ public class RewardBaseVO { ...@@ -77,8 +71,7 @@ public class RewardBaseVO {
@ApiModelProperty(value = "法文备注") @ApiModelProperty(value = "法文备注")
private String remarkFr; private String remarkFr;
@ApiModelProperty(value = "礼品状态(1已启用,2未启用,3已关闭,4已过期)", required = true) @ApiModelProperty(value = "礼品状态(1已启用,2未启用,3已关闭,4已过期)")
@NotNull(message = "礼品状态(1已启用,2未启用,3已关闭,4已过期)不能为空")
private Integer status; private Integer status;
} }
...@@ -21,37 +21,21 @@ public class RewardQueryVO { ...@@ -21,37 +21,21 @@ public class RewardQueryVO {
@ApiModelProperty(value = "兑换所需积分") @ApiModelProperty(value = "兑换所需积分")
private Integer pointsRequire; private Integer pointsRequire;
@ApiModelProperty(value = "兑换所需积分查询条件(1大于,2等于,3小于)")
private Integer pointsRequireSymbol;
@ApiModelProperty(value = "兑换网点") @ApiModelProperty(value = "兑换网点")
private Integer nodeId; private Integer nodeId;
@ApiModelProperty(value = "已兑换次数")
private Integer exchangeCount;
@ApiModelProperty(value = "剩余数量") @ApiModelProperty(value = "剩余数量")
private Integer quantityRemain; private Integer quantityRemain;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) @ApiModelProperty(value = "剩余数量查询条件(1大于,2等于,3小于)")
@ApiModelProperty(value = "开始活动开始时间") private Integer quantityRemainSymbol;
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 = "领取方式(1上门领取,2包邮到家,3邮寄到付)") @ApiModelProperty(value = "领取方式(1上门领取,2包邮到家,3邮寄到付)")
private Integer pickMethod; private Integer pickMethod;
@ApiModelProperty(value = "允许兑换次数")
private Integer allowCount;
@ApiModelProperty(value = "礼品状态(1已启用,2未启用,3已关闭,4已过期)") @ApiModelProperty(value = "礼品状态(1已启用,2未启用,3已关闭,4已过期)")
private Integer status; private Integer status;
......
import cn.hutool.core.lang.UUID;
public class GenRewardCodeTest { public class GenRewardCodeTest {
public static void main(String[] args) {
String format = String.format("%012d", 2);
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
System.out.println(format);
System.out.println(uuid);
}
} }
...@@ -25,7 +25,7 @@ import cn.iocoder.yudao.module.reward.service.reward.RewardService; ...@@ -25,7 +25,7 @@ import cn.iocoder.yudao.module.reward.service.reward.RewardService;
@Validated @Validated
@RestController @RestController
@Api(tags = "管理后台 - 礼品") @Api(tags = "管理后台 - 礼品")
@RequestMapping("/reward/") @RequestMapping("/ecw/reward/")
public class RewardController { public class RewardController {
@Resource @Resource
...@@ -56,7 +56,7 @@ public class RewardController { ...@@ -56,7 +56,7 @@ public class RewardController {
} }
@GetMapping("/get") @GetMapping("/get")
@ApiOperation("获得礼品") @ApiOperation("获得礼品详情")
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
@PreAuthorize("@ss.hasPermission('reward::query')") @PreAuthorize("@ss.hasPermission('reward::query')")
public CommonResult<RewardBackVO> get(@RequestParam("id") Long id) { public CommonResult<RewardBackVO> get(@RequestParam("id") Long id) {
......
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