Commit 0e312220 authored by zhangfeng's avatar zhangfeng

Merge branch 'refs/heads/feature_member_score' into dev

parents 81f17f72 134fb1dc
......@@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.reward.controller.app.reward;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.ecw.api.node.NodeApi;
import cn.iocoder.yudao.module.reward.controller.app.reward.vo.AppRewardBackVO;
import cn.iocoder.yudao.module.reward.controller.app.reward.vo.AppRewardListBackVO;
import cn.iocoder.yudao.module.reward.controller.app.reward.vo.AppRewardListReqVO;
import cn.iocoder.yudao.module.reward.service.reward.RewardService;
import io.swagger.annotations.Api;
......@@ -36,8 +37,8 @@ public class AppRewardController {
@PostMapping("/list")
@ApiOperation("会员获得礼品列表")
public CommonResult<List<AppRewardBackVO>> getListByMemberInfo(@RequestBody AppRewardListReqVO reqVO) {
List<AppRewardBackVO> list = rewardService.getListByMemberInfo(reqVO);
return success(list);
public CommonResult<AppRewardListBackVO> getListByMemberInfo(@RequestBody AppRewardListReqVO reqVO) {
AppRewardListBackVO listVO = rewardService.getListByMemberInfo(reqVO);
return success(listVO);
}
}
package cn.iocoder.yudao.module.reward.controller.app.reward.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
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 AppRewardListBackVO {
@ApiModelProperty(value = "国家id,为了区分根据什么条件查得礼品")
private Long country;
@ApiModelProperty(value = "城市id,为了区分根据什么条件查得礼品")
private Long city;
@ApiModelProperty(value = "礼品列表")
private List<AppRewardBackVO> list;
}
......@@ -4,6 +4,7 @@ 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.reward.controller.app.reward.vo.AppRewardBackVO;
import cn.iocoder.yudao.module.reward.controller.app.reward.vo.AppRewardListBackVO;
import cn.iocoder.yudao.module.reward.controller.app.reward.vo.AppRewardListReqVO;
import cn.iocoder.yudao.module.reward.dal.dataobject.reward.RewardDO;
import cn.iocoder.yudao.module.reward.vo.reward.*;
......@@ -84,7 +85,7 @@ public interface RewardService extends IService<RewardDO> {
* @param reqVO
* @return
*/
List<AppRewardBackVO> getListByMemberInfo(AppRewardListReqVO reqVO);
AppRewardListBackVO getListByMemberInfo(AppRewardListReqVO reqVO);
AppRewardBackVO getRewardDetailForUser(Long id);
}
......@@ -12,6 +12,7 @@ import cn.iocoder.yudao.module.ecw.api.node.dto.NodeRespDTO;
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
import cn.iocoder.yudao.module.member.api.user.dto.UserRespDTO;
import cn.iocoder.yudao.module.reward.controller.app.reward.vo.AppRewardBackVO;
import cn.iocoder.yudao.module.reward.controller.app.reward.vo.AppRewardListBackVO;
import cn.iocoder.yudao.module.reward.controller.app.reward.vo.AppRewardListReqVO;
import cn.iocoder.yudao.module.reward.convert.reward.RewardConvert;
import cn.iocoder.yudao.module.reward.dal.dataobject.reward.RewardDO;
......@@ -269,6 +270,8 @@ public class RewardServiceImpl extends AbstractService<RewardMapper, RewardDO> i
reward.setCode(generateRewardCode());
//设置为未启用
reward.setStatus(RewardStatusEnum.DISABLED.getValue());
//已兑换次数清零
reward.setExchangeCount(0);
reward.setId(null);
reward.setCreateTime(null);
......@@ -333,7 +336,8 @@ public class RewardServiceImpl extends AbstractService<RewardMapper, RewardDO> i
}
@Override
public List<AppRewardBackVO> getListByMemberInfo(AppRewardListReqVO reqVO) {
public AppRewardListBackVO getListByMemberInfo(AppRewardListReqVO reqVO) {
AppRewardListBackVO appRewardListBackVO = new AppRewardListBackVO();
LambdaQuery<RewardDO> rewardDOLambdaQuery = new LambdaQuery<>();
rewardDOLambdaQuery.eq(RewardDO::getStatus, RewardStatusEnum.ENABLED.getValue())
.gt(RewardDO::getQuantityRemain, 0)
......@@ -343,18 +347,36 @@ public class RewardServiceImpl extends AbstractService<RewardMapper, RewardDO> i
if (reqVO.getNodeId() != null) {
rewardDOLambdaQuery.eq(RewardDO::getNodeId, reqVO.getNodeId());
} else {
List<Long> nodes = getMemberCityNodes(reqVO.getMemberId());
if (CollectionUtil.isNotEmpty(nodes)) {
rewardDOLambdaQuery.in(RewardDO::getNodeId, nodes);
UserRespDTO user = memberUserApi.getUser(reqVO.getMemberId());
List<NodeRespDTO> nodes;
// 根据用户城市获取
nodes = nodeApi.getNodesByCity(user.getCity().longValue(), null);
appRewardListBackVO.setCity(user.getCity().longValue());
appRewardListBackVO.setCountry(user.getCountry().longValue());
if (CollectionUtil.isEmpty(nodes)) {
// 根据用户国家获取
nodes = nodeApi.getNodesByCity(null, user.getCountry().longValue());
appRewardListBackVO.setCity(null);
}
// 国家和城市都获取不到
if (CollectionUtil.isEmpty(nodes)) {
nodes = nodeApi.getNodesByCity(null, 130L);
appRewardListBackVO.setCountry(130L);
}
List<Long> nodeIds = nodes.stream().map(NodeRespDTO::getId).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(nodeIds)) {
rewardDOLambdaQuery.in(RewardDO::getNodeId, nodeIds);
}
}
List<RewardDO> rewardDOS = rewardMapper.selectList(rewardDOLambdaQuery);
if (rewardDOS != null && !rewardDOS.isEmpty()) {
List<AppRewardBackVO> collect = rewardDOS.stream().map(RewardConvert.INSTANCE::convertAppVO).collect(Collectors.toList());
collect.forEach(this::setPickMethod);
return collect;
appRewardListBackVO.setList(collect);
return appRewardListBackVO;
}
return Collections.emptyList();
appRewardListBackVO.setList(Collections.emptyList());
return appRewardListBackVO;
}
@Override
......@@ -420,11 +442,14 @@ public class RewardServiceImpl extends AbstractService<RewardMapper, RewardDO> i
if (user.getCity() == null || user.getCountry() == null) {
nodes = nodeApi.getNodesByCity(null, 130L);
} else {
// 根据用户城市获取
nodes = nodeApi.getNodesByCity(user.getCity().longValue(), null);
if (CollectionUtil.isEmpty(nodes)) {
// 根据用户国家获取
nodes = nodeApi.getNodesByCity(null, user.getCountry().longValue());
}
}
// 国家和城市都获取不到
if (CollectionUtil.isEmpty(nodes)) {
nodes = nodeApi.getNodesByCity(null, 130L);
}
......
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