p-honggang.li
2025-09-03 f053c272d7a555f6e58ec9f90ec9bb97cef5b3cb
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`,  // 使用新的专门积分扣减接口
      method: 'post',
      data: {
        userId,
        unitId,
        points,                    // 直接传入要扣减的积分数量
        orderId,
        remark: remark || `订单${orderId}交易扣减积分`,
        dataCategory: dataCategory || 'resource_transaction',
        dataType: 1               // 1表示消耗
      },
    }) as ApiPromise
  },
}
export default pointsApi