@gt6/sdk 1.0.12 → 1.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/gt6-sdk.cjs.js +103 -0
- package/dist/gt6-sdk.cjs.js.map +1 -1
- package/dist/gt6-sdk.esm.js +103 -0
- package/dist/gt6-sdk.esm.js.map +1 -1
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/modules/users.d.ts +48 -0
- package/dist/modules/users.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/gt6-sdk.cjs.js
CHANGED
@@ -1081,6 +1081,97 @@ class UsersAPI {
|
|
1081
1081
|
const result = await this.getUserFunds();
|
1082
1082
|
return result.success ? result.fund : null;
|
1083
1083
|
}
|
1084
|
+
/**
|
1085
|
+
* 获取用户支付记录列表
|
1086
|
+
* @param options 查询选项
|
1087
|
+
* @returns 支付记录列表响应
|
1088
|
+
*/
|
1089
|
+
async getPaymentRecords(options) {
|
1090
|
+
try {
|
1091
|
+
// 获取用户token
|
1092
|
+
const token = this.getToken();
|
1093
|
+
if (!token) {
|
1094
|
+
return {
|
1095
|
+
success: false,
|
1096
|
+
records: [],
|
1097
|
+
total: 0,
|
1098
|
+
page: options?.page || 1,
|
1099
|
+
pageSize: options?.pageSize || 10,
|
1100
|
+
message: '用户未登录'
|
1101
|
+
};
|
1102
|
+
}
|
1103
|
+
// 构建查询参数
|
1104
|
+
const params = new URLSearchParams();
|
1105
|
+
if (options?.page)
|
1106
|
+
params.set('page', options.page.toString());
|
1107
|
+
if (options?.pageSize)
|
1108
|
+
params.set('pageSize', options.pageSize.toString());
|
1109
|
+
if (options?.status)
|
1110
|
+
params.set('status', options.status);
|
1111
|
+
if (options?.recordType)
|
1112
|
+
params.set('recordType', options.recordType.toString());
|
1113
|
+
if (options?.methodId)
|
1114
|
+
params.set('methodId', options.methodId.toString());
|
1115
|
+
const url = `/web/payment/records${params.toString() ? `?${params.toString()}` : ''}`;
|
1116
|
+
const response = await this.client.request(url, {
|
1117
|
+
method: 'GET',
|
1118
|
+
headers: {
|
1119
|
+
'Authorization': `Bearer ${token}`,
|
1120
|
+
'Content-Type': 'application/json'
|
1121
|
+
}
|
1122
|
+
});
|
1123
|
+
return response;
|
1124
|
+
}
|
1125
|
+
catch (error) {
|
1126
|
+
// 如果是HTTP错误,尝试解析响应体
|
1127
|
+
if (error.statusCode && error.message) {
|
1128
|
+
// 对于401错误,返回认证失败信息
|
1129
|
+
if (error.statusCode === 401) {
|
1130
|
+
return {
|
1131
|
+
success: false,
|
1132
|
+
records: [],
|
1133
|
+
total: 0,
|
1134
|
+
page: options?.page || 1,
|
1135
|
+
pageSize: options?.pageSize || 10,
|
1136
|
+
message: '认证失败,请重新登录'
|
1137
|
+
};
|
1138
|
+
}
|
1139
|
+
// 对于其他HTTP错误,返回状态码信息
|
1140
|
+
return {
|
1141
|
+
success: false,
|
1142
|
+
records: [],
|
1143
|
+
total: 0,
|
1144
|
+
page: options?.page || 1,
|
1145
|
+
pageSize: options?.pageSize || 10,
|
1146
|
+
message: error.message || `HTTP ${error.statusCode} 错误`
|
1147
|
+
};
|
1148
|
+
}
|
1149
|
+
// 对于网络错误或其他错误
|
1150
|
+
return {
|
1151
|
+
success: false,
|
1152
|
+
records: [],
|
1153
|
+
total: 0,
|
1154
|
+
page: options?.page || 1,
|
1155
|
+
pageSize: options?.pageSize || 10,
|
1156
|
+
message: error instanceof Error ? error.message : '获取支付记录失败'
|
1157
|
+
};
|
1158
|
+
}
|
1159
|
+
}
|
1160
|
+
/**
|
1161
|
+
* 获取用户支付记录列表(简化版本)
|
1162
|
+
* @param page 页码,默认为1
|
1163
|
+
* @param pageSize 每页数量,默认为10
|
1164
|
+
* @returns 支付记录列表或null
|
1165
|
+
*/
|
1166
|
+
async getPaymentRecordsSimple(page = 1, pageSize = 10) {
|
1167
|
+
const result = await this.getPaymentRecords({ page, pageSize });
|
1168
|
+
return result.success ? {
|
1169
|
+
records: result.records,
|
1170
|
+
total: result.total,
|
1171
|
+
page: result.page,
|
1172
|
+
pageSize: result.pageSize
|
1173
|
+
} : null;
|
1174
|
+
}
|
1084
1175
|
}
|
1085
1176
|
|
1086
1177
|
/**
|
@@ -1354,6 +1445,18 @@ class GT6SDK {
|
|
1354
1445
|
async getFunds() {
|
1355
1446
|
return this.users.getFunds();
|
1356
1447
|
}
|
1448
|
+
/**
|
1449
|
+
* 41. 便捷方法:获取用户支付记录列表
|
1450
|
+
*/
|
1451
|
+
async getPaymentRecords(options) {
|
1452
|
+
return this.users.getPaymentRecords(options);
|
1453
|
+
}
|
1454
|
+
/**
|
1455
|
+
* 42. 便捷方法:获取用户支付记录列表(简化版本)
|
1456
|
+
*/
|
1457
|
+
async getPaymentRecordsSimple(page = 1, pageSize = 10) {
|
1458
|
+
return this.users.getPaymentRecordsSimple(page, pageSize);
|
1459
|
+
}
|
1357
1460
|
}
|
1358
1461
|
|
1359
1462
|
exports.ArticlesAPI = ArticlesAPI;
|