修改订单号规则,增加支付统计列表用户信息展示
This commit is contained in:
@@ -70,6 +70,7 @@ const AdminPaymentStats: React.FC = () => {
|
||||
|
||||
const columns = [
|
||||
{ title: '订单号', dataIndex: 'orderNo', key: 'orderNo', width: 200 },
|
||||
{ title: '用户', dataIndex: 'username', key: 'username', width: 120 },
|
||||
{
|
||||
title: '支付方式', dataIndex: 'paymentMethod', key: 'paymentMethod', width: 100,
|
||||
render: (m: string) => {
|
||||
|
||||
@@ -128,7 +128,7 @@ export interface PaymentOrder {
|
||||
id: string;
|
||||
orderNo: string;
|
||||
userId: string;
|
||||
user?: { username: string };
|
||||
username?: string;
|
||||
amount: number;
|
||||
credits: number;
|
||||
paymentMethod: string;
|
||||
|
||||
@@ -543,12 +543,13 @@ async def get_payment_stats(
|
||||
recent_filters.append(PaymentOrder.created_at < query_end)
|
||||
|
||||
recent_result = await db.execute(
|
||||
select(PaymentOrder)
|
||||
select(PaymentOrder, User)
|
||||
.join(User, PaymentOrder.user_id == User.id)
|
||||
.where(*recent_filters)
|
||||
.order_by(PaymentOrder.created_at.desc())
|
||||
.limit(50)
|
||||
)
|
||||
recent = recent_result.scalars().all()
|
||||
recent_data = recent_result.all()
|
||||
|
||||
return {
|
||||
"by_status": by_status,
|
||||
@@ -565,6 +566,7 @@ async def get_payment_stats(
|
||||
"id": o.id,
|
||||
"order_no": o.order_no,
|
||||
"user_id": o.user_id,
|
||||
"username": u.username,
|
||||
"amount": round(o.amount, 2),
|
||||
"credits": round(o.credits, 2),
|
||||
"payment_method": o.payment_method,
|
||||
@@ -573,7 +575,7 @@ async def get_payment_stats(
|
||||
"paid_at": _iso(o.paid_at),
|
||||
"created_at": _iso(o.created_at),
|
||||
}
|
||||
for o in recent
|
||||
for o, u in recent_data
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import time
|
||||
import random
|
||||
from datetime import datetime
|
||||
import uuid
|
||||
|
||||
|
||||
def generate_id() -> str:
|
||||
@@ -10,7 +12,10 @@ def generate_id() -> str:
|
||||
|
||||
|
||||
def generate_order_no() -> str:
|
||||
"""Generate a human-readable order number."""
|
||||
timestamp = int(time.time())
|
||||
randomness = random.randint(1000, 9999)
|
||||
return f"VG{timestamp}{randomness}"
|
||||
"""Generate a human-readable order number with yyyymmddhhmmss format."""
|
||||
# 格式化为 yyyymmddhhmmss 格式的时间戳
|
||||
now = datetime.now()
|
||||
timestamp = now.strftime("%Y%m%d%H%M%S")
|
||||
# 使用 UUID 的部分值来生成更可靠的随机数,防止并发冲突
|
||||
random_part = uuid.uuid4().hex[:8].upper()
|
||||
return f"MZZC{timestamp}{random_part}"
|
||||
|
||||
Reference in New Issue
Block a user