From a4188f41f3bc981fe8fa92c253a1195b76be04dd Mon Sep 17 00:00:00 2001
From: Bang Hu <hu_bang@hotmail.com>
Date: 星期三, 03 九月 2025 16:45:00 +0800
Subject: [PATCH] 交易确认添加积分扣减功能

---
 src/api/pointsApi.ts |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/src/api/pointsApi.ts b/src/api/pointsApi.ts
index 6d8ec43..2cc74b2 100644
--- a/src/api/pointsApi.ts
+++ b/src/api/pointsApi.ts
@@ -89,6 +89,31 @@
       method: 'get',
     }) as ApiPromise
   },
+
+  // 鑾峰彇鐢ㄦ埛绉垎浣欓 - 浣跨敤宸插瓨鍦ㄧ殑鎺ュ彛
+  getUserPoints(userId: number): ApiPromise {
+    return createAxios({
+      url: `${url}total/user/${userId}`,  // 淇敼涓哄疄闄呭瓨鍦ㄧ殑璺緞
+      method: 'get',
+    }) as ApiPromise
+  },
+
+  // 浣跨敤涓撻棬鐨勭Н鍒嗘墸鍑忔帴鍙�
+  deductPointsByFlow(userId: string, unitId: string, points: number, orderId: string, remark?: string, dataCategory?: string): ApiPromise {
+    return createAxios({
+      url: `${url}user/deduct`,  // 浣跨敤鏂扮殑涓撻棬绉垎鎵e噺鎺ュ彛
+      method: 'post',
+      data: {
+        userId,
+        unitId,
+        points,                    // 鐩存帴浼犲叆瑕佹墸鍑忕殑绉垎鏁伴噺
+        orderId,
+        remark: remark || `璁㈠崟${orderId}浜ゆ槗鎵e噺绉垎`,
+        dataCategory: dataCategory || 'resource_transaction',
+        dataType: 1               // 1琛ㄧず娑堣��
+      },
+    }) as ApiPromise
+  },
 }
 
 export default pointsApi

--
Gitblit v1.8.0