@xbongbong/xbbcli 2.4.4 → 2.4.6
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/README.md +15 -4
- package/business-info-detail.js +126 -0
- package/business-info-search.js +95 -0
- package/buyer-inquiry-detail.js +16 -47
- package/buyer-inquiry-list.js +18 -56
- package/clue-add-couser.js +14 -39
- package/clue-add.js +15 -41
- package/clue-back.js +14 -39
- package/clue-del.js +14 -39
- package/clue-delete-couser.js +14 -39
- package/clue-delete-mainuser.js +14 -39
- package/clue-detail.js +15 -40
- package/clue-distribution.js +14 -43
- package/clue-edit.js +15 -41
- package/clue-handover.js +15 -45
- package/clue-list.js +18 -61
- package/clue-thorough-delete.js +14 -39
- package/communicate-add.js +15 -56
- package/communicate-del.js +17 -59
- package/communicate-detail.js +15 -56
- package/communicate-edit.js +15 -56
- package/communicate-list.js +18 -63
- package/communicate-plan-add.js +16 -42
- package/communicate-plan-cancel.js +14 -40
- package/communicate-plan-del.js +14 -40
- package/communicate-plan-detail.js +15 -41
- package/communicate-plan-list.js +18 -46
- package/communicate-plan-single-operate.js +14 -39
- package/contact-add-couser.js +14 -39
- package/contact-add-mainuser.js +14 -39
- package/contact-add.js +15 -51
- package/contact-del.js +15 -38
- package/contact-delete-couser.js +14 -39
- package/contact-delete-mainuser.js +14 -39
- package/contact-detail.js +15 -38
- package/contact-edit.js +14 -47
- package/contact-handover.js +14 -39
- package/contact-list.js +37 -61
- package/contract-add-couser.js +16 -58
- package/contract-add-mainuser.js +16 -58
- package/contract-add.js +15 -57
- package/contract-del.js +17 -58
- package/contract-delete-couser.js +16 -57
- package/contract-delete-mainuser.js +16 -58
- package/contract-detail.js +15 -57
- package/contract-edit.js +15 -57
- package/contract-handover.js +15 -56
- package/contract-list.js +18 -61
- package/contract-outstock-add.js +15 -46
- package/contract-outstock-del.js +15 -41
- package/contract-outstock-detail.js +15 -41
- package/contract-outstock-edit.js +15 -46
- package/contract-outstock-list.js +18 -46
- package/customer-add-couser.js +13 -54
- package/customer-add.js +15 -58
- package/customer-back.js +15 -57
- package/customer-del.js +17 -58
- package/customer-delete-couser.js +16 -57
- package/customer-delete-mainuser.js +16 -58
- package/customer-detail.js +13 -54
- package/customer-distribution.js +15 -57
- package/customer-edit.js +13 -53
- package/customer-handover.js +15 -56
- package/customer-invoice-address-add.js +15 -41
- package/customer-invoice-address-edit.js +15 -40
- package/customer-invoice-address.js +17 -42
- package/customer-invoice-info-add.js +15 -41
- package/customer-invoice-info-edit.js +15 -40
- package/customer-invoice-info.js +17 -42
- package/customer-list.js +18 -61
- package/department-add.js +14 -39
- package/department-del.js +14 -40
- package/department-edit.js +14 -39
- package/department-list.js +17 -59
- package/form-data-add-couser.js +14 -39
- package/form-data-add-mainuser.js +14 -39
- package/form-data-add.js +13 -54
- package/form-data-del.js +13 -53
- package/form-data-delete-couser.js +14 -40
- package/form-data-delete-mainuser.js +14 -39
- package/form-data-detail.js +13 -54
- package/form-data-edit.js +13 -54
- package/form-data-handover.js +14 -39
- package/form-data-list.js +37 -63
- package/form-get.js +13 -53
- package/form-list.js +19 -66
- package/hkh-call-add-task.js +14 -44
- package/hkh-word-list.js +16 -44
- package/invoice-add.js +15 -45
- package/invoice-cancel.js +14 -44
- package/invoice-del.js +15 -45
- package/invoice-detail.js +15 -45
- package/invoice-edit.js +15 -45
- package/invoice-get-amount-detail.js +14 -44
- package/invoice-list.js +18 -50
- package/invoice-red.js +15 -45
- package/label-add.js +14 -44
- package/label-all-list.js +16 -44
- package/label-batch-add.js +14 -44
- package/label-batch-remove.js +14 -44
- package/label-del-completely.js +14 -44
- package/label-del.js +15 -45
- package/label-edit.js +14 -44
- package/label-group-add.js +15 -45
- package/label-group-del.js +15 -45
- package/label-group-list.js +16 -44
- package/label-group-update.js +15 -45
- package/label-list.js +16 -44
- package/label-reduction.js +15 -45
- package/label-repeat.js +15 -45
- package/market-activity-add.js +14 -49
- package/market-activity-del.js +15 -46
- package/market-activity-detail.js +15 -45
- package/market-activity-edit.js +15 -46
- package/market-activity-handover.js +14 -40
- package/market-activity-list.js +18 -46
- package/opportunity-add-couser.js +16 -58
- package/opportunity-add-mainuser.js +16 -58
- package/opportunity-add.js +15 -56
- package/opportunity-del.js +17 -59
- package/opportunity-delete-couser.js +16 -58
- package/opportunity-delete-mainuser.js +16 -57
- package/opportunity-detail.js +15 -58
- package/opportunity-edit.js +15 -56
- package/opportunity-handover.js +15 -57
- package/opportunity-list.js +40 -65
- package/orginal-text-list.js +16 -61
- package/package.json +8 -1
- package/pay-plan-add-couser.js +14 -41
- package/pay-plan-add-mainuser.js +14 -41
- package/pay-plan-add.js +15 -46
- package/pay-plan-delete-couser.js +14 -40
- package/pay-plan-delete-mainuser.js +14 -40
- package/pay-plan-handover.js +14 -40
- package/pay-sheet-add-bad.js +15 -46
- package/pay-sheet-add-couser.js +14 -40
- package/pay-sheet-add-mainuser.js +14 -41
- package/pay-sheet-add-red.js +15 -46
- package/pay-sheet-add-write-off.js +15 -46
- package/pay-sheet-del.js +14 -48
- package/pay-sheet-delete-couser.js +14 -40
- package/pay-sheet-delete-mainuser.js +14 -41
- package/pay-sheet-detail.js +15 -46
- package/pay-sheet-edit-bad.js +14 -49
- package/pay-sheet-edit-red.js +14 -49
- package/pay-sheet-edit-write-off.js +15 -46
- package/pay-sheet-get-amount-detail.js +14 -44
- package/pay-sheet-list.js +18 -46
- package/payment-add-couser.js +16 -58
- package/payment-add-mainuser.js +16 -58
- package/payment-add.js +15 -56
- package/payment-del.js +17 -58
- package/payment-delete-couser.js +16 -57
- package/payment-delete-mainuser.js +16 -57
- package/payment-detail.js +15 -56
- package/payment-edit.js +15 -56
- package/payment-handover.js +15 -57
- package/payment-list.js +37 -61
- package/payment-sheet-add-bad-debt.js +15 -57
- package/payment-sheet-add-pre.js +15 -46
- package/payment-sheet-add-red.js +15 -57
- package/payment-sheet-add-write-off.js +15 -52
- package/payment-sheet-del.js +17 -53
- package/payment-sheet-detail.js +15 -52
- package/payment-sheet-edit-bad-debt.js +15 -51
- package/payment-sheet-edit-red.js +15 -56
- package/payment-sheet-edit-write-off.js +15 -56
- package/payment-sheet-get-amount-detail.js +14 -45
- package/payment-sheet-handover.js +14 -40
- package/payment-sheet-list.js +37 -60
- package/product-add.js +15 -51
- package/product-category-add.js +13 -48
- package/product-category-del.js +13 -53
- package/product-category-list.js +17 -60
- package/product-category-update.js +13 -54
- package/product-del.js +17 -53
- package/product-detail.js +13 -54
- package/product-edit.js +15 -51
- package/product-list.js +37 -63
- package/product-online.js +14 -44
- package/quotation-add-couser.js +15 -45
- package/quotation-add-mainuser.js +15 -45
- package/quotation-add.js +15 -45
- package/quotation-del.js +15 -45
- package/quotation-delete-couser.js +15 -45
- package/quotation-delete-mainuser.js +15 -45
- package/quotation-detail.js +15 -45
- package/quotation-edit.js +15 -45
- package/quotation-handover.js +14 -39
- package/quotation-list.js +18 -50
- package/refund-add.js +15 -39
- package/refund-del.js +15 -38
- package/refund-detail.js +15 -39
- package/refund-edit.js +15 -39
- package/refund-list.js +37 -61
- package/role-list.js +18 -46
- package/sign-in-list.js +21 -49
- package/stage-get.js +16 -42
- package/stage-jump.js +15 -49
- package/supplier-add.js +15 -57
- package/token-del.js +1 -1
- package/token-list.js +20 -1
- package/token-set.js +1 -1
- package/token-use.js +2 -35
- package/user-add.js +14 -39
- package/user-del.js +14 -40
- package/user-edit.js +14 -40
- package/user-handover.js +14 -40
- package/user-list.js +16 -62
- package/work-order-add.js +13 -54
- package/work-order-asset-add-couser.js +15 -45
- package/work-order-asset-add-mainuser.js +15 -45
- package/work-order-asset-add.js +15 -45
- package/work-order-asset-del-couser.js +15 -45
- package/work-order-asset-del-mainuser.js +15 -45
- package/work-order-asset-del.js +15 -45
- package/work-order-asset-detail.js +15 -45
- package/work-order-asset-edit.js +15 -45
- package/work-order-asset-handover.js +15 -45
- package/work-order-asset-list.js +18 -50
- package/work-order-del.js +13 -54
- package/work-order-detail.js +13 -53
- package/work-order-dynamic-list.js +18 -56
- package/work-order-edit.js +13 -54
- package/work-order-list.js +17 -59
- package/work-order-operate.js +13 -54
- package/work-order-template-detail.js +13 -54
- package/work-order-template-list.js +17 -60
- package/work-report-daily-add.js +14 -39
- package/work-report-daily-del.js +14 -39
- package/work-report-daily-detail.js +15 -40
- package/work-report-daily-edit.js +17 -52
- package/work-report-daily-get-work-plan.js +14 -40
- package/work-report-daily-list.js +18 -45
- package/work-report-monthly-add.js +14 -40
- package/work-report-monthly-del.js +14 -43
- package/work-report-monthly-detail.js +15 -40
- package/work-report-monthly-edit.js +15 -40
- package/work-report-monthly-list.js +18 -45
- package/work-report-weekly-add.js +14 -40
- package/work-report-weekly-del.js +14 -40
- package/work-report-weekly-detail.js +15 -41
- package/work-report-weekly-edit.js +15 -41
- package/work-report-weekly-list.js +18 -45
- package/work-task-add-couser.js +14 -43
- package/work-task-add.js +15 -41
- package/work-task-delete-couser.js +14 -40
- package/work-task-detail.js +15 -40
- package/work-task-edit.js +14 -39
- package/work-task-handover.js +14 -40
- package/workorder-add-couser.js +16 -57
- package/workorder-delete-couser.js +16 -58
- package/workorder-handover.js +17 -58
- package/workorderlist.js +38 -60
- package/workorderproductlist.js +18 -59
- package/worktimerecorddetail.js +13 -54
- package/worktimerecordlist.js +18 -59
- package/xbb-http.js +71 -0
package/customer-back.js
CHANGED
|
@@ -1,33 +1,7 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import os from 'node:os';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import crypto from 'node:crypto';
|
|
5
1
|
import { cli, Strategy } from './xbb-registry.js';
|
|
6
|
-
import {
|
|
2
|
+
import { getRuntimeConfig, requestGateway } from './xbb-http.js';
|
|
7
3
|
|
|
8
|
-
const
|
|
9
|
-
const CONFIG_FILE = path.join(CONFIG_DIR, 'config.env');
|
|
10
|
-
const API_URL = 'https://proapi.xbongbong.com/pro/v2/api/customer/back';
|
|
11
|
-
const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
|
|
12
|
-
|
|
13
|
-
function readConfig() {
|
|
14
|
-
return readActiveConfig();
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function getRuntimeConfig() {
|
|
18
|
-
const config = readConfig();
|
|
19
|
-
return {
|
|
20
|
-
corpid: String(config.corpid || '').trim(),
|
|
21
|
-
token: String(config.token || '').trim(),
|
|
22
|
-
baseUrl: String(config.baseurl || DEFAULT_BASE_URL).trim(),
|
|
23
|
-
userId: String(config.userId || '').trim(),
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function buildApiUrl(baseUrl, defaultUrl) {
|
|
28
|
-
const apiPath = new URL(defaultUrl).pathname;
|
|
29
|
-
return `${baseUrl.replace(/\/+$/, '')}${apiPath}`;
|
|
30
|
-
}
|
|
4
|
+
const API_PATH = '/pro/v2/api/customer/back';
|
|
31
5
|
|
|
32
6
|
function makeErrorRow(code, msg) {
|
|
33
7
|
return [{
|
|
@@ -71,7 +45,6 @@ cli({
|
|
|
71
45
|
payload.dataIdList = dataIdList;
|
|
72
46
|
}
|
|
73
47
|
|
|
74
|
-
const body = JSON.stringify(payload);
|
|
75
48
|
|
|
76
49
|
if (!payload.corpid) {
|
|
77
50
|
return makeErrorRow('NO_CORPID', '缺少本地 corpid;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>');
|
|
@@ -83,40 +56,25 @@ cli({
|
|
|
83
56
|
return makeErrorRow('NO_TOKEN', '缺少 token;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>');
|
|
84
57
|
}
|
|
85
58
|
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
process.stderr.write(`[debug] URL: ${apiUrl}\n[debug] Headers: ${JSON.stringify(headers)}\n[debug] RequestBody: ${body}\n`);
|
|
94
|
-
}
|
|
95
|
-
const resp = await fetch(apiUrl, {
|
|
96
|
-
method: 'POST',
|
|
97
|
-
headers,
|
|
98
|
-
body,
|
|
59
|
+
const gateway = await requestGateway({
|
|
60
|
+
baseUrl,
|
|
61
|
+
apiPath: API_PATH,
|
|
62
|
+
payload,
|
|
63
|
+
token,
|
|
64
|
+
userId,
|
|
65
|
+
debug,
|
|
99
66
|
});
|
|
100
|
-
|
|
101
|
-
if (
|
|
102
|
-
|
|
103
|
-
if (debug) process.stderr.write(`[debug] ResponseBody: ${responseText}\n`);
|
|
104
|
-
return makeErrorRow(resp.status, `HTTP ${resp.status} ${resp.statusText}`);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const data = await resp.json();
|
|
108
|
-
const responseBody = JSON.stringify(data);
|
|
109
|
-
if (debug) process.stderr.write(`[debug] ResponseBody: ${responseBody}\n`);
|
|
110
|
-
if (data.code !== 1) {
|
|
111
|
-
return makeErrorRow(data.code ?? '', data.msg ?? '未知错误');
|
|
67
|
+
if (!gateway.ok) return makeErrorRow(gateway.code, gateway.msg);
|
|
68
|
+
if (gateway.data.code !== 1) {
|
|
69
|
+
return makeErrorRow(gateway.data.code ?? '', gateway.data.msg ?? '未知错误');
|
|
112
70
|
}
|
|
113
71
|
|
|
114
|
-
const result = data.result || {};
|
|
72
|
+
const result = gateway.data.result || {};
|
|
115
73
|
return [{
|
|
116
74
|
resultType: result.resultType || '',
|
|
117
75
|
resultMsg: result.resultMsg || '',
|
|
118
|
-
code: data.code ?? '',
|
|
119
|
-
msg: data.msg || '',
|
|
76
|
+
code: gateway.data.code ?? '',
|
|
77
|
+
msg: gateway.data.msg || '',
|
|
120
78
|
}];
|
|
121
79
|
},
|
|
122
80
|
});
|
package/customer-del.js
CHANGED
|
@@ -1,33 +1,7 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import os from 'node:os';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import crypto from 'node:crypto';
|
|
5
1
|
import { cli, Strategy } from './xbb-registry.js';
|
|
6
|
-
import {
|
|
2
|
+
import { getRuntimeConfig, requestGateway } from './xbb-http.js';
|
|
7
3
|
|
|
8
|
-
const
|
|
9
|
-
const CONFIG_FILE = path.join(CONFIG_DIR, 'config.env');
|
|
10
|
-
const API_URL = 'https://proapi.xbongbong.com/pro/v2/api/customer/del';
|
|
11
|
-
const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
|
|
12
|
-
|
|
13
|
-
function readConfig() {
|
|
14
|
-
return readActiveConfig();
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function getRuntimeConfig() {
|
|
18
|
-
const config = readConfig();
|
|
19
|
-
return {
|
|
20
|
-
corpid: String(config.corpid || '').trim(),
|
|
21
|
-
token: String(config.token || '').trim(),
|
|
22
|
-
baseUrl: String(config.baseurl || DEFAULT_BASE_URL).trim(),
|
|
23
|
-
userId: String(config.userId || '').trim(),
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function buildApiUrl(baseUrl, defaultUrl) {
|
|
28
|
-
const apiPath = new URL(defaultUrl).pathname;
|
|
29
|
-
return `${baseUrl.replace(/\/+$/, '')}${apiPath}`;
|
|
30
|
-
}
|
|
4
|
+
const API_PATH = '/pro/v2/api/customer/del';
|
|
31
5
|
|
|
32
6
|
function makeErrorRow(code, msg) {
|
|
33
7
|
return [{
|
|
@@ -63,7 +37,6 @@ cli({
|
|
|
63
37
|
};
|
|
64
38
|
if (kwargs.userId) payload.userId = String(kwargs.userId);
|
|
65
39
|
|
|
66
|
-
const body = JSON.stringify(payload);
|
|
67
40
|
|
|
68
41
|
if (!payload.corpid) {
|
|
69
42
|
return makeErrorRow('NO_CORPID', '缺少本地 corpid;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>');
|
|
@@ -75,40 +48,26 @@ cli({
|
|
|
75
48
|
return makeErrorRow('NO_TOKEN', '缺少 token;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>');
|
|
76
49
|
}
|
|
77
50
|
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
const resp = await fetch(buildApiUrl(baseUrl, API_URL), {
|
|
87
|
-
method: 'POST',
|
|
88
|
-
headers,
|
|
89
|
-
body,
|
|
51
|
+
const gateway = await requestGateway({
|
|
52
|
+
baseUrl,
|
|
53
|
+
apiPath: API_PATH,
|
|
54
|
+
payload,
|
|
55
|
+
token,
|
|
56
|
+
userId,
|
|
57
|
+
debug,
|
|
90
58
|
});
|
|
91
|
-
|
|
92
|
-
if (
|
|
93
|
-
|
|
94
|
-
if (debug) process.stderr.write(`[debug] ResponseBody: ${responseText}\n`);
|
|
95
|
-
return makeErrorRow(resp.status, `HTTP ${resp.status} ${resp.statusText}`);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const data = await resp.json();
|
|
99
|
-
const responseBody = JSON.stringify(data);
|
|
100
|
-
if (debug) process.stderr.write(`[debug] ResponseBody: ${responseBody}\n`);
|
|
101
|
-
if (data.code !== 1) {
|
|
102
|
-
return makeErrorRow(data.code ?? '', data.msg ?? '未知错误');
|
|
59
|
+
if (!gateway.ok) return makeErrorRow(gateway.code, gateway.msg);
|
|
60
|
+
if (gateway.data.code !== 1) {
|
|
61
|
+
return makeErrorRow(gateway.data.code ?? '', gateway.data.msg ?? '未知错误');
|
|
103
62
|
}
|
|
104
63
|
|
|
105
|
-
const result = data.result || {};
|
|
64
|
+
const result = gateway.data.result || {};
|
|
106
65
|
return [{
|
|
107
|
-
resultCode: data.code ?? '',
|
|
108
|
-
resultMsg: data.msg || '',
|
|
66
|
+
resultCode: gateway.data.code ?? '',
|
|
67
|
+
resultMsg: gateway.data.msg || '',
|
|
109
68
|
errorDataMemo: result.errorDataMemo || '',
|
|
110
|
-
code: data.code ?? '',
|
|
111
|
-
msg: data.msg || '',
|
|
69
|
+
code: gateway.data.code ?? '',
|
|
70
|
+
msg: gateway.data.msg || '',
|
|
112
71
|
}];
|
|
113
72
|
},
|
|
114
73
|
});
|
|
@@ -1,33 +1,7 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import os from 'node:os';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import crypto from 'node:crypto';
|
|
5
1
|
import { cli, Strategy } from './xbb-registry.js';
|
|
6
|
-
import {
|
|
2
|
+
import { getRuntimeConfig, requestGateway } from './xbb-http.js';
|
|
7
3
|
|
|
8
|
-
const
|
|
9
|
-
const CONFIG_FILE = path.join(CONFIG_DIR, 'config.env');
|
|
10
|
-
const API_URL = 'https://proapi.xbongbong.com/pro/v2/api/customer/deleteCoUser';
|
|
11
|
-
const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
|
|
12
|
-
|
|
13
|
-
function readConfig() {
|
|
14
|
-
return readActiveConfig();
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function getRuntimeConfig() {
|
|
18
|
-
const config = readConfig();
|
|
19
|
-
return {
|
|
20
|
-
corpid: String(config.corpid || '').trim(),
|
|
21
|
-
token: String(config.token || '').trim(),
|
|
22
|
-
baseUrl: String(config.baseurl || DEFAULT_BASE_URL).trim(),
|
|
23
|
-
userId: String(config.userId || '').trim(),
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function buildApiUrl(baseUrl, defaultUrl) {
|
|
28
|
-
const apiPath = new URL(defaultUrl).pathname;
|
|
29
|
-
return `${baseUrl.replace(/\/+$/, '')}${apiPath}`;
|
|
30
|
-
}
|
|
4
|
+
const API_PATH = '/pro/v2/api/customer/deleteCoUser';
|
|
31
5
|
|
|
32
6
|
function makeErrorRow(code, msg) {
|
|
33
7
|
return [{
|
|
@@ -73,7 +47,6 @@ cli({
|
|
|
73
47
|
payload.businessUserIdList = userIdList;
|
|
74
48
|
}
|
|
75
49
|
|
|
76
|
-
const body = JSON.stringify(payload);
|
|
77
50
|
|
|
78
51
|
if (!payload.corpid) {
|
|
79
52
|
return makeErrorRow('NO_CORPID', '缺少本地 corpid;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>');
|
|
@@ -88,38 +61,24 @@ cli({
|
|
|
88
61
|
return makeErrorRow('NO_TOKEN', '缺少 token;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>');
|
|
89
62
|
}
|
|
90
63
|
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
const resp = await fetch(buildApiUrl(baseUrl, API_URL), {
|
|
100
|
-
method: 'POST',
|
|
101
|
-
headers,
|
|
102
|
-
body,
|
|
64
|
+
const gateway = await requestGateway({
|
|
65
|
+
baseUrl,
|
|
66
|
+
apiPath: API_PATH,
|
|
67
|
+
payload,
|
|
68
|
+
token,
|
|
69
|
+
userId,
|
|
70
|
+
debug,
|
|
103
71
|
});
|
|
104
|
-
|
|
105
|
-
if (
|
|
106
|
-
|
|
107
|
-
if (debug) process.stderr.write(`[debug] ResponseBody: ${responseText}\n`);
|
|
108
|
-
return makeErrorRow(resp.status, `HTTP ${resp.status} ${resp.statusText}`);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const data = await resp.json();
|
|
112
|
-
const responseBody = JSON.stringify(data);
|
|
113
|
-
if (debug) process.stderr.write(`[debug] ResponseBody: ${responseBody}\n`);
|
|
114
|
-
if (data.code !== 1) {
|
|
115
|
-
return makeErrorRow(data.code ?? '', data.msg ?? '未知错误');
|
|
72
|
+
if (!gateway.ok) return makeErrorRow(gateway.code, gateway.msg);
|
|
73
|
+
if (gateway.data.code !== 1) {
|
|
74
|
+
return makeErrorRow(gateway.data.code ?? '', gateway.data.msg ?? '未知错误');
|
|
116
75
|
}
|
|
117
76
|
|
|
118
77
|
return [{
|
|
119
|
-
resultCode: data.code ?? '',
|
|
120
|
-
resultMsg: data.msg || '',
|
|
121
|
-
code: data.code ?? '',
|
|
122
|
-
msg: data.msg || '',
|
|
78
|
+
resultCode: gateway.data.code ?? '',
|
|
79
|
+
resultMsg: gateway.data.msg || '',
|
|
80
|
+
code: gateway.data.code ?? '',
|
|
81
|
+
msg: gateway.data.msg || '',
|
|
123
82
|
}];
|
|
124
83
|
},
|
|
125
84
|
});
|
|
@@ -1,33 +1,7 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import os from 'node:os';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import crypto from 'node:crypto';
|
|
5
1
|
import { cli, Strategy } from './xbb-registry.js';
|
|
6
|
-
import {
|
|
2
|
+
import { getRuntimeConfig, requestGateway } from './xbb-http.js';
|
|
7
3
|
|
|
8
|
-
const
|
|
9
|
-
const CONFIG_FILE = path.join(CONFIG_DIR, 'config.env');
|
|
10
|
-
const API_URL = 'https://proapi.xbongbong.com/pro/v2/api/customer/deleteMainUser';
|
|
11
|
-
const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
|
|
12
|
-
|
|
13
|
-
function readConfig() {
|
|
14
|
-
return readActiveConfig();
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function getRuntimeConfig() {
|
|
18
|
-
const config = readConfig();
|
|
19
|
-
return {
|
|
20
|
-
corpid: String(config.corpid || '').trim(),
|
|
21
|
-
token: String(config.token || '').trim(),
|
|
22
|
-
baseUrl: String(config.baseurl || DEFAULT_BASE_URL).trim(),
|
|
23
|
-
userId: String(config.userId || '').trim(),
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function buildApiUrl(baseUrl, defaultUrl) {
|
|
28
|
-
const apiPath = new URL(defaultUrl).pathname;
|
|
29
|
-
return `${baseUrl.replace(/\/+$/, '')}${apiPath}`;
|
|
30
|
-
}
|
|
4
|
+
const API_PATH = '/pro/v2/api/customer/deleteMainUser';
|
|
31
5
|
|
|
32
6
|
function makeErrorRow(code, msg) {
|
|
33
7
|
return [{
|
|
@@ -73,7 +47,6 @@ cli({
|
|
|
73
47
|
payload.businessUserIdList = userIdList;
|
|
74
48
|
}
|
|
75
49
|
|
|
76
|
-
const body = JSON.stringify(payload);
|
|
77
50
|
|
|
78
51
|
if (!payload.corpid) {
|
|
79
52
|
return makeErrorRow('NO_CORPID', '缺少本地 corpid;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>');
|
|
@@ -88,39 +61,24 @@ cli({
|
|
|
88
61
|
return makeErrorRow('NO_TOKEN', '缺少 token;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>');
|
|
89
62
|
}
|
|
90
63
|
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
process.stderr.write(`[debug] URL: ${apiUrl}\n[debug] Headers: ${JSON.stringify(headers)}\n[debug] RequestBody: ${body}\n`);
|
|
99
|
-
}
|
|
100
|
-
const resp = await fetch(apiUrl, {
|
|
101
|
-
method: 'POST',
|
|
102
|
-
headers,
|
|
103
|
-
body,
|
|
64
|
+
const gateway = await requestGateway({
|
|
65
|
+
baseUrl,
|
|
66
|
+
apiPath: API_PATH,
|
|
67
|
+
payload,
|
|
68
|
+
token,
|
|
69
|
+
userId,
|
|
70
|
+
debug,
|
|
104
71
|
});
|
|
105
|
-
|
|
106
|
-
if (
|
|
107
|
-
|
|
108
|
-
if (debug) process.stderr.write(`[debug] ResponseBody: ${responseText}\n`);
|
|
109
|
-
return makeErrorRow(resp.status, `HTTP ${resp.status} ${resp.statusText}`);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const data = await resp.json();
|
|
113
|
-
const responseBody = JSON.stringify(data);
|
|
114
|
-
if (debug) process.stderr.write(`[debug] ResponseBody: ${responseBody}\n`);
|
|
115
|
-
if (data.code !== 1) {
|
|
116
|
-
return makeErrorRow(data.code ?? '', data.msg ?? '未知错误');
|
|
72
|
+
if (!gateway.ok) return makeErrorRow(gateway.code, gateway.msg);
|
|
73
|
+
if (gateway.data.code !== 1) {
|
|
74
|
+
return makeErrorRow(gateway.data.code ?? '', gateway.data.msg ?? '未知错误');
|
|
117
75
|
}
|
|
118
76
|
|
|
119
77
|
return [{
|
|
120
|
-
resultCode: data.code ?? '',
|
|
121
|
-
resultMsg: data.msg || '',
|
|
122
|
-
code: data.code ?? '',
|
|
123
|
-
msg: data.msg || '',
|
|
78
|
+
resultCode: gateway.data.code ?? '',
|
|
79
|
+
resultMsg: gateway.data.msg || '',
|
|
80
|
+
code: gateway.data.code ?? '',
|
|
81
|
+
msg: gateway.data.msg || '',
|
|
124
82
|
}];
|
|
125
83
|
},
|
|
126
84
|
});
|
package/customer-detail.js
CHANGED
|
@@ -1,34 +1,9 @@
|
|
|
1
|
-
import crypto from 'node:crypto';
|
|
2
|
-
import fs from 'node:fs';
|
|
3
|
-
import os from 'node:os';
|
|
4
|
-
import path from 'node:path';
|
|
5
1
|
import { cli, Strategy } from './xbb-registry.js';
|
|
6
|
-
import {
|
|
2
|
+
import { getRuntimeConfig, requestGateway } from './xbb-http.js';
|
|
7
3
|
|
|
8
|
-
const
|
|
9
|
-
const DETAIL_API_URL = 'https://proapi.xbongbong.com/pro/v2/api/customer/detail';
|
|
10
|
-
const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
|
|
4
|
+
const DETAIL_API_PATH = '/pro/v2/api/customer/detail';
|
|
11
5
|
const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>';
|
|
12
6
|
|
|
13
|
-
function readConfig() {
|
|
14
|
-
return readActiveConfig();
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function getRuntimeConfig() {
|
|
18
|
-
const config = readConfig();
|
|
19
|
-
return {
|
|
20
|
-
corpid: String(config.corpid || '').trim(),
|
|
21
|
-
token: String(config.token || '').trim(),
|
|
22
|
-
baseUrl: String(config.baseurl || DEFAULT_BASE_URL).trim(),
|
|
23
|
-
userId: String(config.userId || '').trim(),
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function buildApiUrl(baseUrl, defaultUrl) {
|
|
28
|
-
const apiPath = new URL(defaultUrl).pathname;
|
|
29
|
-
return `${baseUrl.replace(/\/+$/, '')}${apiPath}`;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
7
|
function buildPayload(kwargs, corpid) {
|
|
33
8
|
const payload = {
|
|
34
9
|
dataId: Number(kwargs.dataId || 0),
|
|
@@ -105,41 +80,25 @@ cli({
|
|
|
105
80
|
const debug = Boolean(kwargs.debug);
|
|
106
81
|
const { corpid, token, baseUrl, userId } = getRuntimeConfig();
|
|
107
82
|
const payload = buildPayload(kwargs, corpid);
|
|
108
|
-
const body = JSON.stringify(payload);
|
|
109
83
|
|
|
110
84
|
const validationError = getValidationError(payload, token);
|
|
111
85
|
if (validationError) {
|
|
112
86
|
return makeErrorRow(validationError.code, validationError.msg);
|
|
113
87
|
}
|
|
114
88
|
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
process.stderr.write(`[debug] URL: ${apiUrl}\n[debug] Headers: ${JSON.stringify(headers)}\n[debug] RequestBody: ${body}\n`);
|
|
123
|
-
}
|
|
124
|
-
const resp = await fetch(apiUrl, {
|
|
125
|
-
method: 'POST',
|
|
126
|
-
headers,
|
|
127
|
-
body,
|
|
89
|
+
const gateway = await requestGateway({
|
|
90
|
+
baseUrl,
|
|
91
|
+
apiPath: DETAIL_API_PATH,
|
|
92
|
+
payload,
|
|
93
|
+
token,
|
|
94
|
+
userId,
|
|
95
|
+
debug,
|
|
128
96
|
});
|
|
129
|
-
|
|
130
|
-
if (
|
|
131
|
-
|
|
132
|
-
if (debug) process.stderr.write(`[debug] ResponseBody: ${responseText}\n`);
|
|
133
|
-
return makeErrorRow(resp.status, `HTTP ${resp.status} ${resp.statusText}`);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const data = await resp.json();
|
|
137
|
-
const responseBody = JSON.stringify(data);
|
|
138
|
-
if (debug) process.stderr.write(`[debug] ResponseBody: ${responseBody}\n`);
|
|
139
|
-
if (data.code !== 1) {
|
|
140
|
-
return makeErrorRow(data.code ?? '', data.msg ?? '未知错误');
|
|
97
|
+
if (!gateway.ok) return makeErrorRow(gateway.code, gateway.msg);
|
|
98
|
+
if (gateway.data.code !== 1) {
|
|
99
|
+
return makeErrorRow(gateway.data.code ?? '', gateway.data.msg ?? '未知错误');
|
|
141
100
|
}
|
|
142
101
|
|
|
143
|
-
return makeSuccessRow(data);
|
|
102
|
+
return makeSuccessRow(gateway.data);
|
|
144
103
|
},
|
|
145
104
|
});
|
package/customer-distribution.js
CHANGED
|
@@ -1,33 +1,7 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import os from 'node:os';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import crypto from 'node:crypto';
|
|
5
1
|
import { cli, Strategy } from './xbb-registry.js';
|
|
6
|
-
import {
|
|
2
|
+
import { getRuntimeConfig, requestGateway } from './xbb-http.js';
|
|
7
3
|
|
|
8
|
-
const
|
|
9
|
-
const CONFIG_FILE = path.join(CONFIG_DIR, 'config.env');
|
|
10
|
-
const API_URL = 'https://proapi.xbongbong.com/pro/v2/api/customer/distribution';
|
|
11
|
-
const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
|
|
12
|
-
|
|
13
|
-
function readConfig() {
|
|
14
|
-
return readActiveConfig();
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function getRuntimeConfig() {
|
|
18
|
-
const config = readConfig();
|
|
19
|
-
return {
|
|
20
|
-
corpid: String(config.corpid || '').trim(),
|
|
21
|
-
token: String(config.token || '').trim(),
|
|
22
|
-
baseUrl: String(config.baseurl || DEFAULT_BASE_URL).trim(),
|
|
23
|
-
userId: String(config.userId || '').trim(),
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function buildApiUrl(baseUrl, defaultUrl) {
|
|
28
|
-
const apiPath = new URL(defaultUrl).pathname;
|
|
29
|
-
return `${baseUrl.replace(/\/+$/, '')}${apiPath}`;
|
|
30
|
-
}
|
|
4
|
+
const API_PATH = '/pro/v2/api/customer/distribution';
|
|
31
5
|
|
|
32
6
|
function makeErrorRow(code, msg) {
|
|
33
7
|
return [{
|
|
@@ -75,7 +49,6 @@ cli({
|
|
|
75
49
|
payload.dataIdList = dataIdList;
|
|
76
50
|
}
|
|
77
51
|
|
|
78
|
-
const body = JSON.stringify(payload);
|
|
79
52
|
|
|
80
53
|
if (!payload.corpid) {
|
|
81
54
|
return makeErrorRow('NO_CORPID', '缺少本地 corpid;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>');
|
|
@@ -90,40 +63,25 @@ cli({
|
|
|
90
63
|
return makeErrorRow('NO_TOKEN', '缺少 token;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>');
|
|
91
64
|
}
|
|
92
65
|
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
process.stderr.write(`[debug] URL: ${apiUrl}\n[debug] Headers: ${JSON.stringify(headers)}\n[debug] RequestBody: ${body}\n`);
|
|
101
|
-
}
|
|
102
|
-
const resp = await fetch(apiUrl, {
|
|
103
|
-
method: 'POST',
|
|
104
|
-
headers,
|
|
105
|
-
body,
|
|
66
|
+
const gateway = await requestGateway({
|
|
67
|
+
baseUrl,
|
|
68
|
+
apiPath: API_PATH,
|
|
69
|
+
payload,
|
|
70
|
+
token,
|
|
71
|
+
userId,
|
|
72
|
+
debug,
|
|
106
73
|
});
|
|
107
|
-
|
|
108
|
-
if (
|
|
109
|
-
|
|
110
|
-
if (debug) process.stderr.write(`[debug] ResponseBody: ${responseText}\n`);
|
|
111
|
-
return makeErrorRow(resp.status, `HTTP ${resp.status} ${resp.statusText}`);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const data = await resp.json();
|
|
115
|
-
const responseBody = JSON.stringify(data);
|
|
116
|
-
if (debug) process.stderr.write(`[debug] ResponseBody: ${responseBody}\n`);
|
|
117
|
-
if (data.code !== 1) {
|
|
118
|
-
return makeErrorRow(data.code ?? '', data.msg ?? '未知错误');
|
|
74
|
+
if (!gateway.ok) return makeErrorRow(gateway.code, gateway.msg);
|
|
75
|
+
if (gateway.data.code !== 1) {
|
|
76
|
+
return makeErrorRow(gateway.data.code ?? '', gateway.data.msg ?? '未知错误');
|
|
119
77
|
}
|
|
120
78
|
|
|
121
|
-
const result = data.result || {};
|
|
79
|
+
const result = gateway.data.result || {};
|
|
122
80
|
return [{
|
|
123
81
|
resultType: result.resultType || '',
|
|
124
82
|
resultMsg: result.resultMsg || '',
|
|
125
|
-
code: data.code ?? '',
|
|
126
|
-
msg: data.msg || '',
|
|
83
|
+
code: gateway.data.code ?? '',
|
|
84
|
+
msg: gateway.data.msg || '',
|
|
127
85
|
}];
|
|
128
86
|
},
|
|
129
87
|
});
|
package/customer-edit.js
CHANGED
|
@@ -1,32 +1,7 @@
|
|
|
1
|
-
import crypto from 'node:crypto';
|
|
2
|
-
import fs from 'node:fs';
|
|
3
|
-
import os from 'node:os';
|
|
4
|
-
import path from 'node:path';
|
|
5
1
|
import { cli, Strategy } from './xbb-registry.js';
|
|
6
|
-
import {
|
|
2
|
+
import { getRuntimeConfig, requestGateway } from './xbb-http.js';
|
|
7
3
|
|
|
8
|
-
const
|
|
9
|
-
const EDIT_API_URL = 'https://proapi.xbongbong.com/pro/v2/api/customer/edit';
|
|
10
|
-
const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
|
|
11
|
-
|
|
12
|
-
function readConfig() {
|
|
13
|
-
return readActiveConfig();
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function getRuntimeConfig() {
|
|
17
|
-
const config = readConfig();
|
|
18
|
-
return {
|
|
19
|
-
corpid: String(config.corpid || '').trim(),
|
|
20
|
-
token: String(config.token || '').trim(),
|
|
21
|
-
baseUrl: String(config.baseurl || DEFAULT_BASE_URL).trim(),
|
|
22
|
-
userId: String(config.userId || '').trim(),
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function buildApiUrl(baseUrl, defaultUrl) {
|
|
27
|
-
const apiPath = new URL(defaultUrl).pathname;
|
|
28
|
-
return `${baseUrl.replace(/\/+$/, '')}${apiPath}`;
|
|
29
|
-
}
|
|
4
|
+
const EDIT_API_PATH = '/pro/v2/api/customer/edit';
|
|
30
5
|
|
|
31
6
|
function parseDataList(raw) {
|
|
32
7
|
if (raw && typeof raw === 'object' && !Array.isArray(raw)) {
|
|
@@ -132,40 +107,25 @@ cli({
|
|
|
132
107
|
const { corpid, token, baseUrl, userId } = getRuntimeConfig();
|
|
133
108
|
const parsedDataList = parseDataList(kwargs.dataList);
|
|
134
109
|
const payload = buildPayload(kwargs, parsedDataList, corpid, userId);
|
|
135
|
-
const body = JSON.stringify(payload);
|
|
136
110
|
|
|
137
111
|
const validationError = getValidationError(payload, token, parsedDataList);
|
|
138
112
|
if (validationError) {
|
|
139
113
|
return makeErrorRow(validationError.code, validationError.msg);
|
|
140
114
|
}
|
|
141
115
|
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
const resp = await fetch(buildApiUrl(baseUrl, EDIT_API_URL), {
|
|
151
|
-
method: 'POST',
|
|
152
|
-
headers,
|
|
153
|
-
body,
|
|
116
|
+
const gateway = await requestGateway({
|
|
117
|
+
baseUrl,
|
|
118
|
+
apiPath: EDIT_API_PATH,
|
|
119
|
+
payload,
|
|
120
|
+
token,
|
|
121
|
+
userId,
|
|
122
|
+
debug,
|
|
154
123
|
});
|
|
155
|
-
|
|
156
|
-
if (
|
|
157
|
-
|
|
158
|
-
if (debug) process.stderr.write(`[debug] ResponseBody: ${responseText}\n`);
|
|
159
|
-
return makeErrorRow(resp.status, `HTTP ${resp.status} ${resp.statusText}`);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
const data = await resp.json();
|
|
163
|
-
const responseBody = JSON.stringify(data);
|
|
164
|
-
if (debug) process.stderr.write(`[debug] ResponseBody: ${responseBody}\n`);
|
|
165
|
-
if (data.code !== 1) {
|
|
166
|
-
return makeErrorRow(data.code ?? '', data.msg ?? '未知错误');
|
|
124
|
+
if (!gateway.ok) return makeErrorRow(gateway.code, gateway.msg);
|
|
125
|
+
if (gateway.data.code !== 1) {
|
|
126
|
+
return makeErrorRow(gateway.data.code ?? '', gateway.data.msg ?? '未知错误');
|
|
167
127
|
}
|
|
168
128
|
|
|
169
|
-
return makeSuccessRow(data);
|
|
129
|
+
return makeSuccessRow(gateway.data);
|
|
170
130
|
},
|
|
171
131
|
});
|