Commit 0ccd65ec authored by zhangfeng's avatar zhangfeng

后台获取礼品列表增加会员id筛选

parent 2d693130
......@@ -212,6 +212,11 @@ public class RewardServiceImpl extends AbstractService<RewardMapper, RewardDO> i
lambdaQuery.eqIfPresent(RewardDO::getNodeId, query.getNodeId())
.eq(StringUtils.isNotBlank(query.getPickMethod()), RewardDO::getPickMethod, query.getPickMethod())
.eqIfPresent(RewardDO::getStatus, query.getStatus());
//判断memberId,筛选会员所在城市网点礼品
if (query.getMemberId() != null && query.getNodeId() == null) {
List<Long> nodes = getMemberCityNodes(query.getMemberId());
lambdaQuery.in(CollectionUtil.isNotEmpty(nodes), RewardDO::getNodeId, nodes);
}
//备注,模糊匹配三种语言
if (StringUtils.isNotBlank(query.getRemark())) {
lambdaQuery.and(wrapper ->
......@@ -326,16 +331,9 @@ public class RewardServiceImpl extends AbstractService<RewardMapper, RewardDO> i
if (reqVO.getNodeId() != null) {
rewardDOLambdaQuery.eq(RewardDO::getNodeId, reqVO.getNodeId());
} else {
UserRespDTO user = memberUserApi.getUser(reqVO.getMemberId());
List<NodeRespDTO> nodes = null;
// 如果用户没有填写国家或城市默认展示中国的礼品
if (user.getCity() == null || user.getCountry() == null) {
nodes = nodeApi.getNodesByCity(null, 130L);
} else {
nodes = nodeApi.getNodesByCity(user.getCity().longValue(), null);
}
List<Long> nodes = getMemberCityNodes(reqVO.getMemberId());
if (CollectionUtil.isNotEmpty(nodes)) {
rewardDOLambdaQuery.in(RewardDO::getNodeId, nodes.stream().map(NodeRespDTO::getId).collect(Collectors.toList()));
rewardDOLambdaQuery.in(RewardDO::getNodeId, nodes);
}
}
List<RewardDO> rewardDOS = rewardMapper.selectList(rewardDOLambdaQuery);
......@@ -344,7 +342,7 @@ public class RewardServiceImpl extends AbstractService<RewardMapper, RewardDO> i
collect.forEach(this::setPickMethod);
return collect;
}
return Collections.EMPTY_LIST;
return Collections.emptyList();
}
@Override
......@@ -354,14 +352,14 @@ public class RewardServiceImpl extends AbstractService<RewardMapper, RewardDO> i
BeanUtils.copyProperties(rewardDO, appRewardBackVO);
setPickMethod(appRewardBackVO);
NodeRespDTO nodesById = nodeApi.getNodesById(Long.valueOf(rewardDO.getNodeId()));
if (nodesById != null){
if (nodesById != null) {
appRewardBackVO.setNodeZh(nodesById.getTitleZh());
appRewardBackVO.setNodeEn(nodesById.getTitleEn());
}
return appRewardBackVO;
}
private void setPickMethod(AppRewardBackVO appRewardBackVO){
private void setPickMethod(AppRewardBackVO appRewardBackVO) {
for (String pickMethod : appRewardBackVO.getPickMethod().split(",")) {
AppRewardBackVO.PickMethod pickMethodDict = new AppRewardBackVO.PickMethod();
pickMethodDict.setValue(pickMethod);
......@@ -381,6 +379,7 @@ public class RewardServiceImpl extends AbstractService<RewardMapper, RewardDO> i
/**
* 校验礼品是否过期并修改礼品状态
*/
@Override
public Boolean validateExpire(RewardDO rewardDO) {
if (rewardDO.getEndTime() != null) {
if (rewardDO.getStatus() == RewardStatusEnum.ENABLED.getValue() && rewardDO.getEndTime().toInstant().isBefore(Instant.now())) {
......@@ -394,4 +393,22 @@ public class RewardServiceImpl extends AbstractService<RewardMapper, RewardDO> i
}
return false;
}
/**
* 获取会员所在城市网点id
*/
private List<Long> getMemberCityNodes(Long memberId) {
UserRespDTO user = memberUserApi.getUser(memberId);
List<NodeRespDTO> nodes;
// 如果用户没有填写国家或城市默认展示中国的礼品
if (user.getCity() == null || user.getCountry() == null) {
nodes = nodeApi.getNodesByCity(null, 130L);
} else {
nodes = nodeApi.getNodesByCity(user.getCity().longValue(), null);
}
if (CollectionUtil.isNotEmpty(nodes)) {
return nodes.stream().map(NodeRespDTO::getId).collect(Collectors.toList());
}
return Collections.emptyList();
}
}
......@@ -51,4 +51,7 @@ public class RewardQueryVO {
@ApiModelProperty(value = "结束创建时间")
private Date endCreateTime;
@ApiModelProperty(value = "会员id")
private Long memberId;
}
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