From c133169c7b9c00000abd1087cc1f681a5119d0bd Mon Sep 17 00:00:00 2001 From: Rogee Date: Wed, 31 Dec 2025 12:19:01 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E5=92=8C=E7=94=A8=E6=88=B7=E8=A7=86=E5=9B=BE=EF=BC=8C=E5=A2=9E?= =?UTF-8?q?=E5=BC=BA=E8=AE=A2=E5=8D=95=E4=BF=A1=E6=81=AF=E5=B1=95=E7=A4=BA?= =?UTF-8?q?=EF=BC=8C=E6=94=AF=E6=8C=81=E5=85=85=E5=80=BC=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E8=AE=A2=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/http/v1/dto/user.go | 23 ++-- backend/app/services/order.go | 13 +- .../portal/src/views/order/DetailView.vue | 120 +++++++++++------- .../portal/src/views/user/DashboardView.vue | 59 ++++++--- frontend/portal/src/views/user/OrdersView.vue | 51 ++++---- 5 files changed, 161 insertions(+), 105 deletions(-) diff --git a/backend/app/http/v1/dto/user.go b/backend/app/http/v1/dto/user.go index 24d3afb..7b2da6f 100644 --- a/backend/app/http/v1/dto/user.go +++ b/backend/app/http/v1/dto/user.go @@ -40,16 +40,19 @@ type RechargeResponse struct { } type Order struct { - ID string `json:"id"` - CreateTime string `json:"create_time"` - PayTime string `json:"pay_time"` - Status string `json:"status"` - Amount float64 `json:"amount"` - Quantity int `json:"quantity"` - Items []ContentItem `json:"items"` - TenantID string `json:"tenant_id"` - TenantName string `json:"tenant_name"` - IsVirtual bool `json:"is_virtual"` + ID string `json:"id"` + Type string `json:"type"` // consts.OrderType... + TypeDescription string `json:"type_description"` + CreateTime string `json:"create_time"` + PayTime string `json:"pay_time"` + Status string `json:"status"` + StatusDescription string `json:"status_description"` + Amount float64 `json:"amount"` + Quantity int `json:"quantity"` + Items []ContentItem `json:"items"` + TenantID string `json:"tenant_id"` + TenantName string `json:"tenant_name"` + IsVirtual bool `json:"is_virtual"` } type Notification struct { diff --git a/backend/app/services/order.go b/backend/app/services/order.go index 7d09444..5a9ce33 100644 --- a/backend/app/services/order.go +++ b/backend/app/services/order.go @@ -353,11 +353,14 @@ func (s *order) Status(ctx context.Context, id string) (*transaction_dto.OrderSt func (s *order) composeOrderDTO(ctx context.Context, o *models.Order) (user_dto.Order, error) { dto := user_dto.Order{ - ID: cast.ToString(o.ID), - Status: string(o.Status), - Amount: float64(o.AmountPaid) / 100.0, - CreateTime: o.CreatedAt.Format(time.RFC3339), - TenantID: cast.ToString(o.TenantID), + ID: cast.ToString(o.ID), + Type: string(o.Type), + TypeDescription: o.Type.Description(), + Status: string(o.Status), + StatusDescription: o.Status.Description(), + Amount: float64(o.AmountPaid) / 100.0, + CreateTime: o.CreatedAt.Format(time.RFC3339), + TenantID: cast.ToString(o.TenantID), } // Fetch Tenant Name diff --git a/frontend/portal/src/views/order/DetailView.vue b/frontend/portal/src/views/order/DetailView.vue index 31e761d..6e9581d 100644 --- a/frontend/portal/src/views/order/DetailView.vue +++ b/frontend/portal/src/views/order/DetailView.vue @@ -10,8 +10,9 @@

订单号: {{ order.id }}

- 交易成功 - 待支付 + + {{ order.status_description }} +
@@ -29,22 +30,22 @@
提交订单
-
{{ order.createTime }}
+
{{ order.create_time }}
-
+
-
付款成功
-
{{ order.payTime }}
+
付款成功
+
{{ order.pay_time }}
-
{{ order.isVirtual ? '自动发货' : '商家发货' }}
+
{{ order.is_virtual ? '自动发货' : '商家发货' }}
@@ -61,18 +62,38 @@
-
-
商品信息
-
- -
-

{{ order.title }}

-
{{ order.sku || '默认规格' }}
-
虚拟商品
+
+
+ {{ order.type === 'recharge' ? '服务信息' : '商品信息' }} +
+ + +
+
+
-
-
¥ {{ order.price }}
-
x {{ order.quantity }}
+
+

账户余额充值

+
充值金额将会即时到账
+
+
+
¥ {{ order.amount }}
+
+
+ + +
+
+ +
+

{{ item.title }}

+
{{ item.sku || '默认规格' }}
+
虚拟商品
+
+
+
¥ {{ item.price }}
+ +
@@ -81,16 +102,12 @@
商品总额 - ¥ {{ (order.price * order.quantity).toFixed(2) }} + ¥ {{ order.amount }}
运费 ¥ 0.00
-
- 优惠券 - - ¥ 0.00 -
实付金额 ¥ {{ order.amount }} @@ -108,12 +125,12 @@

订单信息

订单编号: {{ order.id }}

-

创建时间: {{ order.createTime }}

-

付款时间: {{ order.payTime }}

+

创建时间: {{ order.create_time }}

+

付款时间: {{ order.pay_time }}

-
+

收货信息

张三 138****8888

@@ -123,13 +140,13 @@
-
+

商家信息

- +
-
{{ order.tenantName }}
+
{{ order.tenant_name }}
@@ -142,32 +159,41 @@ \ No newline at end of file diff --git a/frontend/portal/src/views/user/DashboardView.vue b/frontend/portal/src/views/user/DashboardView.vue index 2385bf1..3111616 100644 --- a/frontend/portal/src/views/user/DashboardView.vue +++ b/frontend/portal/src/views/user/DashboardView.vue @@ -50,19 +50,24 @@
-
- + + +

- {{ order.items && order.items.length > 0 ? order.items[0].title : '未知商品' }}

+ {{ (order.type === 'recharge' || !order.items?.length) ? '账户充值' : (order.items?.[0]?.title || '未知商品') }} +
{{ order.create_time }} · 订单号: {{ order.id }}
¥ {{ order.amount }}
-
{{ order.status }}
+
{{ order.status_description }}
暂无订单
@@ -90,22 +95,38 @@ const wallet = ref({ balance: 0, points: 0 }); const couponCount = ref(0); const recentOrders = ref([]); +const statusColor = (status) => { + const map = { + created: 'text-orange-600', + paid: 'text-blue-600', + completed: 'text-green-600', + refunding: 'text-purple-600', + refunded: 'text-slate-500', + cancelled: 'text-slate-400' + }; + return map[status] || 'text-slate-500'; +}; + const fetchData = async () => { - try { - const w = await userApi.getWallet(); - wallet.value.balance = w.balance || 0; - - const u = await userApi.getMe(); - wallet.value.points = u.points || 0; - - const c = await userApi.getCoupons('unused'); - couponCount.value = c.length; - - const o = await userApi.getOrders('all'); - recentOrders.value = (o || []).slice(0, 3); - } catch (e) { - console.error(e); - } + // Fetch Wallet + userApi.getWallet() + .then(w => { wallet.value.balance = w.balance || 0; }) + .catch(e => console.error("Wallet fetch failed:", e)); + + // Fetch User Info (Points) + userApi.getMe() + .then(u => { wallet.value.points = u.points || 0; }) + .catch(e => console.error("Me fetch failed:", e)); + + // Fetch Coupons + userApi.getCoupons('unused') + .then(c => { couponCount.value = (c || []).length; }) + .catch(e => console.error("Coupons fetch failed:", e)); + + // Fetch Recent Orders + userApi.getOrders('all') + .then(o => { recentOrders.value = (o || []).slice(0, 3); }) + .catch(e => console.error("Orders fetch failed:", e)); }; onMounted(() => { diff --git a/frontend/portal/src/views/user/OrdersView.vue b/frontend/portal/src/views/user/OrdersView.vue index 8e8e4f1..7a31bce 100644 --- a/frontend/portal/src/views/user/OrdersView.vue +++ b/frontend/portal/src/views/user/OrdersView.vue @@ -32,25 +32,40 @@
- {{ order.date }} + {{ order.create_time }} 订单号: {{ order.id }} - {{ order.tenantName }} + {{ order.tenant_name }} + 平台自营
-
{{ statusText(order.status) }}
+
{{ order.status_description }}
-
- -
+
+ + +
-

{{ order.title }}

-
{{ order.typeLabel }}
-
虚拟发货
+

+ {{ (order.type === 'recharge' || !order.items?.length) ? '账户充值' : (order.items?.[0]?.title || '未知商品') }} +

+
+ {{ (order.type === 'recharge' || !order.items?.length) ? '在线充值' : (order.items?.[0]?.genre || '数字内容') }} +
+
+ {{ (order.type === 'recharge' || !order.items?.length) ? '即时到账' : '虚拟发货' }} +
@@ -61,10 +76,10 @@
在线支付
- + 查看详情 - - + +
@@ -124,18 +139,6 @@ watch(currentTab, () => { // Use orders directly (filtered by backend) const filteredOrders = computed(() => orders.value); -const statusText = (status) => { - const map = { - created: '待支付', - paid: '已支付', - completed: '交易成功', - refunding: '退款中', - refunded: '已退款', - cancelled: '已取消' - }; - return map[status] || status; -}; - const statusColor = (status) => { const map = { created: 'text-orange-600',