1.8 KiB
1.8 KiB
I will optimize the registration and payment flow with the specific requirement to record the actual payment amount.
1. Backend Updates (main.py)
- Database Schema: Add
out_trade_nocolumn togsdh_datato link users with payment orders. - Pre-payment Validation:
- Update
create_payment(H5) andcreate_native_payment. - Check if phone exists in
gsdh_data. - Logic:
- If
feehas a valid amount (not empty, '0', or 'PENDING'), reject as "Already Registered". - If
feeis empty/PENDING, allow payment.
- If
- Upsert user with
fee= 'PENDING' andpayment_channel= '..._pending'.
- Update
- Payment Status Sync:
- Update
check_payment_status:- When WeChat returns
SUCCESS:- Update
feeto the actual configured payment amount (e.g., "0.01"). - Update
payment_channelto the final channel (removing '_pending'). - Update
out_trade_nologic to ensure we find the correct user.
- Update
- When WeChat returns
- Update
2. Frontend Optimization (templates/ticket.html)
- Dynamic Form Fields:
- Replace hardcoded inputs with a loop that renders fields based on
config.field_config(managed in Admin). - Respect "Show", "Required", and "Label" settings.
- Replace hardcoded inputs with a loop that renders fields based on
- QR Code Modal:
- Add explicit text: "请使用微信扫一扫完成支付" (Please use WeChat Scan to pay).
- Optimize layout.
- Payment Logic:
- Handle "Already Registered" error.
- Redirect to Success Page on completion.
3. New Success Page
- Create
templates/success.htmlto show a "Registration Successful" message. - Add route in
main.py.
4. Admin Interface
- Verify
templates/admin.htmlfield configuration works with the newticket.htmldynamic rendering.
This ensures that successful payments overwrite the 'PENDING' status with the actual amount paid.