fix: pay
All checks were successful
构建并部署前端到生产环境 / build-and-deploy (push) Successful in 1m0s

This commit is contained in:
sexygoat
2026-05-22 15:16:22 +08:00
parent 874ff41ce3
commit 427b211295
11 changed files with 1458 additions and 738 deletions

View File

@@ -0,0 +1,25 @@
## Why
The front end currently supports WeChat payment and wallet balance payment, but it does not support the new backend Alipay WAP payment-link flow. This prevents users from completing package purchase and wallet recharge scenarios when Alipay is the selected method.
## What Changes
- Add Alipay as a supported payment method in package purchase, order list immediate payment, and wallet recharge flows
- Handle backend `payment_link` responses for Alipay while preserving existing WeChat `pay_config` handling
- Keep wallet balance payment behavior unchanged for package purchase
- Refresh payment-related page state from backend status after the user returns from the Alipay payment link flow
- Preserve current order creation, strong recharge, validation, toast, and list refresh behavior except where Alipay-specific branching is required
## Capabilities
### New Capabilities
- `alipay-payment-link`: Support backend-provided Alipay payment links across package, order, and wallet payment entry points
### Modified Capabilities
## Impact
- Affected code: `pages/package-order/package-order.vue`, `pages/order-list/order-list.vue`, `pages/my-wallet/my-wallet.vue`, `utils/payment.js`, `api/modules/wallet.js`
- Affected UI flows: package payment method popup, order list immediate payment, wallet recharge popup, wallet recharge order immediate payment
- No backend API path changes expected
- Existing WeChat and wallet payment behavior must remain available

View File

@@ -0,0 +1,58 @@
## ADDED Requirements
### Requirement: Package payment SHALL support Alipay payment links
The system SHALL allow users to choose Alipay during package purchase and SHALL handle backend Alipay responses through `payment_link` while preserving the existing WeChat and wallet payment branches.
#### Scenario: User pays a package order with Alipay
- **WHEN** the user selects `alipay` in the package payment popup and the backend returns `payment_method: "alipay"` with `payment_link`
- **THEN** the system SHALL open or present the returned Alipay payment link for the user
- **AND** the system SHALL NOT require WeChat `pay_config` fields for this branch
#### Scenario: User pays a package order with wallet balance
- **WHEN** the user selects `wallet` and the backend completes the package payment without a third-party redirect
- **THEN** the system SHALL preserve the existing wallet payment success flow
- **AND** the system SHALL refresh relevant wallet-related page state after success
#### Scenario: Strong recharge branch returns an Alipay payment link
- **WHEN** package order creation enters the strong recharge branch and the backend returns `order_type: "recharge"` with `payment_link`
- **THEN** the system SHALL use the Alipay payment-link flow for that recharge branch
- **AND** the system SHALL preserve the existing strong recharge messaging and follow-up refresh behavior
### Requirement: Pending order payment SHALL support Alipay payment links
The system SHALL allow users to continue payment for pending package orders from the order list through an Alipay payment link flow.
#### Scenario: User continues a pending order with Alipay
- **WHEN** the user starts payment for a pending order from the order list and the backend returns `payment_method: "alipay"` with `payment_link`
- **THEN** the system SHALL open or present the returned payment link
- **AND** the system SHALL refresh the order list from backend status after the user completes or retries the flow
### Requirement: Wallet recharge flows SHALL support Alipay payment links
The system SHALL support Alipay both when creating a new wallet recharge order and when retrying payment for a pending recharge order.
#### Scenario: User creates a new wallet recharge with Alipay
- **WHEN** the user confirms a wallet recharge with `payment_method: "alipay"` and the backend returns `payment_link`
- **THEN** the system SHALL open or present the returned payment link
- **AND** the system SHALL preserve the existing recharge validation rules and amount checks
#### Scenario: User retries a pending recharge order with Alipay
- **WHEN** the user continues payment for a pending recharge order and the backend returns `payment_link`
- **THEN** the system SHALL open or present the returned Alipay payment link
- **AND** the system SHALL refresh wallet detail and recharge list state from backend data after the user completes or retries the flow
### Requirement: Payment method branching SHALL distinguish WeChat and Alipay contracts
The system SHALL treat WeChat and Alipay payment preparation responses as different contracts and SHALL determine final payment success from backend order or recharge status instead of the redirect result alone.
#### Scenario: WeChat payment returns pay_config
- **WHEN** the backend returns `payment_method: "wechat"` with `pay_config`
- **THEN** the system SHALL continue to use the existing WeChat H5 payment invocation flow
- **AND** the system SHALL preserve the current `app_type` behavior for WeChat requests
#### Scenario: Alipay payment returns payment_link
- **WHEN** the backend returns `payment_method: "alipay"` with `payment_link`
- **THEN** the system SHALL use the returned link fields instead of expecting `pay_config`
- **AND** the system SHALL NOT depend on `app_type` for the Alipay branch
#### Scenario: User returns after Alipay jump
- **WHEN** the user comes back to the application after opening the Alipay payment link
- **THEN** the system SHALL refresh the relevant order or recharge data from backend APIs
- **AND** the system SHALL determine whether the payment succeeded from refreshed backend status

View File

@@ -0,0 +1,29 @@
## 1. Shared Payment Branching
- [ ] 1.1 Add shared front-end handling for Alipay `payment_link` responses alongside the existing WeChat `pay_config` flow
- [ ] 1.2 Ensure Alipay requests do not depend on `app_type` and existing WeChat requests continue to work unchanged
## 2. Package Purchase Flow
- [ ] 2.1 Add Alipay as a selectable payment method in `pages/package-order/package-order.vue`
- [ ] 2.2 Handle normal package order payment responses for `wechat`, `wallet`, and `alipay`
- [ ] 2.3 Handle strong recharge branches that return `payment_link` for Alipay
## 3. Order List Flow
- [ ] 3.1 Add an order-list payment entry that lets the user continue pending orders with Alipay
- [ ] 3.2 Refresh order list state from backend data after the user completes or retries the Alipay flow
## 4. Wallet Flow
- [ ] 4.1 Add Alipay as a selectable payment method in the wallet recharge popup
- [ ] 4.2 Handle Alipay recharge creation responses in `confirmRecharge`
- [ ] 4.3 Handle Alipay payment retries for pending recharge orders in `handleRechargePayment`
- [ ] 4.4 Refresh wallet detail and recharge list state from backend data after the Alipay flow
## 5. Regression Verification
- [ ] 5.1 Verify WeChat package payment still uses `pay_config`
- [ ] 5.2 Verify wallet-balance package payment remains unchanged
- [ ] 5.3 Verify Alipay package payment, order-list payment, wallet recharge, and recharge retry can all open a valid payment link flow
- [ ] 5.4 Verify payment success is determined by refreshed backend status instead of the link jump result