Commit 24f94d5f authored by zhangfeng's avatar zhangfeng

Merge branch 'refs/heads/feature_member_score' into dev

parents adba3fe8 930bb1a7
......@@ -56,4 +56,7 @@ public interface ErrorCodeConstants {
ErrorCode SCORE_RULE_DELETE_ERROR = new ErrorCode(1004008011, "score.rule.delete.error");
ErrorCode SCORE_RULE_UPDATE_ERROR = new ErrorCode(1004008012, "score.rule.update.error");
ErrorCode SCORE_RULE_FIELD_ERROR = new ErrorCode(1004008013, "score.rule.field.error");
ErrorCode USER_ADDRESS_NOT_EXISTS = new ErrorCode(1004008014, "user.address.not.exists");
ErrorCode USER_ADDRESS_FIELD_ERROR = new ErrorCode(1004008015, "user.address.field.error");
}
package cn.iocoder.yudao.module.member.controller.app.address;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.member.convert.address.UserAddressConvert;
import cn.iocoder.yudao.module.member.dal.dataobject.address.UserAddressDO;
import cn.iocoder.yudao.module.member.service.address.UserAddressService;
import cn.iocoder.yudao.module.member.vo.address.UserAddressBackVO;
import cn.iocoder.yudao.module.member.vo.address.UserAddressCreateReqVO;
import cn.iocoder.yudao.module.member.vo.address.UserAddressUpdateReqVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
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 = "用户 APP - 会员收货地址")
@RequestMapping("/member/user-address")
public class UserAddressController {
@Resource
private UserAddressService userAddressService;
@PostMapping("/create")
@ApiOperation("创建会员收货地址")
//@PreAuthenticated
public CommonResult<Long> createUserAddress(@Valid @RequestBody UserAddressCreateReqVO createReqVO) {
return success(userAddressService.createUserAddress(createReqVO));
}
@PostMapping("/update")
@ApiOperation("更新会员收货地址")
//@PreAuthenticated
public CommonResult<Boolean> updateUserAddress(@Valid @RequestBody UserAddressUpdateReqVO updateReqVO) {
userAddressService.updateUserAddress(updateReqVO);
return success(true);
}
@PostMapping("/delete")
@ApiOperation("删除会员收货地址")
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
//@PreAuthenticated
public CommonResult<Boolean> deleteUserAddress(@RequestParam("id") Long id) {
userAddressService.deleteUserAddress(id);
return success(true);
}
@GetMapping("/get")
@ApiOperation("根据id获得会员收货地址")
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
//@PreAuthenticated
public CommonResult<UserAddressBackVO> getUserAddress(@RequestParam("id") Long id) {
UserAddressDO userAddress = userAddressService.getUserAddress(id);
return success(UserAddressConvert.INSTANCE.convert(userAddress));
}
@GetMapping("/member/list")
@ApiOperation("获得会员收货地址列表")
@ApiImplicitParam(name = "id", value = "会员id", required = true, example = "1024", dataTypeClass = Long.class)
//@PreAuthenticated
public CommonResult<List<UserAddressBackVO>> getUserAddressList(@RequestParam("id") Long memberId) {
List<UserAddressDO> list = userAddressService.getUserAddressListByMemberId(memberId);
return success(UserAddressConvert.INSTANCE.convertList(list));
}
//@GetMapping("/list")
//@ApiOperation("获得会员收货地址列表")
//@ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
////@PreAuthenticated
//public CommonResult<List<UserAddressBackVO>> getUserAddressList(@RequestParam("ids") Collection<Long> ids) {
// List<UserAddressDO> list = userAddressService.getUserAddressList(ids);
// return success(UserAddressConvert.INSTANCE.convertList(list));
//}
//@GetMapping("/page")
//@ApiOperation("获得会员收货地址分页")
//@PreAuthenticated
//public CommonResult<PageResult<UserAddressBackVO>> getUserAddressPage(@Valid UserAddressQueryVO query, PageVO page) {
// PageResult<UserAddressDO> pageResult = userAddressService.getUserAddressPage(query, page);
// return success(UserAddressConvert.INSTANCE.convertPage(pageResult));
//}
//@GetMapping("/export-excel")
//@ApiOperation("导出会员收货地址 Excel")
//@PreAuthenticated
//@OperateLog(type = EXPORT)
//public void exportUserAddressExcel(@Valid UserAddressQueryVO query,
// HttpServletResponse response) throws IOException {
// List<UserAddressDO> list = userAddressService.getUserAddressList(query);
// // 导出 Excel
// List<UserAddressBackVO> datas = UserAddressConvert.INSTANCE.convertList(list);
// ExcelUtils.write(response, "会员收货地址.xls", "数据", UserAddressBackVO.class, datas);
//}
}
package cn.iocoder.yudao.module.member.convert.address;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.member.dal.dataobject.address.UserAddressDO;
import cn.iocoder.yudao.module.member.vo.address.UserAddressBackVO;
import cn.iocoder.yudao.module.member.vo.address.UserAddressCreateReqVO;
import cn.iocoder.yudao.module.member.vo.address.UserAddressUpdateReqVO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
* 会员收货地址 Convert
* @author 系统管理员
*/
@Mapper
public interface UserAddressConvert {
/*****转换MapStruct*****/
UserAddressConvert INSTANCE = Mappers.getMapper(UserAddressConvert.class);
/***
* 创建VO转实体
* @param bean
* @return
*/
UserAddressDO convert(UserAddressCreateReqVO bean);
/***
* 修改VO转实体
* @param bean
* @return
*/
UserAddressDO convert(UserAddressUpdateReqVO bean);
/***
* 实体转返回VO
* @param bean
* @return
*/
UserAddressBackVO convert(UserAddressDO bean);
/***
* 实体列表转返回VO列表
* @param list
* @return
*/
List<UserAddressBackVO> convertList(List<UserAddressDO> list);
/***
* 实体分页转返回分页
* @param page
* @return
*/
PageResult<UserAddressBackVO> convertPage(PageResult<UserAddressDO> page);
}
package cn.iocoder.yudao.module.member.dal.dataobject.address;
import lombok.*;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/**
* 会员收货地址 DO
*
* @author 系统管理员
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName("member_user_address")
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class UserAddressDO extends BaseDO {
/**
* 主键
*/
@TableId
private Long id;
/**
* 会员id
*/
private Long memberId;
/**
* 是否默认地址
*/
private Integer isDefault;
/**
* 收货人姓名
*/
private String name;
/**
* 区号
*/
private String areaCode;
/**
* 收货人手机
*/
private String phone;
/**
* 详细地址
*/
private String address;
}
package cn.iocoder.yudao.module.member.dal.mysql.address;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.AbstractMapper;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQuery;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import cn.iocoder.yudao.module.member.dal.dataobject.address.UserAddressDO;
import cn.iocoder.yudao.module.member.vo.address.UserAddressQueryVO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 会员收货地址 Mapper
* @author 系统管理员
*/
@Mapper
public interface UserAddressMapper extends AbstractMapper<UserAddressDO> {
@Override
default PageResult<UserAddressDO> selectPage(PageVO page, Object object) {
if (object instanceof UserAddressQueryVO) {
UserAddressQueryVO vo = (UserAddressQueryVO)object;
return selectPage(page, new LambdaQuery<UserAddressDO>()
.eqIfPresent(UserAddressDO::getMemberId, vo.getMemberId())
.eqIfPresent(UserAddressDO::getIsDefault, vo.getIsDefault())
.likeIfPresent(UserAddressDO::getName, vo.getName())
.eqIfPresent(UserAddressDO::getAreaCode, vo.getAreaCode())
.eqIfPresent(UserAddressDO::getPhone, vo.getPhone())
.eqIfPresent(UserAddressDO::getAddress, vo.getAddress())
.betweenIfPresent(UserAddressDO::getCreateTime, vo.getBeginCreateTime(), vo.getEndCreateTime())
.orderByDesc(UserAddressDO::getId));
}
return null;
}
@Override
default List<UserAddressDO> selectList(Object object) {
if (object instanceof UserAddressQueryVO) {
UserAddressQueryVO vo = (UserAddressQueryVO)object;
return selectList(new LambdaQuery<UserAddressDO>()
.eqIfPresent(UserAddressDO::getMemberId, vo.getMemberId())
.eqIfPresent(UserAddressDO::getIsDefault, vo.getIsDefault())
.likeIfPresent(UserAddressDO::getName, vo.getName())
.eqIfPresent(UserAddressDO::getAreaCode, vo.getAreaCode())
.eqIfPresent(UserAddressDO::getPhone, vo.getPhone())
.eqIfPresent(UserAddressDO::getAddress, vo.getAddress())
.betweenIfPresent(UserAddressDO::getCreateTime, vo.getBeginCreateTime(), vo.getEndCreateTime())
.orderByDesc(UserAddressDO::getId));
}
return null;
}
}
......@@ -83,6 +83,7 @@ public class OrderVStrategy extends AbstractScoreRuleStrategy {
// 计算积分
List<ScoreRuleOrderVExtraVO.OrderVRule> orderVRules = extraInfo.getOrderVRule();
Integer scoreCount = 0;
// TODO:体积和重量取的字段确认
if (transportId == TransportTypeEnum.OCEAN_LCL.getValue()) {
// 海运算重量
BigDecimal orgVWeight = order.getOrgVWeight();
......@@ -146,6 +147,7 @@ public class OrderVStrategy extends AbstractScoreRuleStrategy {
}
}
// 校验累计最高分
// TODO:MaxScoreTotal为0时为不限制积分
Integer userScoreTotalCount = getUserScoreTotalCount(scoreRuleDO.getId(), userId);
if (userScoreTotalCount >= scoreRuleDO.getMaxScoreTotal()) {
log.info("Order in shipping listener: The user has reached the maximum score,userId:{},scoreRuleId:{}", userId, scoreRuleDO.getId());
......
package cn.iocoder.yudao.module.member.service.address;
import java.util.*;
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.dal.dataobject.address.UserAddressDO;
import cn.iocoder.yudao.module.member.vo.address.UserAddressCreateReqVO;
import cn.iocoder.yudao.module.member.vo.address.UserAddressQueryVO;
import cn.iocoder.yudao.module.member.vo.address.UserAddressUpdateReqVO;
/**
* 会员收货地址 Service 接口
*
* @author 系统管理员
*/
public interface UserAddressService extends IService<UserAddressDO> {
/**
* 创建会员收货地址
* @param createReqVO 创建信息
* @return 编号
*/
Long createUserAddress(@Valid UserAddressCreateReqVO createReqVO);
/**
* 更新会员收货地址
* @param updateReqVO 更新信息
*/
void updateUserAddress(@Valid UserAddressUpdateReqVO updateReqVO);
/**
* 删除会员收货地址
* @param id 编号
*/
void deleteUserAddress(Long id);
/**
* 获得会员收货地址
* @param id 编号
* @return 会员收货地址
*/
UserAddressDO getUserAddress(Long id);
/**
* 获得会员收货地址列表
* @param ids 编号
* @return 会员收货地址列表
*/
List<UserAddressDO> getUserAddressList(Collection<Long> ids);
/**
* 获得会员收货地址分页
* @param page 分页查询
* @param query 查询
* @return 会员收货地址分页
*/
PageResult<UserAddressDO> getUserAddressPage(UserAddressQueryVO query, PageVO page);
/**
* 获得会员收货地址列表, 用于 Excel 导出
* @param query 查询
* @return 会员收货地址列表
*/
List<UserAddressDO> getUserAddressList(UserAddressQueryVO query);
List<UserAddressDO> getUserAddressListByMemberId(Long memberId);
}
package cn.iocoder.yudao.module.member.service.address;
import java.util.*;
import javax.annotation.Resource;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.service.AbstractService;
import cn.iocoder.yudao.module.member.convert.address.UserAddressConvert;
import cn.iocoder.yudao.module.member.dal.dataobject.address.UserAddressDO;
import cn.iocoder.yudao.module.member.dal.mysql.address.UserAddressMapper;
import cn.iocoder.yudao.module.member.enums.YesOrNoTypeEnum;
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
import cn.iocoder.yudao.module.member.vo.address.UserAddressBaseVO;
import cn.iocoder.yudao.module.member.vo.address.UserAddressCreateReqVO;
import cn.iocoder.yudao.module.member.vo.address.UserAddressQueryVO;
import cn.iocoder.yudao.module.member.vo.address.UserAddressUpdateReqVO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*;
/**
* 会员收货地址 Service 实现类
*
* @author 系统管理员
*/
@Service
@Validated
public class UserAddressServiceImpl extends AbstractService<UserAddressMapper, UserAddressDO> implements UserAddressService {
@Resource
private UserAddressMapper userAddressMapper;
@Resource
private MemberUserService userService;
@Override
public Long createUserAddress(UserAddressCreateReqVO createReqVO) {
// 插入
UserAddressDO userAddress = UserAddressConvert.INSTANCE.convert(createReqVO);
updateIsDefault(createReqVO, 0L);
userAddressMapper.insert(userAddress);
// 返回
return userAddress.getId();
}
@Override
public void updateUserAddress(UserAddressUpdateReqVO updateReqVO) {
// 校验存在
this.validateUserAddressExists(updateReqVO.getId());
updateIsDefault(updateReqVO, updateReqVO.getId());
// 更新
UserAddressDO updateObj = UserAddressConvert.INSTANCE.convert(updateReqVO);
userAddressMapper.updateById(updateObj);
}
// 校验参数
private void verifyUserAddress(UserAddressBaseVO reqVO) {
// 会员id是否存在
//Long memberId = reqVO.getMemberId();
//if (userService.getUser(memberId) == null) {
// throw exception(USER_NOT_EXISTS);
//}
if (StringUtils.isAnyBlank(reqVO.getAddress(), reqVO.getAreaCode(), reqVO.getName(), reqVO.getPhone())) {
throw exception(USER_ADDRESS_FIELD_ERROR);
}
// 校验手机号格式
if (!reqVO.getPhone().matches("^1[3-9]\\d{9}$")) {
throw exception(USER_ADDRESS_FIELD_ERROR);
}
}
private void updateIsDefault(UserAddressBaseVO updateReqVO, Long id) {
// 如果更新了默认,修改其他地址默认状态保证只有一个默认
if (updateReqVO.getIsDefault() != null && updateReqVO.getIsDefault().equals(YesOrNoTypeEnum.YES.ordinal())) {
for (UserAddressDO userAddressDO : getUserAddressListByMemberId(updateReqVO.getMemberId())) {
if (!Objects.equals(userAddressDO.getId(), id) && userAddressDO.getIsDefault().equals(YesOrNoTypeEnum.YES.ordinal())) {
userAddressDO.setIsDefault(YesOrNoTypeEnum.NO.ordinal());
userAddressMapper.updateById(userAddressDO);
}
}
}
}
@Override
public void deleteUserAddress(Long id) {
// 校验存在
this.validateUserAddressExists(id);
// 删除
userAddressMapper.deleteById(id);
}
private void validateUserAddressExists(Long id) {
if (userAddressMapper.selectById(id) == null) {
throw exception(USER_ADDRESS_NOT_EXISTS);
}
}
@Override
public UserAddressDO getUserAddress(Long id) {
return userAddressMapper.selectById(id);
}
@Override
public List<UserAddressDO> getUserAddressList(Collection<Long> ids) {
return userAddressMapper.selectBatchIds(ids);
}
@Override
public PageResult<UserAddressDO> getUserAddressPage(UserAddressQueryVO query, PageVO page) {
return userAddressMapper.selectPage(page, query);
}
@Override
public List<UserAddressDO> getUserAddressList(UserAddressQueryVO query) {
return userAddressMapper.selectList(query);
}
@Override
public List<UserAddressDO> getUserAddressListByMemberId(Long memberId) {
return userAddressMapper.selectList("member_id", memberId);
}
}
package cn.iocoder.yudao.module.member.vo.address;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import com.alibaba.excel.annotation.ExcelProperty;
import org.springframework.format.annotation.DateTimeFormat;
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 UserAddressBackVO {
@ExcelProperty("主键")
@ApiModelProperty(value = "主键", required = true)
private Long id;
@ExcelProperty("会员id")
@ApiModelProperty(value = "会员id", required = true)
private Long memberId;
@ExcelProperty("是否默认地址")
@ApiModelProperty(value = "是否默认地址")
private Integer isDefault;
@ExcelProperty("收货人姓名")
@ApiModelProperty(value = "收货人姓名")
private String name;
@ExcelProperty("区号")
@ApiModelProperty(value = "区号")
private String areaCode;
@ExcelProperty("收货人手机")
@ApiModelProperty(value = "收货人手机")
private String phone;
@ExcelProperty("详细地址")
@ApiModelProperty(value = "详细地址")
private String address;
@ExcelProperty("创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "创建时间", required = true)
private Date createTime;
}
package cn.iocoder.yudao.module.member.vo.address;
import lombok.*;
import io.swagger.annotations.*;
import javax.validation.constraints.*;
/**
* 会员收货地址 Base VO,提供给添加、修改、详细的子 VO 使用
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
*/
@Data
public class UserAddressBaseVO {
@ApiModelProperty(value = "会员id", required = true)
@NotNull(message = "会员id不能为空")
private Long memberId;
@ApiModelProperty(value = "是否默认地址(0是,1否)")
private Integer isDefault = 1;
@ApiModelProperty(value = "收货人姓名", required = true)
@NotNull(message = "收货人姓名不能为空")
private String name = "";
@ApiModelProperty(value = "区号", required = true)
@NotNull(message = "区号不能为空")
private String areaCode = "";
@ApiModelProperty(value = "收货人手机", required = true)
@NotNull(message = "收货人手机不能为空")
private String phone = "";
@ApiModelProperty(value = "详细地址", required = true)
@NotNull(message = "详细地址不能为空")
private String address = "";
}
package cn.iocoder.yudao.module.member.vo.address;
import lombok.*;
import io.swagger.annotations.*;
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel("管理后台 - 会员收货地址创建 Request VO")
public class UserAddressCreateReqVO extends UserAddressBaseVO {
}
package cn.iocoder.yudao.module.member.vo.address;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import org.springframework.format.annotation.DateTimeFormat;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Data
@ApiModel("管理后台 - 会员收货地址查询 VO")
public class UserAddressQueryVO {
@ApiModelProperty(value = "会员id")
private Long memberId;
@ApiModelProperty(value = "是否默认地址")
private Integer isDefault;
@ApiModelProperty(value = "收货人姓名")
private String name;
@ApiModelProperty(value = "区号")
private String areaCode;
@ApiModelProperty(value = "收货人手机")
private String phone;
@ApiModelProperty(value = "详细地址")
private String address;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始创建时间")
private Date beginCreateTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束创建时间")
private Date endCreateTime;
}
package cn.iocoder.yudao.module.member.vo.address;
import lombok.*;
import io.swagger.annotations.*;
import javax.validation.constraints.*;
@ApiModel("管理后台 - 会员收货地址更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class UserAddressUpdateReqVO extends UserAddressBaseVO {
@ApiModelProperty(value = "主键", required = true)
@NotNull(message = "主键不能为空")
private Long id;
}
package cn.iocoder.yudao.module.reward.controller.app.config;
import cn.iocoder.yudao.framework.swagger.config.YudaoSwaggerAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.spring.web.plugins.Docket;
import javax.annotation.Resource;
/**
* Swagger2 自动配置类
*
* @author 捷道源码
*/
@Configuration
public class SwaggerAppRewardConfiguration {
@Bean
public Docket createAppRewardApi() {
String title = "客户端-礼品模块";
String author = "客户端-礼品模块";
String basePackage = "cn.iocoder.yudao.module.reward.controller.app";
// 创建 Docket 对象
return autoConfiguration.docket(title, author, basePackage);
}
@Resource
private YudaoSwaggerAutoConfiguration autoConfiguration;
}
\ No newline at end of file
package cn.iocoder.yudao.module.reward.controller.app.redeem;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.reward.api.reward.RedeemRewardApi;
import cn.iocoder.yudao.module.reward.api.reward.dto.RedeemRewardReqVO;
import cn.iocoder.yudao.module.reward.api.reward.dto.RedeemRewardRespDTO;
import cn.iocoder.yudao.module.reward.controller.app.redeem.vo.AppRewardRedeemListRespVO;
import cn.iocoder.yudao.module.reward.service.redeem.RewardRedeemService;
import cn.iocoder.yudao.module.reward.vo.reward.RewardRedeemBaseVO;
import cn.iocoder.yudao.module.reward.vo.reward.RewardRedeemPageRespVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
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 = "用户 APP - 兑换记录管理")
@RequestMapping("/reward/redeem")
public class AppRedeemRewardController {
@Resource
private RedeemRewardApi redeemRewardApi;
@Resource
private RewardRedeemService rewardRedeemService;
@PostMapping("record/list")
@ApiOperation("兑换记录列表")
//@PreAuthenticated
public CommonResult<List<AppRewardRedeemListRespVO>> recordList(@Valid @RequestBody RewardRedeemBaseVO request) {
return success(rewardRedeemService.recordList(request.getMemberId()));
}
@PostMapping("record/detail")
@ApiOperation("兑换详情")
//@PreAuthenticated
public CommonResult<RewardRedeemPageRespVO> detail(@Valid @RequestBody RewardRedeemBaseVO request) {
return success(rewardRedeemService.detail(request.getId()));
}
@PostMapping("/single")
@ApiOperation("兑换礼品")
//@PreAuthenticated
public CommonResult<RedeemRewardRespDTO> redeemReward(@Valid @RequestBody RedeemRewardReqVO redeemRewardReqVO) {
return success(redeemRewardApi.redeemReward(redeemRewardReqVO));
}
}
package cn.iocoder.yudao.module.reward.controller.app.redeem.vo;
import cn.iocoder.yudao.module.reward.vo.reward.RewardRedeemBaseVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
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
@ApiModel("客户端 - 礼品兑换记录列表 VO")
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class AppRewardRedeemListRespVO {
@ApiModelProperty(value = "id")
private Long id;
@ApiModelProperty(value = "礼品ID")
private Long rewardCode;
@ApiModelProperty(value = "礼品名称(中文)")
private String rewardTitleZh;
@ApiModelProperty(value = "礼品名称(英文)")
private String rewardTitleEn;
@ApiModelProperty(value = "礼品名称(法文)")
private String rewardTitleFr;
@ApiModelProperty(value = "兑换数量")
private Integer rewardCount;
@ApiModelProperty(value = "花费积分")
private Integer scoreCount;
@ApiModelProperty(value = "日志时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private Date createTime;
}
......@@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.reward.service.redeem;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.service.IService;
import cn.iocoder.yudao.module.reward.controller.app.redeem.vo.AppRewardRedeemListRespVO;
import cn.iocoder.yudao.module.reward.dal.dataobject.redeem.RewardRedeemDO;
import cn.iocoder.yudao.module.reward.vo.reward.*;
......@@ -37,4 +38,6 @@ public interface RewardRedeemService extends IService<RewardRedeemDO> {
Boolean cancel(RewardRedeemIdReqVO req);
RedeemCancelCheckRespVO cancelCheck(RewardRedeemIdReqVO req);
List<AppRewardRedeemListRespVO> recordList(Long memberId);
}
......@@ -16,12 +16,15 @@ import cn.iocoder.yudao.module.member.api.score.MemberUserScoreApi;
import cn.iocoder.yudao.module.member.api.score.dto.MemberUserScoreOperateReqDTO;
import cn.iocoder.yudao.module.member.api.score.dto.ReleationScoreExpireInfoDTO;
import cn.iocoder.yudao.module.member.enums.ScoreSourceTypeEnum;
import cn.iocoder.yudao.module.reward.controller.app.redeem.vo.AppRewardRedeemListRespVO;
import cn.iocoder.yudao.module.reward.dal.dataobject.redeem.RewardRedeemDO;
import cn.iocoder.yudao.module.reward.dal.dataobject.reward.RewardDO;
import cn.iocoder.yudao.module.reward.dal.mysql.redeem.RewardRedeemMapper;
import cn.iocoder.yudao.module.reward.dto.RewardRedeemVerifyDTO;
import cn.iocoder.yudao.module.reward.enums.ErrorCodeConstants;
import cn.iocoder.yudao.module.reward.enums.RewardPickMethedEnum;
import cn.iocoder.yudao.module.reward.enums.RewardRedeemStatusEnum;
import cn.iocoder.yudao.module.reward.service.reward.RewardService;
import cn.iocoder.yudao.module.reward.vo.reward.*;
import cn.iocoder.yudao.module.system.api.file.FileMakeApi;
import cn.iocoder.yudao.module.system.api.file.dto.FileMakeReqDTO;
......@@ -35,6 +38,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
......@@ -59,14 +63,16 @@ public class RewardRedeemServiceImpl extends AbstractService<RewardRedeemMapper,
private final ExpressApi expressApi;
private final CurrencyApi currencyApi;
private final MemberUserScoreApi memberUserScoreApi;
private final RewardService rewardService;
public RewardRedeemServiceImpl(RewardRedeemMapper rewardRedeemMapper, FileMakeApi fileMakeApi,
ExpressApi expressApi, CurrencyApi currencyApi, MemberUserScoreApi memberUserScoreApi) {
ExpressApi expressApi, CurrencyApi currencyApi, MemberUserScoreApi memberUserScoreApi, RewardService rewardService) {
this.rewardRedeemMapper = rewardRedeemMapper;
this.fileMakeApi = fileMakeApi;
this.expressApi = expressApi;
this.currencyApi = currencyApi;
this.memberUserScoreApi = memberUserScoreApi;
this.rewardService = rewardService;
}
@Override
......@@ -295,6 +301,24 @@ public class RewardRedeemServiceImpl extends AbstractService<RewardRedeemMapper,
return RedeemCancelCheckRespVO.builder().expireCount(totalExpireScore).build();
}
@Override
public List<AppRewardRedeemListRespVO> recordList(Long memberId) {
List<RewardRedeemDO> rewardRedeemDOList = rewardRedeemMapper.selectList("member_id", memberId);
return rewardRedeemDOList.stream().map(rewardRedeemDO -> {
RewardDO rewardDO = rewardService.getById(rewardRedeemDO.getRewardId());
return AppRewardRedeemListRespVO.builder()
.id(rewardRedeemDO.getId())
.createTime(rewardRedeemDO.getCreateTime())
.rewardCode(rewardRedeemDO.getRewardId())
.rewardTitleEn(rewardDO.getTitleEn())
.rewardTitleFr(rewardDO.getTitleFr())
.rewardTitleZh(rewardDO.getTitleZh())
.rewardCount(rewardRedeemDO.getRewardCount())
.scoreCount(rewardRedeemDO.getScoreCount())
.build();
}).collect(Collectors.toList());
}
private Map<String, String> validate(List<RedeemInfoImportExcelVO> dataList, Map<String, CurrencyRespDTO> titleZhCurrencyMap,
Map<String, CurrencyRespDTO> titleEnCurrencyMap,
Map<String, ExpressRespDTO> nameExpressMap) {
......
......@@ -3,9 +3,11 @@ package cn.iocoder.yudao.module.reward.vo.reward;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@ApiModel("管理后台 - 礼品兑换记录分页结果 VO")
@EqualsAndHashCode(callSuper = true)
public class RewardRedeemPageRespVO extends RewardRedeemBaseVO {
@ApiModelProperty(value = "会员名称中文")
private String memberNameZh;
......
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