This commit is contained in:
dzc committed 2026-08-31 11:29:36 +08:00
1 parent 93dc377bb1
commit 34d1e25760
6 files changed
+58 -69

No files matched your search

@@ -15,7 +15,7 @@ import java.math.BigDecimal;
* 批量充值扣款水单导出行,按用户、身份、审批和金额组织二级表头。
*
* <p>用户与身份资料由 UPMS 完整导出接口按批补齐,金额统一转换为元;扣款和食堂退还场景保持负数,
* 以便财务人员直接汇总。</p>
* 以便财务人员直接汇总。业务类型仅参与后台金额方向计算,不写入财务导出工作簿。</p>
*/
@Data
@EqualsAndHashCode(callSuper = true)
@@ -33,39 +33,35 @@ public class WalletRechargeImportExportExcelVo extends WalletUserExportExcelVo {
@ExcelProperty(value = {"水单", "业务月份"}, index = 11)
private String importMonth;
/** 批量处理业务类型中文名称;未知历史编码保留原值。 */
@ExcelProperty(value = {"水单", "业务类型"}, index = 12)
private String bizTypeName;
/** 钱包类型中文名称;类型资料缺失时为空。 */
@ExcelProperty(value = {"钱包", "钱包类型"}, index = 13)
@ExcelProperty(value = {"钱包", "钱包类型"}, index = 12)
private String walletTypeName;
/** 操作前钱包金额,单位为元并保留两位小数。 */
@ExcelProperty(value = {"金额", "操作前金额(元)"}, index = 14)
@ExcelProperty(value = {"金额", "操作前金额(元)"}, index = 13)
@NumberFormat("#,##0.00")
private BigDecimal beforePrice;
/** 本次操作金额,单位为元并保留两位小数;扣款和退还场景为负数。 */
@ExcelProperty(value = {"金额", "操作金额(元)"}, index = 15)
@ExcelProperty(value = {"金额", "操作金额(元)"}, index = 14)
@NumberFormat("#,##0.00")
private BigDecimal price;
/** 财务统计标签原始字典值,多个值使用英文逗号分隔。 */
@ExcelProperty(value = {"水单", "财务标签"}, index = 16)
@ExcelProperty(value = {"水单", "财务标签"}, index = 15)
private String tags;
/** 审批流程状态原始字典值,便于与管理端字典核对。 */
@ExcelProperty(value = {"审批", "审批状态"}, index = 17)
@ExcelProperty(value = {"审批", "审批状态"}, index = 16)
private String processStatus;
/** 审批处理时间,格式为 yyyy-MM-dd HH:mm:ss。 */
@ExcelProperty(value = {"审批", "审批时间"}, index = 18)
@ExcelProperty(value = {"审批", "审批时间"}, index = 17)
@ColumnWidth(22)
private String processTime;
/** 水单明细创建时间,格式为 yyyy-MM-dd HH:mm:ss。 */
@ExcelProperty(value = {"水单", "创建时间"}, index = 19)
@ExcelProperty(value = {"水单", "创建时间"}, index = 18)
@ColumnWidth(22)
private String createTime;
}
@@ -15,6 +15,6 @@ import lombok.EqualsAndHashCode;
public class WalletRechargePersonExportExcelVo extends WalletTransactionExportExcelVo {
/** 流水所属食堂名称,来源于钱包商户部门视图;无法匹配时为空。 */
@ExcelProperty(value = {"食堂", "所属食堂"}, index = 20)
@ExcelProperty(value = {"食堂", "所属食堂"}, index = 19)
private String canteenName;
}
@@ -14,8 +14,8 @@ import java.math.BigDecimal;
/**
* 钱包流水导出行,按用户、身份、钱包和流水业务域组织二级表头。
*
* <p>充值、记账扣款、消费、退款、食堂退还及个人充值统计共用该结构;金额统一以元展示,
* 未识别的历史业务编码保留原值,避免导出过程丢失业务信息。</p>
* <p>全部流水、充值、记账扣款、消费、退款、食堂退还及个人充值统计共用该结构;金额统一以元展示。
* 业务类型仅用于页面查询和列表展示,不写入财务导出工作簿。</p>
*/
@Data
@EqualsAndHashCode(callSuper = true)
@@ -37,35 +37,31 @@ public class WalletTransactionExportExcelVo extends WalletUserExportExcelVo {
@ExcelProperty(value = {"钱包", "卡号"}, index = 12)
private String cardNumber;
/** 流水业务类型中文名称;未知历史编码保留原值。 */
@ExcelProperty(value = {"流水", "业务类型"}, index = 13)
private String bizTypeName;
/** 流水业务标题,来源于交易发生时保存的标题快照。 */
@ExcelProperty(value = {"流水", "标题"}, index = 14)
@ExcelProperty(value = {"流水", "标题"}, index = 13)
private String title;
/** 本次交易金额,单位为元并保留两位小数,支出保留负数。 */
@ExcelProperty(value = {"流水", "交易金额(元)"}, index = 15)
@ExcelProperty(value = {"流水", "交易金额(元)"}, index = 14)
@NumberFormat("#,##0.00")
private BigDecimal price;
/** 交易完成后的钱包余额,单位为元并保留两位小数。 */
@ExcelProperty(value = {"流水", "交易后余额(元)"}, index = 16)
@ExcelProperty(value = {"流水", "交易后余额(元)"}, index = 15)
@NumberFormat("#,##0.00")
private BigDecimal balance;
/** 财务统计标签原始字典值,多个值使用英文逗号分隔。 */
@ExcelProperty(value = {"流水", "财务标签"}, index = 17)
@ExcelProperty(value = {"流水", "财务标签"}, index = 16)
private String tags;
/** 后台补充的流水业务备注;历史记录允许为空。 */
@ExcelProperty(value = {"流水", "备注"}, index = 18)
@ExcelProperty(value = {"流水", "备注"}, index = 17)
@ColumnWidth(24)
private String remark;
/** 流水创建时间,格式为 yyyy-MM-dd HH:mm:ss。 */
@ExcelProperty(value = {"流水", "交易时间"}, index = 19)
@ExcelProperty(value = {"流水", "交易时间"}, index = 18)
@ColumnWidth(22)
private String createTime;
}
@@ -286,6 +286,21 @@ public class WalletTransactionController {
return R.ok(walletTransactionService.scopePageList(page, dto, dataScope));
}
/**
* 按页面筛选条件分页查询当前操作者数据权限范围内的全部类型钱包流水。
*
* @param page 分页参数
* @param dto 用户、部门、身份、收支方向、交易类型、标签和时间等筛选条件
* @return 当前数据权限范围内的钱包流水分页
*/
@Operation(summary = "后台全部钱包流水分页", description = "按数据权限查询全部类型的钱包流水")
@PostMapping("/page-all")
@PreAuthorize("@pms.hasPermission('wallet_walletTransaction_view')")
public R<Page<WalletTransactionVo>> pageAll(@ParameterObject Page<WalletTransactionVo> page,
@RequestBody WalletTransactionDto dto) {
return R.ok(walletTransactionService.scopePageList(page, dto, DataScope.of()));
}
@Operation(summary = "分页查询复杂查询", description = "分页查询复杂查询")
@GetMapping("/page-join")
@@ -360,6 +375,19 @@ public class WalletTransactionController {
"充值记录导出任务已提交");
}
/**
* 提交全部类型钱包流水异步分片导出任务,沿用页面交易类型和收支方向筛选条件。
*
* @param dto 页面当前用户、部门、身份、收支方向、交易类型、标签和时间等筛选条件
* @return 包含任务编号和初始进度的统一响应
*/
@PostMapping("/export-all-async")
@PreAuthorize("@pms.hasPermission('wallet_walletTransaction_export')")
public R<AsyncTaskProgressVO> submitAllExport(@RequestBody WalletTransactionDto dto) {
return R.ok(walletUserExportService.submitTransactionExport(dto, WalletTransactionExportScene.ALL),
"钱包流水导出任务已提交");
}
@Operation(summary = "充值统计", description = "充值统计")
@PostMapping("/cz-total")
public R<WalletTypeTotalVo> czTotal(@RequestBody WalletTransactionDto dto) {
@@ -13,6 +13,9 @@ import java.util.List;
*/
public enum WalletTransactionExportScene {
/** 全部类型钱包流水,保留页面传入的交易类型和收支方向筛选条件。 */
ALL("wallet:user:export:all-transaction", "钱包流水导出", "钱包流水", List.of(), null, false),
/** 个人充值明细,限定充值类业务和正向收入流水。 */
RECHARGE("wallet:user:export:cz", "充值记录导出", "充值记录", List.copyOf(WalletBizEnum.getTopUpCodes()),
WalletTransactionDto.TYPE_INCOME, false),
@@ -46,7 +49,7 @@ public enum WalletTransactionExportScene {
/** 导出文件和工作表使用的业务名称,不包含时间戳和扩展名。 */
private final String fileNamePrefix;
/** 当前场景允许查询的钱包流水业务编码集合。 */
/** 当前场景固定的钱包流水业务编码集合;空集合表示保留页面传入的交易类型条件。 */
private final List<String> bizTypes;
/** 收支方向编码;为空表示不额外限制金额正负。 */
@@ -61,7 +64,7 @@ public enum WalletTransactionExportScene {
* @param redisKey 前端进度轮询使用的固定命名空间
* @param taskName 异步任务展示名称
* @param fileNamePrefix 导出文件和工作表业务名称
* @param bizTypes 钱包流水业务编码集合
* @param bizTypes 固定的钱包流水业务编码集合;空集合表示不覆盖页面交易类型条件
* @param transactionType 收支方向编码,允许为空
* @param findOrder 是否解析关联订单号
*/
@@ -90,7 +93,7 @@ public enum WalletTransactionExportScene {
return fileNamePrefix;
}
/** @return 当前场景允许查询的钱包流水业务编码集合 */
/** @return 当前场景固定的钱包流水业务编码集合;空集合表示不覆盖页面交易类型条件 */
public List<String> getBizTypes() {
return bizTypes;
}
@@ -21,7 +21,6 @@ import com.bsd.pjcloud.common.core.constant.enums.MerchantTypeEnum;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.common.excel.stream.BatchExcelExportTemplate;
import com.bsd.pjcloud.wallet.api.constant.WalletBizEnum;
import com.bsd.pjcloud.wallet.api.constant.WalletBizRechargeEnum;
import com.bsd.pjcloud.wallet.api.dto.WalletActiveDto;
import com.bsd.pjcloud.wallet.api.dto.WalletManageBalanceDto;
@@ -721,7 +720,6 @@ public class WalletUserExportServiceImpl implements WalletUserExportService {
row.setLineNumber(Long.toString(lineNumber));
row.setWalletTypeName(source.getWalletTypeName());
row.setCardNumber(source.getWalletCardNumber());
row.setBizTypeName(resolveTransactionBizType(source.getBizType()));
row.setTitle(source.getTitle());
row.setPrice(formatPrice(source.getPrice()));
row.setBalance(formatPrice(source.getBalance()));
@@ -804,7 +802,6 @@ public class WalletUserExportServiceImpl implements WalletUserExportService {
source.getTeacherInfo());
row.setLineNumber(Long.toString(startIndex + rows.size() + 1L));
row.setImportMonth(source.getImportTime() == null ? null : source.getImportTime().toString().substring(0, 7));
row.setBizTypeName(resolveRechargeBizType(source.getBizType()));
row.setWalletTypeName(source.getWalletTypeName());
row.setBeforePrice(formatPrice(source.getBeforePrice()));
row.setPrice(formatPrice(normalizeRechargeImportPrice(source.getPrice(), source.getBizType())));
@@ -925,42 +922,6 @@ public class WalletUserExportServiceImpl implements WalletUserExportService {
}).filter(StrUtil::isNotBlank).collect(Collectors.joining(","));
}
/**
* 将钱包流水业务编码安全转换为中文名称。
*
* @param bizType 数据库保存的钱包流水业务编码
* @return 中文名称,未知历史编码原样保留
*/
private String resolveTransactionBizType(String bizType) {
if (StrUtil.isBlank(bizType)) {
return bizType;
}
for (WalletBizEnum value : WalletBizEnum.values()) {
if (Objects.equals(value.getCode(), bizType)) {
return value.getDesc();
}
}
return bizType;
}
/**
* 将批量充值扣款业务编码安全转换为中文名称。
*
* @param bizType 充值申请保存的业务编码
* @return 中文名称,未知历史编码原样保留
*/
private String resolveRechargeBizType(String bizType) {
if (StrUtil.isBlank(bizType)) {
return bizType;
}
for (WalletBizRechargeEnum value : WalletBizRechargeEnum.values()) {
if (Objects.equals(value.getCode(), bizType)) {
return value.getDesc();
}
}
return bizType;
}
/**
* 保持旧水单导出的扣款负数语义。
*
@@ -1021,8 +982,13 @@ public class WalletUserExportServiceImpl implements WalletUserExportService {
*/
private WalletTransactionDto prepareTransactionQuery(WalletTransactionDto query,
WalletTransactionExportScene scene) {
query.setBizTypes(new ArrayList<>(scene.getBizTypes()));
query.setType(scene.getTransactionType());
// 全部流水场景必须保留页面传入的交易类型和收支方向,其余场景继续沿用原有服务端固定口径。
if (!scene.getBizTypes().isEmpty()) {
query.setBizTypes(new ArrayList<>(scene.getBizTypes()));
}
if (scene != WalletTransactionExportScene.ALL) {
query.setType(scene.getTransactionType());
}
query.setIsFindOrder(scene.isFindOrder());
if (scene == WalletTransactionExportScene.RECHARGE_PERSON_TOTAL) {
prepareRechargePersonPriceQuery(query);