p-honggang.li
5 天以前 80ca024e9ae633df0dc9f4e8f533f33b526afb3d
src/api/pointsApi.ts
@@ -27,7 +27,7 @@
  // 保存积分规则配置
  savePointsRules(data: object): ApiPromise {
    return createAxios({
      url: `${url}rules/update`,
      url: `${url}rule/update`,
      data: data,
    }) as ApiPromise
  },
@@ -89,6 +89,32 @@
      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, providerId?: 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表示消耗
        providerId: providerId
      },
    }) as ApiPromise
  },
}
export default pointsApi