Commit b7d23338 authored by zhaobiyan's avatar zhaobiyan

会员积分查询新增编码筛选

parents 58b8a937 7f1f5617
package cn.iocoder.yudao.framework.apollo.core.event.export;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class RewardRedeemRecordExportEvent {
/**
* 操作用户
*/
private Long userId = 0L;
/**
* 端口
*/
private Integer userType = 2;
/**
* 请求参数
*/
private String requestParams;
/**
* 国际化语言值,默认0中文, 具体取值I18nMessage.getLang()
*/
private Integer lang = 0;
/**
* 文件名称
*/
private String fileName;
/**
* 文件路径
*/
private String path;
/**
* 下载地址
*/
private String url;
/**
* 执行结果
*/
private String result;
@ApiModelProperty(value = "文件ID")
private Long fileId;
}
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
<dependency> <dependency>
<groupId>cn.iocoder.boot</groupId> <groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-system-impl</artifactId> <artifactId>yudao-module-system-impl</artifactId>
<version>1.6.1-snapshot</version> <version>${revision}</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
</dependencies> </dependencies>
......
...@@ -65,9 +65,9 @@ public class ScoreRuleController { ...@@ -65,9 +65,9 @@ public class ScoreRuleController {
@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('member:score-rule:query')") @PreAuthorize("@ss.hasPermission('member:score-rule:query')")
public CommonResult<ScoreRuleBackVO> getScoreRule(@NotNull @RequestBody Long id) { public CommonResult<ScoreRuleBackDetailVO> getScoreRule(@NotNull @RequestBody Long id) {
ScoreRuleBackVO scoreRuleBackVO = scoreRuleService.getScoreRule(id); ScoreRuleBackDetailVO scoreRuleBackDetailVO = scoreRuleService.getScoreRule(id);
return success(scoreRuleBackVO); return success(scoreRuleBackDetailVO);
} }
@PostMapping("/list") @PostMapping("/list")
......
package cn.iocoder.yudao.module.member.convert.scoreRule; package cn.iocoder.yudao.module.member.convert.scoreRule;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.member.dal.dataobject.scoreRule.ScoreRuleDO;
import cn.iocoder.yudao.module.member.vo.scoreRule.ScoreRuleBackVO; import cn.iocoder.yudao.module.member.vo.scoreRule.ScoreRuleBackVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.ScoreRuleCreateReqVO; import cn.iocoder.yudao.module.member.vo.scoreRule.ScoreRuleCreateReqVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.ScoreRuleUpdateReqVO; import cn.iocoder.yudao.module.member.vo.scoreRule.ScoreRuleUpdateReqVO;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
import cn.iocoder.yudao.module.member.dal.dataobject.scoreRule.ScoreRuleDO;
import java.util.List;
/** /**
* 积分规则 DO Convert * 积分规则 DO Convert
......
...@@ -41,7 +41,7 @@ public interface ScoreRuleService extends IService<ScoreRuleDO> { ...@@ -41,7 +41,7 @@ public interface ScoreRuleService extends IService<ScoreRuleDO> {
* @param id 编号 * @param id 编号
* @return 积分规则 * @return 积分规则
*/ */
ScoreRuleBackVO getScoreRule(Long id); ScoreRuleBackDetailVO getScoreRule(Long id);
/** /**
* 获得积分规则列表 * 获得积分规则列表
......
...@@ -17,6 +17,7 @@ import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleOrderVExtraVO; ...@@ -17,6 +17,7 @@ import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleOrderVExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleRegisterExtraVO; import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleRegisterExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleShareExtraVO; import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleShareExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRulerRecommendExtraVO; import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRulerRecommendExtraVO;
import org.springframework.beans.BeanUtils;
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;
...@@ -99,14 +100,15 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score ...@@ -99,14 +100,15 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
} }
@Override @Override
public ScoreRuleBackVO getScoreRule(Long id) { public ScoreRuleBackDetailVO getScoreRule(Long id) {
ScoreRuleDO scoreRuleDO = scoreRuleMapper.selectById(id); ScoreRuleDO scoreRuleDO = scoreRuleMapper.selectById(id);
if (scoreRuleDO == null) { if (scoreRuleDO == null) {
throw exception(SCORE_RULE_NOT_EXISTS); throw exception(SCORE_RULE_NOT_EXISTS);
} }
ScoreRuleBackVO scoreRuleBackVO = ScoreRuleConvert.INSTANCE.convert(scoreRuleDO); ScoreRuleBackDetailVO scoreRuleBackDetailVO = new ScoreRuleBackDetailVO();
setExtraVO(scoreRuleBackVO); BeanUtils.copyProperties(scoreRuleDO, scoreRuleBackDetailVO);
return scoreRuleBackVO; setExtraVO(scoreRuleBackDetailVO);
return scoreRuleBackDetailVO;
} }
...@@ -114,7 +116,6 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score ...@@ -114,7 +116,6 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
public List<ScoreRuleBackVO> getScoreRuleList(Collection<Long> ids) { public List<ScoreRuleBackVO> getScoreRuleList(Collection<Long> ids) {
List<ScoreRuleDO> scoreRuleDOS = scoreRuleMapper.selectBatchIds(ids); List<ScoreRuleDO> scoreRuleDOS = scoreRuleMapper.selectBatchIds(ids);
List<ScoreRuleBackVO> scoreRuleBackVOS = ScoreRuleConvert.INSTANCE.convertList(scoreRuleDOS); List<ScoreRuleBackVO> scoreRuleBackVOS = ScoreRuleConvert.INSTANCE.convertList(scoreRuleDOS);
scoreRuleBackVOS.forEach(this::setExtraVO);
return scoreRuleBackVOS; return scoreRuleBackVOS;
} }
...@@ -122,24 +123,23 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score ...@@ -122,24 +123,23 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
public PageResult<ScoreRuleBackVO> getScoreRulePage(ScoreRuleQueryVO query, PageVO page) { public PageResult<ScoreRuleBackVO> getScoreRulePage(ScoreRuleQueryVO query, PageVO page) {
PageResult<ScoreRuleDO> pageResult = scoreRuleMapper.selectPage(page, query); PageResult<ScoreRuleDO> pageResult = scoreRuleMapper.selectPage(page, query);
PageResult<ScoreRuleBackVO> scoreRuleBackVOPageResult = ScoreRuleConvert.INSTANCE.convertPage(pageResult); PageResult<ScoreRuleBackVO> scoreRuleBackVOPageResult = ScoreRuleConvert.INSTANCE.convertPage(pageResult);
scoreRuleBackVOPageResult.getList().forEach(this::setExtraVO);
return scoreRuleBackVOPageResult; return scoreRuleBackVOPageResult;
} }
/** /**
* 设置返回VO额外信息 * 设置返回VO额外信息
* *
* @param scoreRuleBackVO VO * @param scoreRuleBackDetailVO VO
*/ */
private void setExtraVO(ScoreRuleBackVO scoreRuleBackVO) { private void setExtraVO(ScoreRuleBackDetailVO scoreRuleBackDetailVO) {
if (scoreRuleBackVO.getType() == ScoreRuleTypeEnum.ORDER_V.getValue()) { if (scoreRuleBackDetailVO.getType() == ScoreRuleTypeEnum.ORDER_V.getValue()) {
scoreRuleBackVO.setExtraOrderV(JSONUtil.toBean(scoreRuleBackVO.getExtra(), ScoreRuleOrderVExtraVO.class)); scoreRuleBackDetailVO.setExtraOrderV(JSONUtil.toBean(scoreRuleBackDetailVO.getExtra(), ScoreRuleOrderVExtraVO.class));
} else if (scoreRuleBackVO.getType() == ScoreRuleTypeEnum.REGISTER.getValue()) { } else if (scoreRuleBackDetailVO.getType() == ScoreRuleTypeEnum.REGISTER.getValue()) {
scoreRuleBackVO.setExtraRegister(JSONUtil.toBean(scoreRuleBackVO.getExtra(), ScoreRuleRegisterExtraVO.class)); scoreRuleBackDetailVO.setExtraRegister(JSONUtil.toBean(scoreRuleBackDetailVO.getExtra(), ScoreRuleRegisterExtraVO.class));
} else if (scoreRuleBackVO.getType() == ScoreRuleTypeEnum.RECOMMEND.getValue()) { } else if (scoreRuleBackDetailVO.getType() == ScoreRuleTypeEnum.RECOMMEND.getValue()) {
scoreRuleBackVO.setExtraRecommend(JSONUtil.toBean(scoreRuleBackVO.getExtra(), ScoreRulerRecommendExtraVO.class)); scoreRuleBackDetailVO.setExtraRecommend(JSONUtil.toBean(scoreRuleBackDetailVO.getExtra(), ScoreRulerRecommendExtraVO.class));
} else if (scoreRuleBackVO.getType() == ScoreRuleTypeEnum.SHARE.getValue()) { } else if (scoreRuleBackDetailVO.getType() == ScoreRuleTypeEnum.SHARE.getValue()) {
scoreRuleBackVO.setExtraShare(JSONUtil.toBean(scoreRuleBackVO.getExtra(), ScoreRuleShareExtraVO.class)); scoreRuleBackDetailVO.setExtraShare(JSONUtil.toBean(scoreRuleBackDetailVO.getExtra(), ScoreRuleShareExtraVO.class));
} else { } else {
throw exception(SCORE_RULE_NOT_EXISTS); throw exception(SCORE_RULE_NOT_EXISTS);
} }
......
package cn.iocoder.yudao.module.member.vo.scoreRule;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleOrderVExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleRegisterExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleShareExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRulerRecommendExtraVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel("管理后台 - 积分规则详细信息 Response VO")
public class ScoreRuleBackDetailVO extends ScoreRuleBackVO{
@ApiModelProperty(value = "扩展字段原始")
private String extra;
@ApiModelProperty(value = "订单V值扩展字段")
private ScoreRuleOrderVExtraVO extraOrderV;
@ApiModelProperty(value = "注册扩展字段")
private ScoreRuleRegisterExtraVO extraRegister;
@ApiModelProperty(value = "推荐扩展字段")
private ScoreRulerRecommendExtraVO extraRecommend;
@ApiModelProperty(value = "分享扩展字段")
private ScoreRuleShareExtraVO extraShare;
}
package cn.iocoder.yudao.module.member.vo.scoreRule; package cn.iocoder.yudao.module.member.vo.scoreRule;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleOrderVExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleRegisterExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleShareExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRulerRecommendExtraVO;
import com.baomidou.dynamic.datasource.annotation.DS;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat; 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; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
/** /**
...@@ -17,7 +15,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ ...@@ -17,7 +15,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
* @author 系统管理员 * @author 系统管理员
*/ */
@Data @Data
@ApiModel("管理后台 - 积分规则 Response VO") @ApiModel("管理后台 - 积分规则基本信息 Response VO")
public class ScoreRuleBackVO { public class ScoreRuleBackVO {
@ExcelProperty("主键") @ExcelProperty("主键")
...@@ -72,7 +70,7 @@ public class ScoreRuleBackVO { ...@@ -72,7 +70,7 @@ public class ScoreRuleBackVO {
@ExcelProperty("积分有效期") @ExcelProperty("积分有效期")
@ApiModelProperty(value = "积分有效期", required = true) @ApiModelProperty(value = "积分有效期", required = true)
private Integer socrePeriod; private Integer scorePeriod;
@ExcelProperty("排序值") @ExcelProperty("排序值")
@ApiModelProperty(value = "排序值", required = true) @ApiModelProperty(value = "排序值", required = true)
...@@ -95,15 +93,17 @@ public class ScoreRuleBackVO { ...@@ -95,15 +93,17 @@ public class ScoreRuleBackVO {
@ApiModelProperty(value = "创建时间", required = true) @ApiModelProperty(value = "创建时间", required = true)
private Date createTime; private Date createTime;
@ApiModelProperty(value = "扩展字段原始") @ExcelProperty("更新时间")
private String extra; @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "订单V值扩展字段") @ApiModelProperty(value = "更新时间", required = true)
private ScoreRuleOrderVExtraVO extraOrderV; private Date updateTime;
@ApiModelProperty(value = "注册扩展字段")
private ScoreRuleRegisterExtraVO extraRegister; @ExcelProperty("创建人")
@ApiModelProperty(value = "推荐扩展字段") @ApiModelProperty(value = "创建人", required = true)
private ScoreRulerRecommendExtraVO extraRecommend; private String creator;
@ApiModelProperty(value = "分享扩展字段")
private ScoreRuleShareExtraVO extraShare; @ExcelProperty("更新人")
@ApiModelProperty(value = "更新人", required = true)
private String updater;
} }
...@@ -70,7 +70,7 @@ public class ScoreRuleBaseVO { ...@@ -70,7 +70,7 @@ public class ScoreRuleBaseVO {
@NotNull(message = "排序值不能为空") @NotNull(message = "排序值不能为空")
private Integer orderNum; private Integer orderNum;
@ApiModelProperty(value = "是否推送(0是,1否)", required = true) @ApiModelProperty(value = "是否推送(0是,1否)默认是", required = true)
@NotNull(message = "是否推送不能为空") @NotNull(message = "是否推送不能为空")
private Integer pushActivity = 0; private Integer pushActivity = 0;
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
<sql id="scoreCondition"> <sql id="scoreCondition">
<if test="query.key != null and query.key != ''"> <if test="query.key != null and query.key != ''">
and (mu.nickname like '%${query.key}%' or mu.mobile like '%${query.key}%') and (mu.nickname like '%${query.key}%' or mu.mobile like '%${query.key}%' or mu.code like '%${query.key}%')
</if> </if>
<if test="query.country != null"> <if test="query.country != null">
and mu.country = #{query.country} and mu.country = #{query.country}
......
...@@ -39,12 +39,28 @@ ...@@ -39,12 +39,28 @@
<dependency> <dependency>
<groupId>cn.iocoder.boot</groupId> <groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-system-api</artifactId> <artifactId>yudao-module-system-api</artifactId>
<version>1.6.1-snapshot</version> <version>${revision}</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>cn.iocoder.boot</groupId> <groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-ecw-api</artifactId> <artifactId>yudao-module-ecw-api</artifactId>
<version>${revision}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-config</artifactId>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-system-impl</artifactId>
<version>1.6.1-snapshot</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-infra-impl</artifactId>
<version>1.6.1-snapshot</version> <version>1.6.1-snapshot</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
......
...@@ -72,6 +72,12 @@ public class RedeemRewardController { ...@@ -72,6 +72,12 @@ public class RedeemRewardController {
return success(rewardRedeemService.verifyBack(redeemIds)); return success(rewardRedeemService.verifyBack(redeemIds));
} }
@PostMapping("record/export")
@ApiOperation("导出")
public CommonResult<Boolean> export(@Valid @RequestBody RewardRedeemPageReqVO reqVO) {
return success(rewardRedeemService.export(reqVO));
}
@PostMapping("/single") @PostMapping("/single")
@ApiOperation("兑换礼品") @ApiOperation("兑换礼品")
......
...@@ -21,4 +21,6 @@ public interface RewardRedeemMapper extends AbstractMapper<RewardRedeemDO> { ...@@ -21,4 +21,6 @@ public interface RewardRedeemMapper extends AbstractMapper<RewardRedeemDO> {
int pageCount(@Param("req") RewardRedeemPageReqVO reqVO); int pageCount(@Param("req") RewardRedeemPageReqVO reqVO);
RewardRedeemPageRespVO detail(@Param("id") Long id); RewardRedeemPageRespVO detail(@Param("id") Long id);
List<RewardRedeemPageRespVO> exportList(@Param("req") RewardRedeemPageReqVO request);
} }
package cn.iocoder.yudao.module.reward.listener;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.apollo.core.event.export.RewardRedeemRecordExportEvent;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.excel.util.ExcelUtils;
import cn.iocoder.yudao.module.infra.api.file.FileApi;
import cn.iocoder.yudao.module.infra.api.file.dto.FileRespDto;
import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileDO;
import cn.iocoder.yudao.module.reward.service.redeem.RewardRedeemService;
import cn.iocoder.yudao.module.reward.vo.reward.RewardRedeemPageReqVO;
import cn.iocoder.yudao.module.reward.vo.reward.RewardRedeemPageRespVO;
import cn.iocoder.yudao.module.reward.vo.reward.RewardRedeemRecordExportVO;
import cn.iocoder.yudao.module.system.framework.ue.UeProperties;
import com.alibaba.fastjson.JSONObject;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import java.io.File;
import java.io.FileInputStream;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.excel.constant.ExportConstant.DATA_FORMAT;
@Component
@AllArgsConstructor
@Slf4j
public class RewardRedeemRecordExportListener {
private RewardRedeemService rewardRedeemService;
private UeProperties ueProperties;
private FileApi fileService;
@EventListener(RewardRedeemRecordExportEvent.class)
public void listen(RewardRedeemRecordExportEvent event) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATA_FORMAT);
String nowTime = formatter.format(LocalDateTime.now());
String dir = ueProperties.getTempDir().concat("/rewardRedeemRecord/excel/");
File fileDir = new File(dir);
if (!fileDir.exists()){
// 不存在则创建一个目录
fileDir.mkdirs();
}
String fileName = event.getUserId().toString().concat(StrUtil.DASHED).concat(event.getUserType().toString()).concat(StrUtil.DASHED).concat(nowTime).concat("shipment_preload.xlsx");
RewardRedeemPageReqVO request = JSONObject.parseObject(event.getRequestParams(), RewardRedeemPageReqVO.class);
Integer totalCount = rewardRedeemService.exportCount(request);
int size = 500;
int totalPage = totalCount%size == 0 ? totalCount/size: totalCount/size + 1;
List<RewardRedeemRecordExportVO> result = new ArrayList<>();
for (int i = 1; i <= totalPage ; i++) {
request.setPageNo(i);
request.setPageSize(size);
PageResult<RewardRedeemPageRespVO> rewardRedeemPageRespVOPageResult = rewardRedeemService.pageInfo(request);
result.addAll(convert2ExcelVo(rewardRedeemPageRespVOPageResult.getList()));
}
try {
String path = ExcelUtils.write(dir, fileName, "数据", RewardRedeemRecordExportVO.class, result);
// 获取到临时文件
File file = new File(path);
// 创建FileInputStream对象
FileInputStream fileInputStream = new FileInputStream(file);
// 读取文件内容
byte[] fileBytes = new byte[(int) file.length()];
fileInputStream.read(fileBytes);
// 关闭文件流
fileInputStream.close();
// 将文件上传到资源服务器
FileRespDto fileRespDto = fileService.createFile(dir, fileName, fileBytes);
event.setPath(fileRespDto.getPath());
event.setFileName(fileRespDto.getFileName());
event.setUrl(fileRespDto.getUrl());
event.setFileId(fileRespDto.getId());
} catch (Exception e) {
log.info("reward redeem record export listener exception", e);
event.setResult(e.getMessage());
}
}
private Collection<RewardRedeemRecordExportVO> convert2ExcelVo(List<RewardRedeemPageRespVO> list) {
return list.stream().map(item -> {
RewardRedeemRecordExportVO exportVO = new RewardRedeemRecordExportVO();
exportVO.setId(String.valueOf(item.getId()));
exportVO.setStatus(item.getStatus());
exportVO.setRewardCode(item.getRewardCode());
exportVO.setRewardTitle(item.getRewardTitleZh());
exportVO.setMemberName(item.getMemberName());
exportVO.setRewardCount(item.getRewardCount());
exportVO.setRedeemType(item.getRedeemType());
exportVO.setEntrance(item.getEntrance());
exportVO.setExpenses(item.getExpenses());
exportVO.setCurrencyTitle(item.getCurrencyTitleZh());
exportVO.setRecipientName(item.getRecipientName());
exportVO.setRecipientPhoneNum(item.getRecipientPhoneNum());
exportVO.setRecipientAddress(item.getRecipientAddress());
exportVO.setRedeemer(item.getRedeemer());
exportVO.setRedemptionTime(item.getCreateTime());
exportVO.setCourierCompanyName(item.getCourierCompanyName());
exportVO.setExpressNo(item.getExpressNo());
exportVO.setExpressDate(item.getExpressDate());
exportVO.setExpressSender(item.getExpressSender());
exportVO.setRemark(item.getRemark());
exportVO.setVerifyUser(item.getVerifyUser());
exportVO.setVerifyTime(item.getVerifyTime());
exportVO.setCreatorName(item.getCreatorName());
exportVO.setCreateTime(item.getCreateTime());
exportVO.setUpdaterName(item.getUpdaterName());
exportVO.setUpdateTime(item.getUpdateTime());
return exportVO;
}).collect(Collectors.toList());
}
}
...@@ -25,4 +25,10 @@ public interface RewardRedeemService extends IService<RewardRedeemDO> { ...@@ -25,4 +25,10 @@ public interface RewardRedeemService extends IService<RewardRedeemDO> {
Boolean batchVerify(RewardRedeemBatchVerifyReqVO request); Boolean batchVerify(RewardRedeemBatchVerifyReqVO request);
Boolean verifyBack(List<Long> redeemIds); Boolean verifyBack(List<Long> redeemIds);
Boolean export(RewardRedeemPageReqVO reqVO);
List<RewardRedeemPageRespVO> exportList(RewardRedeemPageReqVO request);
Integer exportCount(RewardRedeemPageReqVO request);
} }
package cn.iocoder.yudao.module.reward.service.redeem; package cn.iocoder.yudao.module.reward.service.redeem;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.i18n.core.I18nMessage;
import cn.iocoder.yudao.framework.mybatis.core.service.AbstractService; import cn.iocoder.yudao.framework.mybatis.core.service.AbstractService;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.reward.dal.dataobject.redeem.RewardRedeemDO; import cn.iocoder.yudao.module.reward.dal.dataobject.redeem.RewardRedeemDO;
...@@ -11,6 +12,9 @@ import cn.iocoder.yudao.module.reward.enums.RewardPickMethedEnum; ...@@ -11,6 +12,9 @@ import cn.iocoder.yudao.module.reward.enums.RewardPickMethedEnum;
import cn.iocoder.yudao.module.reward.enums.RewardRedeemStatusEnum; import cn.iocoder.yudao.module.reward.enums.RewardRedeemStatusEnum;
import cn.iocoder.yudao.module.reward.service.reward.RewardService; import cn.iocoder.yudao.module.reward.service.reward.RewardService;
import cn.iocoder.yudao.module.reward.vo.reward.*; 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;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
...@@ -19,6 +23,7 @@ import lombok.extern.slf4j.Slf4j; ...@@ -19,6 +23,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -26,6 +31,7 @@ import java.util.function.Function; ...@@ -26,6 +31,7 @@ import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
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.system.enums.download.DownloadTypeEnum.REWARD_REDEEM_RECORD;
/** /**
* 礼品兑换 Service * 礼品兑换 Service
...@@ -39,6 +45,8 @@ public class RewardRedeemServiceImpl extends AbstractService<RewardRedeemMapper, ...@@ -39,6 +45,8 @@ public class RewardRedeemServiceImpl extends AbstractService<RewardRedeemMapper,
private RewardRedeemMapper rewardRedeemMapper; private RewardRedeemMapper rewardRedeemMapper;
@Resource @Resource
private RewardService rewardService; private RewardService rewardService;
@Resource
private FileMakeApi fileMakeApi;
@Override @Override
public PageResult<RewardRedeemPageRespVO> pageInfo(RewardRedeemPageReqVO reqVO) { public PageResult<RewardRedeemPageRespVO> pageInfo(RewardRedeemPageReqVO reqVO) {
...@@ -152,6 +160,29 @@ public class RewardRedeemServiceImpl extends AbstractService<RewardRedeemMapper, ...@@ -152,6 +160,29 @@ public class RewardRedeemServiceImpl extends AbstractService<RewardRedeemMapper,
return true; return true;
} }
@Override
public Boolean export(RewardRedeemPageReqVO reqVO) {
FileMakeReqDTO fileMakeReqDTO = new FileMakeReqDTO();
fileMakeReqDTO.setType(REWARD_REDEEM_RECORD.getType());
fileMakeReqDTO.setName("礼品兑换记录导出excel");
fileMakeReqDTO.setFileSuffix("xlsx");
fileMakeReqDTO.setTemporaryFile(true);
fileMakeReqDTO.setUserType(2);
fileMakeReqDTO.setLang(I18nMessage.getLang());
fileMakeReqDTO.setRequestParams(JSONObject.toJSONString(reqVO));
fileMakeApi.sendFileMake(fileMakeReqDTO);
return true;
}
@Override
public List<RewardRedeemPageRespVO> exportList(RewardRedeemPageReqVO request) {
return rewardRedeemMapper.exportList(request);
}
@Override
public Integer exportCount(RewardRedeemPageReqVO request) {
return rewardRedeemMapper.pageCount(request);
}
private List<Long> checkBatchVerifyParam(RewardRedeemBatchVerifyReqVO request) { private List<Long> checkBatchVerifyParam(RewardRedeemBatchVerifyReqVO request) {
LambdaUpdateWrapper<RewardRedeemDO> wrapper = Wrappers.lambdaUpdate(); LambdaUpdateWrapper<RewardRedeemDO> wrapper = Wrappers.lambdaUpdate();
wrapper.in(RewardRedeemDO::getId, request.getIds()); wrapper.in(RewardRedeemDO::getId, request.getIds());
......
...@@ -88,7 +88,7 @@ public class RewardRedeemBaseVO { ...@@ -88,7 +88,7 @@ public class RewardRedeemBaseVO {
* 快递日期 * 快递日期
*/ */
@ApiModelProperty(value = "快递日期") @ApiModelProperty(value = "快递日期")
private String expressDate; private Date expressDate;
/** /**
* 快递寄出人 * 快递寄出人
*/ */
...@@ -111,7 +111,7 @@ public class RewardRedeemBaseVO { ...@@ -111,7 +111,7 @@ public class RewardRedeemBaseVO {
@ApiModelProperty(value = "更新人id") @ApiModelProperty(value = "更新人id")
private String updater; private String updater;
@ApiModelProperty(value = "更新时间") @ApiModelProperty(value = "更新时间")
private String updateTime; private Date updateTime;
@ApiModelProperty(value = "是否删除") @ApiModelProperty(value = "是否删除")
private Boolean deleted; private Boolean deleted;
/** /**
...@@ -123,5 +123,5 @@ public class RewardRedeemBaseVO { ...@@ -123,5 +123,5 @@ public class RewardRedeemBaseVO {
* 核销时间 * 核销时间
*/ */
@ApiModelProperty(value = "核销时间") @ApiModelProperty(value = "核销时间")
private String verifyTime; private Date verifyTime;
} }
...@@ -23,12 +23,15 @@ public class RewardRedeemPageRespVO extends RewardRedeemBaseVO { ...@@ -23,12 +23,15 @@ public class RewardRedeemPageRespVO extends RewardRedeemBaseVO {
private String nodeTitleEn; private String nodeTitleEn;
@ApiModelProperty(value = "兑换积分") @ApiModelProperty(value = "兑换积分")
private Integer totalCount; private Integer totalCount;
@ApiModelProperty(value = "创建人时间") @ApiModelProperty(value = "创建人")
private String creatorName; private String creatorName;
@ApiModelProperty(value = "更新人时间") @ApiModelProperty(value = "更新人")
private String updaterName; private String updaterName;
@ApiModelProperty(value = "币种名称中文") @ApiModelProperty(value = "币种名称中文")
private String currencyTitleZh; private String currencyTitleZh;
@ApiModelProperty(value = "币种名称英文") @ApiModelProperty(value = "币种名称英文")
private String currencyTitleEn; private String currencyTitleEn;
@ApiModelProperty(value = "快递公司名称")
private String courierCompanyName;
} }
package cn.iocoder.yudao.module.reward.vo.reward;
import cn.iocoder.yudao.framework.excel.annotations.DictFormat;
import cn.iocoder.yudao.framework.excel.convert.DictConvert;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.converters.bigdecimal.BigDecimalStringConverter;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
@Data
public class RewardRedeemRecordExportVO {
@ExcelProperty("兑换记录ID")
private String id;
@ExcelProperty(value = "兑换状态", converter = DictConvert.class)
@DictFormat("reward_redeem_status")
private Integer status;
@ExcelProperty("礼品ID")
private String rewardCode;
@ExcelProperty("礼品名称")
private String rewardTitle;
@ExcelProperty("会员名称")
private String memberName;
@ExcelProperty("兑换数量")
private Integer rewardCount;
@ExcelProperty(value = "兑换方式", converter = DictConvert.class)
@DictFormat("way_of_receiving")
private Integer redeemType;
@ExcelProperty(value = "兑换入口", converter = DictConvert.class)
@DictFormat("platform_type")
private Integer entrance;
@ExcelProperty(value = "费用", converter = BigDecimalStringConverter.class)
private BigDecimal expenses;
@ExcelProperty("币种名称")
private String currencyTitle;
@ExcelProperty(value = "收件人姓名")
private String recipientName;
@ExcelProperty(value = "收件人电话")
private String recipientPhoneNum;
@ExcelProperty(value = "收件人地址")
private String recipientAddress;
@ExcelProperty(value = "兑换人")
private String redeemer;
@ExcelProperty(value = "兑换时间")
private Date redemptionTime;
@ExcelProperty(value = "快递公司名称")
private String courierCompanyName;
@ExcelProperty(value = "快递单号")
private String expressNo;
@ExcelProperty(value = "快递日期")
private Date expressDate;
@ExcelProperty(value = "快递寄出人")
private String expressSender;
@ExcelProperty(value = "备注")
private String remark;
@ExcelProperty(value = "核销人")
private String verifyUser;
@ExcelProperty(value = "核销时间")
private Date verifyTime;
@ExcelProperty(value = "创建人")
private String creatorName;
@ExcelProperty(value = "创建时间")
private Date createTime;
@ExcelProperty(value = "更新人")
private String updaterName;
@ExcelProperty(value = "更新时间")
private Date updateTime;
}
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
left join system_user suc on suc.id = er.creator left join system_user suc on suc.id = er.creator
left join system_user suu on suu.id = er.updater left join system_user suu on suu.id = er.updater
left join ecw_currency cc on err.currency = cc.id left join ecw_currency cc on err.currency = cc.id
left join ecw_express ee on err.courier_company = ee.id
where 1=1 where 1=1
<include refid="pageCondition"/> <include refid="pageCondition"/>
order by er.create_time desc order by er.create_time desc
...@@ -32,6 +33,7 @@ ...@@ -32,6 +33,7 @@
left join ecw_node en on er.node_id = en.id left join ecw_node en on er.node_id = en.id
left join system_user suc on suc.id = er.creator left join system_user suc on suc.id = er.creator
left join system_user suu on suu.id = er.updater left join system_user suu on suu.id = er.updater
left join ecw_express ee on err.courier_company = ee.id
where 1=1 where 1=1
<include refid="pageCondition"/> <include refid="pageCondition"/>
</select> </select>
...@@ -45,8 +47,24 @@ ...@@ -45,8 +47,24 @@
left join system_user suc on suc.id = er.creator left join system_user suc on suc.id = er.creator
left join system_user suu on suu.id = er.updater left join system_user suu on suu.id = er.updater
left join ecw_currency cc on err.currency = cc.id left join ecw_currency cc on err.currency = cc.id
left join ecw_express ee on err.courier_company = ee.id
where err.id = #{id} where err.id = #{id}
</select> </select>
<select id="exportList" resultType="cn.iocoder.yudao.module.reward.vo.reward.RewardRedeemPageRespVO">
select
<include refid="columns"/>
from ecw_reward_redeem err
left join ecw_reward er on err.reward_id = er.id
left join member_user mu on mu.id = err.member_id
left join ecw_node en on er.node_id = en.id
left join system_user suc on suc.id = er.creator
left join system_user suu on suu.id = er.updater
left join ecw_currency cc on err.currency = cc.id
left join ecw_express ee on err.courier_company = ee.id
where 1=1
<include refid="pageCondition"/>
order by er.create_time desc
</select>
<sql id="columns"> <sql id="columns">
err.id , err.id ,
...@@ -64,6 +82,7 @@ ...@@ -64,6 +82,7 @@
err.redeemer, err.redeemer,
err.redemption_time as redemptionTime, err.redemption_time as redemptionTime,
err.courier_company as courierCompany, err.courier_company as courierCompany,
ee.company_name as courierCompanyName,
err.express_no as expressNo, err.express_no as expressNo,
err.express_date as expressDate, err.express_date as expressDate,
err.express_sender as expressSender, err.express_sender as expressSender,
......
...@@ -174,6 +174,11 @@ public enum DownloadTypeEnum implements IntArrayValuable { ...@@ -174,6 +174,11 @@ public enum DownloadTypeEnum implements IntArrayValuable {
*/ */
REPORT_SALES_ANALYSIS(32), REPORT_SALES_ANALYSIS(32),
/**
* 礼品兑换记录
*/
REWARD_REDEEM_RECORD(33),
// ....自己补充 // ....自己补充
; ;
......
...@@ -362,6 +362,9 @@ public class DownloadLogServiceImpl extends AbstractService<DownloadLogMapper, D ...@@ -362,6 +362,9 @@ public class DownloadLogServiceImpl extends AbstractService<DownloadLogMapper, D
//销售分析报表 //销售分析报表
REPORT_SALES_ANALYSIS_Event(downloadLog); REPORT_SALES_ANALYSIS_Event(downloadLog);
break; break;
case REWARD_REDEEM_RECORD:
rewardRedeemRecordExportPushEvent(downloadLog);
break;
default: default:
downloadLog.setResult("unknown type"); downloadLog.setResult("unknown type");
break; break;
...@@ -388,6 +391,20 @@ public class DownloadLogServiceImpl extends AbstractService<DownloadLogMapper, D ...@@ -388,6 +391,20 @@ public class DownloadLogServiceImpl extends AbstractService<DownloadLogMapper, D
} }
} }
private void rewardRedeemRecordExportPushEvent(DownloadLogDO downloadLog) {
RewardRedeemRecordExportEvent event = new RewardRedeemRecordExportEvent();
event.setUserId(downloadLog.getUserId());
event.setUserType(downloadLog.getUserType());
event.setLang(downloadLog.getLang());
event.setRequestParams(downloadLog.getRequestParams());
applicationContext.publishEvent(event);
downloadLog.setFileName(event.getFileName());
downloadLog.setPath(event.getPath());
downloadLog.setDownloadUrl(event.getUrl());
downloadLog.setResult(event.getResult());
downloadLog.setFileId(event.getFileId());
}
private void achievementDetailExcelExportPushEvent(DownloadLogDO downloadLog) { private void achievementDetailExcelExportPushEvent(DownloadLogDO downloadLog) {
AchievementDetailExcelExportPushEvent event = new AchievementDetailExcelExportPushEvent(); AchievementDetailExcelExportPushEvent event = new AchievementDetailExcelExportPushEvent();
event.setUserId(downloadLog.getUserId()); event.setUserId(downloadLog.getUserId());
......
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