feat: 新增退款凭证
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 4m27s

This commit is contained in:
sexygoat
2026-05-27 14:58:37 +08:00
parent fe0093972f
commit 6654972ddb
14 changed files with 521 additions and 47 deletions

View File

@@ -0,0 +1,20 @@
# Change: Update Refund Voucher Multi Image Behavior
## Why
退款管理需要更清晰地展示退款凭证,并支持一次退款记录关联多张凭证图片,便于财务核验。创建退款申请选择订单时也应只允许选择已支付订单,避免对未支付订单发起退款。
## What Changes
- 退款详情中直接展示退款凭证图片,点击图片后可放大预览。
- 创建退款申请的订单号搜索/选择请求必须增加 `payment_status: 2` 条件。
- 退款管理凭证上传支持多张图片,并将所有上传后的文件 key 以英文逗号拼接后放入 `refund_voucher_key` 参数。
## Impact
- Affected specs: `order-management`
- Affected code:
- Refund detail voucher display and image preview behavior
- Create refund request order selector query params
- Refund management voucher upload component and submit payload
- Breaking changes: Refund voucher payload field for this flow remains `refund_voucher_key` and supports one or more uploaded image keys separated by English commas.

View File

@@ -0,0 +1,109 @@
## ADDED Requirements
### Requirement: Refund Detail Inline Voucher Preview
The system SHALL display refund voucher images directly in the refund detail page when voucher file keys exist, and each displayed image SHALL support click-to-enlarge preview. Refund voucher viewing from the refund list SHALL be controlled by the permission code `refund:view_voucher`.
#### Scenario: Display and enlarge refund voucher in detail
- **GIVEN** 用户打开退款详情页
- **AND** 退款详情数据包含一个或多个退款凭证文件 key
- **WHEN** 页面渲染退款凭证区域
- **THEN** 系统 MUST 直接展示对应的凭证图片
- **AND** 用户点击任一凭证图片后,系统 MUST 放大预览该图片
#### Scenario: Hide voucher images when no voucher exists
- **GIVEN** 用户打开退款详情页
- **WHEN** 退款详情数据不包含退款凭证文件 key
- **THEN** 系统 MUST NOT 展示空的凭证图片占位
- **AND** 系统 MAY display `-` or equivalent empty-state text for the voucher field
#### Scenario: Show refund voucher list action with permission
- **GIVEN** 用户正在查看退款管理列表
- **AND** 某条退款记录存在 `refund_voucher_key`
- **AND** 当前用户拥有 `refund:view_voucher` 权限编码
- **WHEN** 系统渲染该行操作列
- **THEN** 系统 MUST show the `查看退款凭证` action
#### Scenario: Hide refund voucher list action without permission
- **GIVEN** 用户正在查看退款管理列表
- **AND** 某条退款记录存在 `refund_voucher_key`
- **AND** 当前用户不拥有 `refund:view_voucher` 权限编码
- **WHEN** 系统渲染该行操作列
- **THEN** 系统 MUST NOT show the `查看退款凭证` action
### Requirement: Refund Application Paid Order Filtering
The system SHALL restrict the order number search/select request in create refund application to paid orders by including `payment_status: 2` in the query parameters.
#### Scenario: Search selectable orders for refund application
- **GIVEN** 用户正在创建退款申请
- **WHEN** 用户通过订单号搜索/选择订单
- **THEN** 系统 MUST call the order search/list API with `payment_status: 2`
- **AND** 未支付、已取消或其他非已支付状态订单 MUST NOT be returned as selectable refund orders by the frontend query
### Requirement: Refund Application Zero Amount
The system SHALL allow the requested refund amount in create refund application to be `0`, while still preventing negative amounts and amounts greater than the actual received amount.
#### Scenario: Submit zero requested refund amount
- **GIVEN** 用户正在创建退款申请
- **AND** 用户已选择可退款订单
- **WHEN** 用户输入申请退款金额 `0`
- **THEN** 系统 MUST allow the amount validation to pass
- **AND** 系统 MUST submit `requested_refund_amount` as `0`
#### Scenario: Block negative requested refund amount
- **GIVEN** 用户正在创建退款申请
- **WHEN** 用户输入小于 `0` 的申请退款金额
- **THEN** 系统 MUST prevent submission
- **AND** 系统 MUST 提示申请退款金额不能小于 `0`
#### Scenario: Block requested refund amount above actual received amount
- **GIVEN** 用户正在创建退款申请
- **AND** 已选订单存在实收金额
- **WHEN** 用户输入的申请退款金额大于实收金额
- **THEN** 系统 MUST prevent submission
- **AND** 系统 MUST 提示申请退款金额不能大于实收金额
### Requirement: Refund Management Multi Image Voucher Upload
The system SHALL allow multiple refund voucher images in any browser-recognized image format to be uploaded in refund management and SHALL submit all uploaded file keys in the `refund_voucher_key` parameter as a comma-separated string.
#### Scenario: Submit multiple uploaded voucher images
- **GIVEN** 用户正在退款管理中创建或提交退款相关记录
- **AND** 用户上传了多张退款凭证图片
- **WHEN** 每张图片上传成功并返回文件 key
- **AND** 用户提交表单
- **THEN** 系统 MUST join the uploaded file keys with English commas
- **AND** 系统 MUST put the joined string into `refund_voucher_key`
- **AND** `refund_voucher_key` MUST look like `attachments/a.jpg,attachments/b.jpg` when multiple files exist
#### Scenario: Upload any image format refund voucher without frontend size limit
- **GIVEN** 用户正在创建退款申请
- **WHEN** 用户选择或拖入任意浏览器识别为图片类型的退款凭证
- **THEN** 系统 MUST NOT reject the file based on frontend file size checks
- **AND** 系统 MUST accept the file when its MIME type starts with `image/`
#### Scenario: Submit single uploaded voucher image
- **GIVEN** 用户正在退款管理中创建或提交退款相关记录
- **AND** 用户只上传了一张退款凭证图片
- **WHEN** 用户提交表单
- **THEN** 系统 MUST put that single file key into `refund_voucher_key` without a trailing comma
#### Scenario: Block submission without required voucher image
- **GIVEN** 退款管理表单要求上传退款凭证
- **WHEN** 用户未上传任何凭证图片并尝试提交
- **THEN** 系统 MUST prevent submission
- **AND** 系统 MUST 提示用户上传退款凭证

View File

@@ -0,0 +1,10 @@
## 1. Implementation
- [x] 1.1 Update refund detail to render voucher images inline when voucher keys exist.
- [x] 1.2 Add click-to-preview/enlarge behavior for refund detail voucher images.
- [x] 1.3 Add `payment_status: 2` to the order number search/select request used by create refund application.
- [x] 1.4 Update refund management voucher upload to allow multiple image uploads.
- [x] 1.5 Submit uploaded voucher file keys joined by English commas in `refund_voucher_key`.
- [x] 1.6 Validate that at least one voucher image is uploaded before submission when voucher is required.
- [x] 1.7 Verify refund detail display, order selector filtering, and multi-image payload behavior.
- [x] 1.8 Allow requested refund amount `0` while blocking negative and over-actual amounts.