Commit 1a4865c1 authored by zhangfeng's avatar zhangfeng

Merge branch 'refs/heads/feature_member_score' into dev

parents 8783a621 3d4559a6
...@@ -23,4 +23,8 @@ public class AppMemberUserScoreInfoRespVO { ...@@ -23,4 +23,8 @@ public class AppMemberUserScoreInfoRespVO {
private Integer totalScore; private Integer totalScore;
@ApiModelProperty(value = "会员等级名称") @ApiModelProperty(value = "会员等级名称")
private String levelName; private String levelName;
@ApiModelProperty(value = "积分范围 下界")
private Integer lowerCount;
@ApiModelProperty(value = "积分范围 上界")
private Integer upperCount;
} }
...@@ -125,6 +125,8 @@ public class MemberUserScoreServiceImpl extends AbstractService<MemberUserScoreM ...@@ -125,6 +125,8 @@ public class MemberUserScoreServiceImpl extends AbstractService<MemberUserScoreM
MemberUserLevelConfigBaseRespVO level = memberUserLevelConfigService.getLevelByCount(userScoreTotal); MemberUserLevelConfigBaseRespVO level = memberUserLevelConfigService.getLevelByCount(userScoreTotal);
if (level != null) { if (level != null) {
infoRespVO.setLevelName(level.getName()); infoRespVO.setLevelName(level.getName());
infoRespVO.setLowerCount(level.getLowerCount());
infoRespVO.setUpperCount(level.getUpperCount());
} }
return infoRespVO; return infoRespVO;
} }
......
...@@ -28,5 +28,6 @@ public interface ErrorCodeConstants { ...@@ -28,5 +28,6 @@ public interface ErrorCodeConstants {
ErrorCode REWARD_REDEEM_VERIFY_BACK_STATUS = new ErrorCode(1001011022, "reward.redeem.verify.back.status"); ErrorCode REWARD_REDEEM_VERIFY_BACK_STATUS = new ErrorCode(1001011022, "reward.redeem.verify.back.status");
ErrorCode REDEEM_IMPORT_MAX_COUNT = new ErrorCode(1001011023, "redeem.import.max.count"); ErrorCode REDEEM_IMPORT_MAX_COUNT = new ErrorCode(1001011023, "redeem.import.max.count");
ErrorCode REDEEM_CANCEL_STATUS_ERROR = new ErrorCode(1001011024, "redeem.cancel.status.error"); ErrorCode REDEEM_CANCEL_STATUS_ERROR = new ErrorCode(1001011024, "redeem.cancel.status.error");
ErrorCode REWARD_NODE_AND_POINTS_LIST_ERROR = new ErrorCode(1001011025, "reward.node.and.points.list.error");
} }
...@@ -41,7 +41,7 @@ public class RewardController { ...@@ -41,7 +41,7 @@ public class RewardController {
@ApiOperation("创建礼品") @ApiOperation("创建礼品")
@Idempotent(timeout = 3) @Idempotent(timeout = 3)
@PreAuthorize("@ss.hasPermission('ecw:giftManagement:add')") @PreAuthorize("@ss.hasPermission('ecw:giftManagement:add')")
public CommonResult<Long> create(@Valid @RequestBody RewardCreateReqVO createReqVO) { public CommonResult<List<Long>> create(@Valid @RequestBody RewardCreateReqVO createReqVO) {
return success(rewardService.create(createReqVO)); return success(rewardService.create(createReqVO));
} }
......
...@@ -63,7 +63,7 @@ public class RewardDO extends BaseDO { ...@@ -63,7 +63,7 @@ public class RewardDO extends BaseDO {
/** /**
* 兑换网点 * 兑换网点
*/ */
private String nodeId; private Integer nodeId;
/** /**
* 已兑换次数 * 已兑换次数
*/ */
......
...@@ -24,7 +24,7 @@ public interface RewardService extends IService<RewardDO> { ...@@ -24,7 +24,7 @@ public interface RewardService extends IService<RewardDO> {
* @param createReqVO 创建信息 * @param createReqVO 创建信息
* @return 编号 * @return 编号
*/ */
Long create(@Valid RewardCreateReqVO createReqVO); List<Long> create(@Valid RewardCreateReqVO createReqVO);
/** /**
* 更新礼品 * 更新礼品
......
...@@ -47,7 +47,34 @@ public class RewardServiceImpl extends AbstractService<RewardMapper, RewardDO> i ...@@ -47,7 +47,34 @@ public class RewardServiceImpl extends AbstractService<RewardMapper, RewardDO> i
private MemberUserApi memberUserApi; private MemberUserApi memberUserApi;
@Override @Override
public Long create(RewardCreateReqVO createReqVO) { public List<Long> create(RewardCreateReqVO createReqVO) {
verifyCreateVO(createReqVO);
// 插入
RewardDO rewardDO = RewardConvert.INSTANCE.convert(createReqVO);
// 剩余数量若没传给默认值0
if (rewardDO.getQuantityRemain() == null) {
rewardDO.setQuantityRemain(0);
}
ArrayList<Long> ids = new ArrayList<>();
for (RewardCreateReqVO.NodeAndPoints nodeId : createReqVO.getNodeIds()) {
rewardDO.setNodeId(nodeId.getNodeId());
rewardDO.setPointsRequire(nodeId.getPoints());
rewardDO.setCode(generateRewardCode());
//如果插入失败,重新生成code再次插入
try {
rewardMapper.insert(rewardDO);
} catch (Exception e) {
rewardDO.setCode(generateRewardCode());
rewardMapper.insert(rewardDO);
}
ids.add(rewardDO.getId());
rewardDO.setId(null);
}
// 返回
return ids;
}
private void verifyCreateVO(RewardCreateReqVO createReqVO) {
//活动开始时间不能比活动结束时间晚,活动结束时间不能比当前时间早 //活动开始时间不能比活动结束时间晚,活动结束时间不能比当前时间早
if (ObjectUtils.allNotNull(createReqVO.getStartTime(), createReqVO.getEndTime())) { if (ObjectUtils.allNotNull(createReqVO.getStartTime(), createReqVO.getEndTime())) {
if (createReqVO.getStartTime().after((createReqVO.getEndTime())) || createReqVO.getEndTime().before(Date.from(Instant.now()))) { if (createReqVO.getStartTime().after((createReqVO.getEndTime())) || createReqVO.getEndTime().before(Date.from(Instant.now()))) {
...@@ -61,22 +88,20 @@ public class RewardServiceImpl extends AbstractService<RewardMapper, RewardDO> i ...@@ -61,22 +88,20 @@ public class RewardServiceImpl extends AbstractService<RewardMapper, RewardDO> i
if (createReqVO.getStatus() != RewardStatusEnum.ENABLED.getValue() && createReqVO.getStatus() != RewardStatusEnum.DISABLED.getValue()) { if (createReqVO.getStatus() != RewardStatusEnum.ENABLED.getValue() && createReqVO.getStatus() != RewardStatusEnum.DISABLED.getValue()) {
throw exception(REWARD_STATUS_NOT_ALLOW_CREATE); throw exception(REWARD_STATUS_NOT_ALLOW_CREATE);
} }
// 插入 // 校验节点和所需积分
RewardDO rewardDO = RewardConvert.INSTANCE.convert(createReqVO); List<RewardCreateReqVO.NodeAndPoints> nodeIds = createReqVO.getNodeIds();
rewardDO.setCode(generateRewardCode()); if (CollectionUtil.isEmpty(nodeIds)) {
// 剩余数量若没传给默认值0 throw exception(REWARD_NODE_AND_POINTS_LIST_ERROR);
if (rewardDO.getQuantityRemain() == null) { } else {
rewardDO.setQuantityRemain(0); for (RewardCreateReqVO.NodeAndPoints nodeId : nodeIds) {
if (nodeId.getPoints() == null || nodeId.getNodeId() == null) {
throw exception(REWARD_NODE_AND_POINTS_LIST_ERROR);
}
if (nodeId.getPoints() <= 0 || nodeId.getNodeId() <= 0) {
throw exception(REWARD_NODE_AND_POINTS_LIST_ERROR);
}
} }
//如果插入失败,重新生成code再次插入
try {
rewardMapper.insert(rewardDO);
} catch (Exception e) {
rewardDO.setCode(generateRewardCode());
rewardMapper.insert(rewardDO);
} }
// 返回
return rewardDO.getId();
} }
@Override @Override
...@@ -170,8 +195,9 @@ public class RewardServiceImpl extends AbstractService<RewardMapper, RewardDO> i ...@@ -170,8 +195,9 @@ public class RewardServiceImpl extends AbstractService<RewardMapper, RewardDO> i
.eq(query.getPointsRequireSymbol() == QuantitativeRelationSymbolEnum.EQ.getValue(), RewardDO::getPointsRequire, query.getPointsRequire()) .eq(query.getPointsRequireSymbol() == QuantitativeRelationSymbolEnum.EQ.getValue(), RewardDO::getPointsRequire, query.getPointsRequire())
.lt(query.getPointsRequireSymbol() == QuantitativeRelationSymbolEnum.LT.getValue(), RewardDO::getPointsRequire, query.getPointsRequire()); .lt(query.getPointsRequireSymbol() == QuantitativeRelationSymbolEnum.LT.getValue(), RewardDO::getPointsRequire, query.getPointsRequire());
} }
//领取方式,状态 //兑换网点id,领取方式,状态
lambdaQuery.eqIfPresent(RewardDO::getPickMethod, query.getPickMethod()) lambdaQuery.eqIfPresent(RewardDO::getNodeId, query.getNodeId())
.eqIfPresent(RewardDO::getPickMethod, query.getPickMethod())
.eqIfPresent(RewardDO::getStatus, query.getStatus()); .eqIfPresent(RewardDO::getStatus, query.getStatus());
//备注,模糊匹配三种语言 //备注,模糊匹配三种语言
if (query.getRemark() != null) { if (query.getRemark() != null) {
...@@ -195,10 +221,6 @@ public class RewardServiceImpl extends AbstractService<RewardMapper, RewardDO> i ...@@ -195,10 +221,6 @@ public class RewardServiceImpl extends AbstractService<RewardMapper, RewardDO> i
PageResult<RewardDO> rewardDOPageResult = rewardMapper.selectPage(page, lambdaQuery); PageResult<RewardDO> rewardDOPageResult = rewardMapper.selectPage(page, lambdaQuery);
//校验是否过期 //校验是否过期
rewardDOPageResult.getList().forEach(this::validateExpire); rewardDOPageResult.getList().forEach(this::validateExpire);
// 过滤兑换网点
if (query.getNodeId() != null) {
rewardDOPageResult.getList().removeIf(rewardDO -> !Arrays.asList(rewardDO.getNodeId().split(",")).contains(query.getNodeId().toString()));
}
return rewardDOPageResult; return rewardDOPageResult;
} }
...@@ -295,9 +317,9 @@ public class RewardServiceImpl extends AbstractService<RewardMapper, RewardDO> i ...@@ -295,9 +317,9 @@ public class RewardServiceImpl extends AbstractService<RewardMapper, RewardDO> i
List<NodeRespDTO> nodes = null; List<NodeRespDTO> nodes = null;
// 如果用户没有填写国家或城市默认展示中国的礼品 // 如果用户没有填写国家或城市默认展示中国的礼品
if (user.getCity() == null || user.getCountry() == null) { if (user.getCity() == null || user.getCountry() == null) {
nodes = nodeApi.getNodesByCity(null, 130L); nodes = nodeApi.getNodesByCity(null,130L);
} else { } else {
nodes = nodeApi.getNodesByCity(user.getCity().longValue(), null); nodes = nodeApi.getNodesByCity(user.getCity().longValue(),null);
} }
if (CollectionUtil.isNotEmpty(nodes)) { if (CollectionUtil.isNotEmpty(nodes)) {
rewardDOLambdaQuery.in(RewardDO::getNodeId, nodes.stream().map(NodeRespDTO::getId).collect(Collectors.toList())); rewardDOLambdaQuery.in(RewardDO::getNodeId, nodes.stream().map(NodeRespDTO::getId).collect(Collectors.toList()));
......
...@@ -58,7 +58,7 @@ public class RewardBackVO { ...@@ -58,7 +58,7 @@ public class RewardBackVO {
@ExcelProperty("兑换网点") @ExcelProperty("兑换网点")
@ApiModelProperty(value = "兑换网点", required = true) @ApiModelProperty(value = "兑换网点", required = true)
private String nodeId; private Integer nodeId;
@ExcelProperty("已兑换次数") @ExcelProperty("已兑换次数")
@ApiModelProperty(value = "已兑换次数") @ApiModelProperty(value = "已兑换次数")
......
...@@ -40,14 +40,18 @@ public class RewardCreateReqVO { ...@@ -40,14 +40,18 @@ public class RewardCreateReqVO {
@ApiModelProperty(value = "法文礼品图片") @ApiModelProperty(value = "法文礼品图片")
private String imgFr; private String imgFr;
@ApiModelProperty(value = "兑换所需积分", required = true) //@ApiModelProperty(value = "兑换所需积分", required = true)
@NotNull(message = "兑换所需积分不能为空") //@NotNull(message = "兑换所需积分不能为空")
@Min(value = 0) //@Min(value = 0)
private Integer pointsRequire; //private Integer pointsRequire;
//@ApiModelProperty(value = "兑换网点", required = true)
//@NotNull(message = "兑换网点不能为空")
//private Integer nodeId;
@ApiModelProperty(value = "兑换网点", required = true) @ApiModelProperty(value = "兑换网点和积分列表", required = true)
@NotNull(message = "兑换网点不能为空") @NotNull(message = "兑换网点列表不能为空")
private String nodeId; private List<NodeAndPoints> nodeIds;
@ApiModelProperty(value = "剩余数量", required = true) @ApiModelProperty(value = "剩余数量", required = true)
@NotNull(message = "剩余数量不能为空") @NotNull(message = "剩余数量不能为空")
...@@ -86,4 +90,12 @@ public class RewardCreateReqVO { ...@@ -86,4 +90,12 @@ public class RewardCreateReqVO {
@ApiModelProperty(value = "礼品状态(1已启用,2未启用,3已关闭,4已过期)", required = true) @ApiModelProperty(value = "礼品状态(1已启用,2未启用,3已关闭,4已过期)", required = true)
@NotNull(message = "礼品状态不能为空") @NotNull(message = "礼品状态不能为空")
private Integer status; private Integer status;
@Data
public static class NodeAndPoints {
@ApiModelProperty(value = "兑换网点")
private Integer nodeId;
@ApiModelProperty(value = "兑换网点对应积分")
private Integer points;
}
} }
...@@ -48,7 +48,7 @@ public class RewardUpdateReqVO { ...@@ -48,7 +48,7 @@ public class RewardUpdateReqVO {
private Integer pointsRequire; private Integer pointsRequire;
@ApiModelProperty(value = "兑换网点") @ApiModelProperty(value = "兑换网点")
private String nodeId; private Integer nodeId;
@ApiModelProperty(value = "剩余数量") @ApiModelProperty(value = "剩余数量")
@Min(value = 0) @Min(value = 0)
......
...@@ -1026,6 +1026,7 @@ reward.score.not.enough = user score not enough:{} ...@@ -1026,6 +1026,7 @@ reward.score.not.enough = user score not enough:{}
reward.count.not.enough = reward count not enough reward.count.not.enough = reward count not enough
reward.redeem.count.not.allow = bulk redemption is limited to a maximum of 10 pieces at a time reward.redeem.count.not.allow = bulk redemption is limited to a maximum of 10 pieces at a time
reward.redeem.allow.count.error = the number of redemptions allowed by the individual has been exceeded:{} reward.redeem.allow.count.error = the number of redemptions allowed by the individual has been exceeded:{}
reward.node.and.points.list.error = reward node and points create error
redeem.import.max.count = allow maximum number of imports is {} redeem.import.max.count = allow maximum number of imports is {}
dict.unknown.error = Not in dict {0}: {1} dict.unknown.error = Not in dict {0}: {1}
......
...@@ -1022,6 +1022,7 @@ reward.score.not.enough = \u79EF\u5206\u4E0D\u8DB3\uFF1A{} ...@@ -1022,6 +1022,7 @@ reward.score.not.enough = \u79EF\u5206\u4E0D\u8DB3\uFF1A{}
reward.count.not.enough = \u793C\u54C1\u6570\u91CF\u4E0D\u8DB3 reward.count.not.enough = \u793C\u54C1\u6570\u91CF\u4E0D\u8DB3
reward.redeem.count.not.allow = \u6279\u91CF\u5151\u6362\u6BCF\u6B21\u6700\u591A\u5341\u6761 reward.redeem.count.not.allow = \u6279\u91CF\u5151\u6362\u6BCF\u6B21\u6700\u591A\u5341\u6761
reward.redeem.allow.count.error = \u5DF2\u8D85\u51FA\u4E2A\u4EBA\u5141\u8BB8\u5151\u6362\u6B21\u6570\uFF1A{} reward.redeem.allow.count.error = \u5DF2\u8D85\u51FA\u4E2A\u4EBA\u5141\u8BB8\u5151\u6362\u6B21\u6570\uFF1A{}
reward.node.and.points.list.error = \u521B\u5EFA\u793C\u54C1\u7F51\u70B9\u6216\u6240\u9700\u79EF\u5206\u9519\u8BEF
get.lock.failed = \u670D\u52A1\u7E41\u5FD9\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5 get.lock.failed = \u670D\u52A1\u7E41\u5FD9\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5
reward.redeem.not.exist = \u793C\u54C1\u5151\u6362\u8BB0\u5F55\u4E0D\u5B58\u5728 reward.redeem.not.exist = \u793C\u54C1\u5151\u6362\u8BB0\u5F55\u4E0D\u5B58\u5728
......
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