diff --git a/dating-agency-mall-server/src/main/java/com/qniao/dam/api/query/walletaccount/user/WalletAccountUserQueryController.java b/dating-agency-mall-server/src/main/java/com/qniao/dam/api/query/walletaccount/user/WalletAccountUserQueryController.java index f2a2593..3bcccd9 100644 --- a/dating-agency-mall-server/src/main/java/com/qniao/dam/api/query/walletaccount/user/WalletAccountUserQueryController.java +++ b/dating-agency-mall-server/src/main/java/com/qniao/dam/api/query/walletaccount/user/WalletAccountUserQueryController.java @@ -1,19 +1,14 @@ package com.qniao.dam.api.query.walletaccount.user; -import com.qniao.dam.api.query.revenuereward.user.request.UsePageRevenueRewardRecordByOperatorQueryParams; -import com.qniao.dam.api.query.revenuereward.user.response.UsePageRevenueRewardRecordByOperatorVo; import com.qniao.dam.api.query.walletaccount.user.request.UsePageWalletAccountRecordByOperatorQueryParams; import com.qniao.dam.api.query.walletaccount.user.request.UserPageWalletAccountRecordQueryParam; -import com.qniao.dam.api.query.walletaccount.user.response.UseGetWalletAccountAbstractByOperatorVo; import com.qniao.dam.api.query.walletaccount.user.response.UsePageWalletAccountRecordByOperatorVo; import com.qniao.dam.api.query.walletaccount.user.response.UserGetWalletAccountRecordVo; import com.qniao.dam.api.query.walletaccount.user.response.UserGetWalletAccountVo; -import com.qniao.dam.domain.aggregate.walletaccount.entity.WalletAccount; import com.qniao.dam.query.walletaccount.WalletAccountQueryService; import com.qniao.dau.infrastructure.constant.RequestHeaderFields; import com.qniao.domain.QnPage; import com.qniao.framework.utils.PageUtil; -import com.qniao.framework.utils.TypeConvertUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.*; @@ -58,4 +53,11 @@ public class WalletAccountUserQueryController { UsePageWalletAccountRecordByOperatorQueryParams queryParams) { return PageUtil.convert(walletAccountQueryService.pageWalletAccountRecordByOperator(pageUtil, queryParams), UsePageWalletAccountRecordByOperatorVo.class); } + + + @ApiOperation("运营端导出用户收益记录分页") + @GetMapping("/export/wallet-account-record/by/operator") + public String userExportWalletAccountRecordByOperator(UsePageWalletAccountRecordByOperatorQueryParams queryParams) { + return walletAccountQueryService.exportData(queryParams); + } } diff --git a/dating-agency-mall-server/src/main/java/com/qniao/dam/api/query/walletaccount/user/response/WalletAccountRecordExportVo.java b/dating-agency-mall-server/src/main/java/com/qniao/dam/api/query/walletaccount/user/response/WalletAccountRecordExportVo.java new file mode 100644 index 0000000..ff4d58a --- /dev/null +++ b/dating-agency-mall-server/src/main/java/com/qniao/dam/api/query/walletaccount/user/response/WalletAccountRecordExportVo.java @@ -0,0 +1,41 @@ +package com.qniao.dam.api.query.walletaccount.user.response; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +@Data +public class WalletAccountRecordExportVo { + + @ApiModelProperty("流水明细ID") + private Long associateId; + + @ApiModelProperty("交易类型") + private String tradeTypeVal; + + @ApiModelProperty("是否收入") + private String isIncome; + + @ApiModelProperty("创建时间") + private LocalDateTime createTime; + + @ApiModelProperty("名称") + private String name; + + @ApiModelProperty("手机号") + private String phone; + + @ApiModelProperty("红娘等级") + private String matchmakerLevelVal; + + @ApiModelProperty("交易金额") + private BigDecimal tradeAmount; + + @ApiModelProperty("原始金额") + private BigDecimal originalBalance; + + @ApiModelProperty("当前金额") + private BigDecimal currentBalance; +} diff --git a/dating-agency-mall-server/src/main/java/com/qniao/dam/query/walletaccount/WalletAccountQueryService.java b/dating-agency-mall-server/src/main/java/com/qniao/dam/query/walletaccount/WalletAccountQueryService.java index 7c18148..c430014 100644 --- a/dating-agency-mall-server/src/main/java/com/qniao/dam/query/walletaccount/WalletAccountQueryService.java +++ b/dating-agency-mall-server/src/main/java/com/qniao/dam/query/walletaccount/WalletAccountQueryService.java @@ -25,4 +25,6 @@ public interface WalletAccountQueryService { BigDecimal countAvailableWithdrawBalance(WalletAccount walletAccount); IPage pageWalletAccountRecordByOperator(PageUtil pageUtil, UsePageWalletAccountRecordByOperatorQueryParams queryParams); + + String exportData(UsePageWalletAccountRecordByOperatorQueryParams queryParams); } diff --git a/dating-agency-mall-server/src/main/java/com/qniao/dam/query/walletaccount/impl/WalletAccountQueryServiceImpl.java b/dating-agency-mall-server/src/main/java/com/qniao/dam/query/walletaccount/impl/WalletAccountQueryServiceImpl.java index 97633d4..372b80b 100644 --- a/dating-agency-mall-server/src/main/java/com/qniao/dam/query/walletaccount/impl/WalletAccountQueryServiceImpl.java +++ b/dating-agency-mall-server/src/main/java/com/qniao/dam/query/walletaccount/impl/WalletAccountQueryServiceImpl.java @@ -7,9 +7,11 @@ import com.qniao.dam.api.query.walletaccount.user.request.UserPageWalletAccountR import com.qniao.dam.api.query.walletaccount.user.response.UsePageWalletAccountRecordByOperatorVo; import com.qniao.dam.api.query.walletaccount.user.response.UserGetWalletAccountRecordVo; import com.qniao.dam.api.query.walletaccount.user.response.UserGetWalletAccountVo; +import com.qniao.dam.api.query.walletaccount.user.response.WalletAccountRecordExportVo; import com.qniao.dam.domain.aggregate.walletaccount.valueobj.WalletAccountRecord; import com.qniao.dam.domian.aggregate.walletaccount.constant.IdentityTypeEnum; import com.qniao.dam.domian.aggregate.walletaccount.constant.TradeTypeEnum; +import com.qniao.dam.infrastructure.easyexcel.EasyExcelUtil; import com.qniao.dam.infrastructure.persistent.dao.domain.WalletAccountRecordDao; import com.qniao.dam.infrastructure.persistent.dao.view.WalletAccountViewDao; import com.qniao.dam.query.matchmaker.MatchmakerQueryService; @@ -18,13 +20,14 @@ import com.qniao.dam.domain.aggregate.walletaccount.entity.WalletAccount; import com.qniao.dam.infrastructure.persistent.dao.domain.WalletAccountDao; import com.qniao.framework.utils.PageUtil; import com.qniao.framework.utils.TypeConvertUtils; -import com.thoughtworks.xstream.converters.time.LocalDateTimeConverter; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.math.BigDecimal; import java.time.LocalDate; import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; import java.util.Objects; @Service @@ -38,6 +41,8 @@ public class WalletAccountQueryServiceImpl implements WalletAccountQueryService private WalletAccountRecordDao walletAccountRecordDao; @Resource private MatchmakerQueryService matchmakerQueryService; + @Resource + private EasyExcelUtil easyExcelUtil; @Override public WalletAccount queryByUserId(Long userId) { @@ -106,6 +111,35 @@ public class WalletAccountQueryServiceImpl implements WalletAccountQueryService return page; } + @Override + public String exportData(UsePageWalletAccountRecordByOperatorQueryParams queryParams) { + PageUtil pageUtil = new PageUtil(); + pageUtil.setOrders(null); + pageUtil.setPageNum(1); + pageUtil.setPageSize(-1); + IPage page = pageWalletAccountRecordByOperator(pageUtil, queryParams); + List list = transformExport(page.getRecords()); + return easyExcelUtil.writeToFilePath( + easyExcelUtil.getTemplateFileAsStream("walletAccountRecordExport"), + list + ); + } + + private List transformExport(List recordList) { + List list = new ArrayList<>(); + for (UsePageWalletAccountRecordByOperatorVo record : recordList) { + WalletAccountRecordExportVo exportVo = TypeConvertUtils.convert(record, WalletAccountRecordExportVo.class, (rVo, eVo) -> { + if (Objects.nonNull(rVo.getMatchmakerLevel())) { + eVo.setMatchmakerLevelVal(rVo.getMatchmakerLevel().getDesc()); + } + eVo.setTradeTypeVal(rVo.getTradeType().getDesc()); + eVo.setIsIncome(rVo.getIsIncome()?"收入":"支出"); + }); + list.add(exportVo); + } + return list; + } + private BigDecimal countUnavailableWithdrawBalance(Long walletAccountId, LocalDate date, int month) { LocalDateTime dateTime = date.minusMonths(month).withDayOfMonth(1).atStartOfDay(); return walletAccountRecordDao.selectList(new LambdaQueryWrapper() diff --git a/dating-agency-mall-server/src/main/resources/templates/walletAccountRecordExport.xlsx b/dating-agency-mall-server/src/main/resources/templates/walletAccountRecordExport.xlsx new file mode 100644 index 0000000..b265e3a Binary files /dev/null and b/dating-agency-mall-server/src/main/resources/templates/walletAccountRecordExport.xlsx differ