gm-mcp 1.0.7
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 +60 -0
- package/dist/env.d.ts +36 -0
- package/dist/env.js +49 -0
- package/dist/helpers/currency.d.ts +1 -0
- package/dist/helpers/currency.js +43 -0
- package/dist/helpers/extract-date.d.ts +5 -0
- package/dist/helpers/extract-date.js +13 -0
- package/dist/helpers/extract-month.d.ts +4 -0
- package/dist/helpers/extract-month.js +17 -0
- package/dist/helpers/index.d.ts +3 -0
- package/dist/helpers/index.js +19 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +83 -0
- package/dist/services/gimo.service.d.ts +3 -0
- package/dist/services/gimo.service.js +48 -0
- package/dist/services/lark.service.d.ts +109 -0
- package/dist/services/lark.service.js +162 -0
- package/dist/services/lending.service.d.ts +19 -0
- package/dist/services/lending.service.js +96 -0
- package/dist/services/types/gimo.type.d.ts +177 -0
- package/dist/services/types/gimo.type.js +2 -0
- package/dist/services/types/index.d.ts +2 -0
- package/dist/services/types/index.js +18 -0
- package/dist/services/types/lending.type.d.ts +168 -0
- package/dist/services/types/lending.type.js +21 -0
- package/dist/test.d.ts +1 -0
- package/dist/test.js +39 -0
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.js +17 -0
- package/dist/tools/statistic-x3.d.ts +26 -0
- package/dist/tools/statistic-x3.js +337 -0
- package/package.json +35 -0
- package/src/env.ts +45 -0
- package/src/helpers/currency.ts +8 -0
- package/src/helpers/extract-date.ts +10 -0
- package/src/helpers/extract-month.ts +14 -0
- package/src/helpers/index.ts +3 -0
- package/src/index.ts +104 -0
- package/src/services/gimo.service.ts +31 -0
- package/src/services/lark.service.ts +122 -0
- package/src/services/lending.service.ts +107 -0
- package/src/services/types/gimo.type.ts +184 -0
- package/src/services/types/index.ts +2 -0
- package/src/services/types/lending.type.ts +181 -0
- package/src/test.ts +38 -0
- package/src/tools/index.ts +1 -0
- package/src/tools/statistic-x3.ts +378 -0
- package/tsconfig.json +115 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import * as lark from "@larksuiteoapi/node-sdk";
|
|
3
|
+
import { getEnv } from "../env";
|
|
4
|
+
// const LARK_BASE_TABLE_ID = process.env['LARK_BASE_TABLE_ID'];
|
|
5
|
+
// const LARK_BITABLE_APP_TOKEN = process.env['LARK_BITABLE_APP_TOKEN'];
|
|
6
|
+
// group test_bot
|
|
7
|
+
// const LARK_X3_GROUP_ID = 'oc_bb4e5b8dd8ada38127c790fa368c02b9';
|
|
8
|
+
// Group dan choi front end
|
|
9
|
+
|
|
10
|
+
const larkClient = new lark.Client({
|
|
11
|
+
appId: getEnv().LARK_APP_ID,
|
|
12
|
+
appSecret: getEnv().LARK_APP_SECRET,
|
|
13
|
+
disableTokenCache: true,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
async function getAccessToken() {
|
|
17
|
+
const url = "https://open.larksuite.com/open-apis/auth/v3/tenant_access_token/internal";
|
|
18
|
+
return axios
|
|
19
|
+
.post<{
|
|
20
|
+
code: number;
|
|
21
|
+
msg: string;
|
|
22
|
+
tenant_access_token: string;
|
|
23
|
+
expire: number;
|
|
24
|
+
}>(url, {
|
|
25
|
+
app_id: getEnv().LARK_APP_ID,
|
|
26
|
+
app_secret: getEnv().LARK_APP_SECRET,
|
|
27
|
+
})
|
|
28
|
+
.then((res) => res.data.tenant_access_token);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// export async function logX3Issue(p: {
|
|
32
|
+
// phone: string;
|
|
33
|
+
// company: string;
|
|
34
|
+
// created_at: number;
|
|
35
|
+
// customer_name: string;
|
|
36
|
+
// ekyc_link: { text: string; link: string };
|
|
37
|
+
// type: "ekyc" | "cic" | "datanest" | "pending_application";
|
|
38
|
+
// ops_status: "pending" | "done";
|
|
39
|
+
// assignee: { id: string }[];
|
|
40
|
+
// created_by: { id: string }[];
|
|
41
|
+
// }) {
|
|
42
|
+
// return logBaseRecord(
|
|
43
|
+
// { tableId: LARK_BASE_TABLE_ID, appToken: LARK_BITABLE_APP_TOKEN },
|
|
44
|
+
// p
|
|
45
|
+
// );
|
|
46
|
+
// }
|
|
47
|
+
|
|
48
|
+
// export async function logBaseRecord(
|
|
49
|
+
// config: { tableId: string; appToken: string },
|
|
50
|
+
// record: Record<string, any>
|
|
51
|
+
// ) {
|
|
52
|
+
// // const fields = new Map<string, any>();
|
|
53
|
+
// // Object.entries(record).forEach(([key, value]) => fields.set(key, value))
|
|
54
|
+
// const access_token = await getAccessToken();
|
|
55
|
+
// return larkClient.bitable.appTableRecord.create(
|
|
56
|
+
// {
|
|
57
|
+
// path: {
|
|
58
|
+
// app_token: config.appToken,
|
|
59
|
+
// table_id: config.tableId,
|
|
60
|
+
// },
|
|
61
|
+
// data: {
|
|
62
|
+
// fields: record,
|
|
63
|
+
// },
|
|
64
|
+
// },
|
|
65
|
+
// lark.withTenantToken(access_token)
|
|
66
|
+
// );
|
|
67
|
+
// }
|
|
68
|
+
|
|
69
|
+
// Split later
|
|
70
|
+
export async function sendStatisticX3Message(data: { date: string; content: string }) {
|
|
71
|
+
const access_token = await getAccessToken();
|
|
72
|
+
const { date, content } = data;
|
|
73
|
+
const messageContent = {
|
|
74
|
+
type: "template",
|
|
75
|
+
data: {
|
|
76
|
+
template_id: getEnv().LARK_X3_TEMPLATE_ID,
|
|
77
|
+
// template_id: 'ctp_AAdI5Sp48YUT',
|
|
78
|
+
template_variable: {
|
|
79
|
+
date,
|
|
80
|
+
content,
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
return larkClient.im.message.create(
|
|
85
|
+
{
|
|
86
|
+
params: {
|
|
87
|
+
receive_id_type: "chat_id",
|
|
88
|
+
},
|
|
89
|
+
data: {
|
|
90
|
+
receive_id: getEnv().LARK_X3_GROUP_ID,
|
|
91
|
+
msg_type: "interactive",
|
|
92
|
+
content: JSON.stringify(messageContent),
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
lark.withTenantToken(access_token)
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export async function sendLarkTextMessage(p: { message_content: { text: string }; receive_id: string }) {
|
|
100
|
+
const { message_content, receive_id } = p;
|
|
101
|
+
const access_token = await getAccessToken();
|
|
102
|
+
return larkClient.im.message.create(
|
|
103
|
+
{
|
|
104
|
+
params: {
|
|
105
|
+
receive_id_type: "chat_id",
|
|
106
|
+
},
|
|
107
|
+
data: {
|
|
108
|
+
receive_id,
|
|
109
|
+
msg_type: "text",
|
|
110
|
+
content: JSON.stringify(message_content),
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
lark.withTenantToken(access_token)
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export async function sendMessageToX3Group(message_content: { text: string }) {
|
|
118
|
+
return sendLarkTextMessage({
|
|
119
|
+
receive_id: getEnv().LARK_X3_GROUP_ID,
|
|
120
|
+
message_content,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import { getEnv } from "../env";
|
|
3
|
+
import { Gimo, GimoLending } from "./types";
|
|
4
|
+
|
|
5
|
+
async function getAccessToken() {
|
|
6
|
+
const url = `${getEnv().DASH_URL}/api/v1/auth/admin/login`;
|
|
7
|
+
return axios
|
|
8
|
+
.post<Gimo.LoginRes>(url, {
|
|
9
|
+
password: getEnv().PASSWORD,
|
|
10
|
+
username: getEnv().USER_NAME,
|
|
11
|
+
})
|
|
12
|
+
.then((res) => res.data.access_token);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export async function listApplication(p: GimoLending.FilterApplication) {
|
|
16
|
+
const url = `${getEnv().LENDING_URL}/api/v1/admin/lending/application/pagination`;
|
|
17
|
+
const access_token = await getAccessToken();
|
|
18
|
+
return axios
|
|
19
|
+
.get<{
|
|
20
|
+
result: {
|
|
21
|
+
content: GimoLending.Application[];
|
|
22
|
+
size: number;
|
|
23
|
+
total_elements: number;
|
|
24
|
+
total_pages: number;
|
|
25
|
+
};
|
|
26
|
+
}>(url, {
|
|
27
|
+
headers: {
|
|
28
|
+
Authorization: "Bearer " + access_token,
|
|
29
|
+
},
|
|
30
|
+
params: {
|
|
31
|
+
...p,
|
|
32
|
+
sort: "created_at,DESC",
|
|
33
|
+
},
|
|
34
|
+
})
|
|
35
|
+
.then((res) => res.data.result);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export async function statisticLoan(p: GimoLending.FilterLoan) {
|
|
39
|
+
const url = `${getEnv().LENDING_URL}/api/v1/admin/lending/instance/pagination`;
|
|
40
|
+
const access_token = await getAccessToken();
|
|
41
|
+
return axios
|
|
42
|
+
.get<{
|
|
43
|
+
result: {
|
|
44
|
+
loan_instance_list_statistics: GimoLending.LoanStatistic;
|
|
45
|
+
};
|
|
46
|
+
}>(url, {
|
|
47
|
+
headers: {
|
|
48
|
+
Authorization: "Bearer " + access_token,
|
|
49
|
+
},
|
|
50
|
+
params: {
|
|
51
|
+
...p,
|
|
52
|
+
sort: "created_at,DESC",
|
|
53
|
+
},
|
|
54
|
+
})
|
|
55
|
+
.then((res) => res.data.result.loan_instance_list_statistics);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export async function statisticX3(p: GimoLending.FilterApplication) {
|
|
59
|
+
const { created_from, created_to } = p;
|
|
60
|
+
try {
|
|
61
|
+
const { content: applications, total_elements } = await listApplication({
|
|
62
|
+
created_to,
|
|
63
|
+
created_from,
|
|
64
|
+
size: 1_000_000,
|
|
65
|
+
});
|
|
66
|
+
const loan_statistic = await statisticLoan({
|
|
67
|
+
disbursementTimeFrom: created_from,
|
|
68
|
+
disbursementTimeTo: created_to,
|
|
69
|
+
});
|
|
70
|
+
const total_appraisal = applications.filter(
|
|
71
|
+
(item) => item.status === GimoLending.LendingApplicationStatus.APPRAISAL
|
|
72
|
+
).length;
|
|
73
|
+
const total_approval = applications.filter(
|
|
74
|
+
(item) => item.status === GimoLending.LendingApplicationStatus.APPROVAL
|
|
75
|
+
).length;
|
|
76
|
+
const total_confrimed = applications.filter(
|
|
77
|
+
(item) => item.status === GimoLending.LendingApplicationStatus.CONFIRMED
|
|
78
|
+
).length;
|
|
79
|
+
const total_rejected = applications.filter(
|
|
80
|
+
(item) => item.status === GimoLending.LendingApplicationStatus.REJECTED
|
|
81
|
+
).length;
|
|
82
|
+
const total_signed = applications.filter(
|
|
83
|
+
(item) => item.status === GimoLending.LendingApplicationStatus.SIGNED
|
|
84
|
+
).length;
|
|
85
|
+
const total_closed = applications.filter(
|
|
86
|
+
(item) => item.status === GimoLending.LendingApplicationStatus.CLOSED
|
|
87
|
+
).length;
|
|
88
|
+
|
|
89
|
+
const total_dibursed = applications.filter(
|
|
90
|
+
(item) => item.disbursement_status === GimoLending.LoanDisbursementStatus.DISBURSED
|
|
91
|
+
).length;
|
|
92
|
+
|
|
93
|
+
return {
|
|
94
|
+
total: total_elements,
|
|
95
|
+
total_appraisal,
|
|
96
|
+
total_approval,
|
|
97
|
+
total_confrimed,
|
|
98
|
+
total_rejected,
|
|
99
|
+
total_signed,
|
|
100
|
+
total_closed,
|
|
101
|
+
total_dibursed,
|
|
102
|
+
loan_statistic,
|
|
103
|
+
};
|
|
104
|
+
} catch (error) {
|
|
105
|
+
throw error;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
2
|
+
export namespace Gimo {
|
|
3
|
+
export interface LoginRes {
|
|
4
|
+
user_id: number;
|
|
5
|
+
access_token: string;
|
|
6
|
+
access_token_expires_at: number;
|
|
7
|
+
token_type: string;
|
|
8
|
+
change_password_token: string;
|
|
9
|
+
require_change_password: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface CustomerEWA {
|
|
13
|
+
customer_id: number;
|
|
14
|
+
customer_full_name: string;
|
|
15
|
+
customer_code?: string;
|
|
16
|
+
identify_number?: string;
|
|
17
|
+
employee_id?: number;
|
|
18
|
+
employee_code?: string;
|
|
19
|
+
partner_id?: number;
|
|
20
|
+
partner_name?: string;
|
|
21
|
+
debt_collection_type?: string;
|
|
22
|
+
onboard_method?: string;
|
|
23
|
+
verification_status?: string;
|
|
24
|
+
working_status: string;
|
|
25
|
+
dda_status?: string;
|
|
26
|
+
ewa_longest_over_due_day: string;
|
|
27
|
+
ewa_debt_amount?: number;
|
|
28
|
+
ewa_status?: string;
|
|
29
|
+
customer_phone_number: string;
|
|
30
|
+
created_at: string;
|
|
31
|
+
updated_at: string;
|
|
32
|
+
bank_full_name?: string;
|
|
33
|
+
bank_id?: number;
|
|
34
|
+
bank_name?: string;
|
|
35
|
+
bank_acc_number?: string;
|
|
36
|
+
customer_service_id?: number;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface Customer {
|
|
40
|
+
id: number;
|
|
41
|
+
ewa_customer_id?: number;
|
|
42
|
+
customer_code?: string;
|
|
43
|
+
avatar?: string;
|
|
44
|
+
phone_number?: string;
|
|
45
|
+
full_name?: string;
|
|
46
|
+
dda_code?: string;
|
|
47
|
+
active?: boolean;
|
|
48
|
+
created_at?: string;
|
|
49
|
+
created_by?: string;
|
|
50
|
+
verified_at?: string;
|
|
51
|
+
is_verified?: boolean;
|
|
52
|
+
customer_ewa_id?: number;
|
|
53
|
+
link_employees?: LinkedEmployee[];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface EmployeeV1 {
|
|
57
|
+
id: number;
|
|
58
|
+
active: boolean;
|
|
59
|
+
suspend: boolean;
|
|
60
|
+
gender: string;
|
|
61
|
+
birth_date: Date;
|
|
62
|
+
status: string;
|
|
63
|
+
code: string;
|
|
64
|
+
partner_id: number;
|
|
65
|
+
organization_id: number;
|
|
66
|
+
organization_name: number;
|
|
67
|
+
partner_name: string;
|
|
68
|
+
mobile_phone: string;
|
|
69
|
+
first_name: string;
|
|
70
|
+
middle_name: string;
|
|
71
|
+
last_name: string;
|
|
72
|
+
id_number: string;
|
|
73
|
+
bank_id: number;
|
|
74
|
+
bank_name: string;
|
|
75
|
+
bank_first_name: string;
|
|
76
|
+
bank_middle_name: string;
|
|
77
|
+
bank_last_name: string;
|
|
78
|
+
bank_full_name: string;
|
|
79
|
+
bank_acc_number: string;
|
|
80
|
+
start_date: string;
|
|
81
|
+
id_issued_date: Date;
|
|
82
|
+
id_issued_by: string;
|
|
83
|
+
number_of_dependents: number;
|
|
84
|
+
married_status: boolean;
|
|
85
|
+
mail_address: string;
|
|
86
|
+
address: string;
|
|
87
|
+
position: string;
|
|
88
|
+
wage: number;
|
|
89
|
+
full_name: string;
|
|
90
|
+
customer_code: string;
|
|
91
|
+
customer_id: number; // customer_id actually is ewa_customer_id: this is an old API from ewa service. new customer_id is migrated to customer service.
|
|
92
|
+
rules: any[];
|
|
93
|
+
total_contract_disbursed: number;
|
|
94
|
+
verified: boolean;
|
|
95
|
+
total_disbursed_contract_in_pay_period: number;
|
|
96
|
+
disbursed_contract_in_month: boolean;
|
|
97
|
+
bank_acc_verified: boolean;
|
|
98
|
+
updated_at: Date;
|
|
99
|
+
created_at: Date;
|
|
100
|
+
remaining_amount: number;
|
|
101
|
+
employee_timekeepers: any[];
|
|
102
|
+
has_income_from_attendance: boolean;
|
|
103
|
+
dda_code?: string;
|
|
104
|
+
dda_status?: string;
|
|
105
|
+
reason?: string;
|
|
106
|
+
seniority?: number;
|
|
107
|
+
partner?: any;
|
|
108
|
+
cancel_dda_count?: number;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface EmployeeInfo {
|
|
112
|
+
employee_id: number;
|
|
113
|
+
employee_code?: string;
|
|
114
|
+
verified?: boolean;
|
|
115
|
+
employee?: EmployeeV1 & { onboard_id?: number };
|
|
116
|
+
link_employees?: LinkedEmployee[];
|
|
117
|
+
partner_id?: number;
|
|
118
|
+
partner?: any;
|
|
119
|
+
}
|
|
120
|
+
export interface LinkedEmployee {
|
|
121
|
+
employee_id: number;
|
|
122
|
+
employee_code: string;
|
|
123
|
+
partner_id: number;
|
|
124
|
+
partner_name: string;
|
|
125
|
+
partner_onboard_method?: string;
|
|
126
|
+
verification_status: boolean;
|
|
127
|
+
work_status: boolean;
|
|
128
|
+
verification_time?: string;
|
|
129
|
+
debt_collection?: string;
|
|
130
|
+
onboard_id?: number;
|
|
131
|
+
allow_access?: boolean;
|
|
132
|
+
status?: string;
|
|
133
|
+
reason?: string;
|
|
134
|
+
seniority?: number;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export interface Contract {
|
|
138
|
+
[key: string]: any;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export interface PaymentTxn {
|
|
142
|
+
code?: string;
|
|
143
|
+
ref_transaction_id?: number;
|
|
144
|
+
ref_transaction_code?: string;
|
|
145
|
+
bank_integration_name?: string;
|
|
146
|
+
transfer_type?: string;
|
|
147
|
+
ref_customer_id?: number;
|
|
148
|
+
customer_code?: string;
|
|
149
|
+
customer_name?: string;
|
|
150
|
+
customer_phone?: string;
|
|
151
|
+
bank_account_number?: string;
|
|
152
|
+
bank_account_name?: string;
|
|
153
|
+
bank_name?: string;
|
|
154
|
+
amount?: number;
|
|
155
|
+
ref_product_id?: number;
|
|
156
|
+
ref_product_name?: string;
|
|
157
|
+
response_time: string;
|
|
158
|
+
trace_key?: string;
|
|
159
|
+
status?: string;
|
|
160
|
+
service_source?: string;
|
|
161
|
+
request_time?: string;
|
|
162
|
+
updated_at?: string;
|
|
163
|
+
debit_resource_number?: string;
|
|
164
|
+
display_error_message?: string;
|
|
165
|
+
suggestion_message?: string;
|
|
166
|
+
request_logs?: any[];
|
|
167
|
+
partner_id?: number;
|
|
168
|
+
[key: string]: any;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export interface ContractWithTxn extends Contract {
|
|
172
|
+
transactions: PaymentTxn[];
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export interface AccountingCustomer {
|
|
176
|
+
customer_fee_amount: number;
|
|
177
|
+
outstanding_balance: number;
|
|
178
|
+
partner_fee_amount: number;
|
|
179
|
+
total_actual_amount: number;
|
|
180
|
+
total_contract_number: number;
|
|
181
|
+
total_fee_amount: number;
|
|
182
|
+
total_request_amount: number;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
export namespace GimoLending {
|
|
2
|
+
export interface Application {
|
|
3
|
+
id: string;
|
|
4
|
+
fund_provider_code: string;
|
|
5
|
+
product_scheme_name: any;
|
|
6
|
+
status: string;
|
|
7
|
+
bank_id: number;
|
|
8
|
+
bank_account_number: string;
|
|
9
|
+
bank_code: string;
|
|
10
|
+
bank_account_name: string;
|
|
11
|
+
loan_request: LoanRequest;
|
|
12
|
+
loan_offer?: LoanOffer;
|
|
13
|
+
loan_instance: any;
|
|
14
|
+
customer_info?: CustomerInfo;
|
|
15
|
+
underwriting_decision_result: UnderwritingDecisionResult;
|
|
16
|
+
suspend_registration_reason?: string;
|
|
17
|
+
suspend_registration_until?: string;
|
|
18
|
+
disbursement_time?: string;
|
|
19
|
+
disbursement_status?: string;
|
|
20
|
+
contract_error_code?: string;
|
|
21
|
+
reject_message?: string;
|
|
22
|
+
contract_status?: string;
|
|
23
|
+
created_at: string;
|
|
24
|
+
updated_at: string;
|
|
25
|
+
created_by: string;
|
|
26
|
+
updated_by: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface FilterApplication {
|
|
30
|
+
created_from?: string;
|
|
31
|
+
created_to?: string;
|
|
32
|
+
page?: number;
|
|
33
|
+
size?: number;
|
|
34
|
+
sort?: string;
|
|
35
|
+
[key: string]: any;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface FilterLoan {
|
|
39
|
+
disbursementTimeFrom?: string;
|
|
40
|
+
disbursementTimeTo?: string;
|
|
41
|
+
page?: number;
|
|
42
|
+
size?: number;
|
|
43
|
+
sort?: string;
|
|
44
|
+
[key: string]: any;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface LoanStatistic {
|
|
48
|
+
total_disbursement_amount: number;
|
|
49
|
+
total_interest_amount: number;
|
|
50
|
+
total_payment_amount: number;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface LoanOffer {
|
|
54
|
+
id: string;
|
|
55
|
+
loan_offer_amount?: number | null;
|
|
56
|
+
interest_rate: number;
|
|
57
|
+
repayment_amount_per_repayment: number;
|
|
58
|
+
repayment_frequency_type: string;
|
|
59
|
+
repayment_every: number;
|
|
60
|
+
number_of_repayments: number;
|
|
61
|
+
offer_at: string;
|
|
62
|
+
offer_expire_at: string;
|
|
63
|
+
created_by: string;
|
|
64
|
+
created_at: string;
|
|
65
|
+
updated_by: string;
|
|
66
|
+
updated_at: string;
|
|
67
|
+
offer_emi?: number;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface LoanRequest {
|
|
71
|
+
id: string;
|
|
72
|
+
submit_form_id: number;
|
|
73
|
+
loan_request_amount?: number | null;
|
|
74
|
+
interest_rate: number;
|
|
75
|
+
repayment_amount_per_repayment: number;
|
|
76
|
+
repayment_frequency_type: string;
|
|
77
|
+
repayment_every: number;
|
|
78
|
+
number_of_repayments: number;
|
|
79
|
+
created_by: string;
|
|
80
|
+
created_at: string;
|
|
81
|
+
updated_by: string;
|
|
82
|
+
updated_at: string;
|
|
83
|
+
request_emi?: number;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface CustomerInfo {
|
|
87
|
+
customer_service_id: number;
|
|
88
|
+
customer_code: string;
|
|
89
|
+
customer_ewa_id: number;
|
|
90
|
+
phone_number: string;
|
|
91
|
+
full_name: string;
|
|
92
|
+
occupation: string;
|
|
93
|
+
partner_id: number;
|
|
94
|
+
partner_name: string;
|
|
95
|
+
position: any;
|
|
96
|
+
average_income: number;
|
|
97
|
+
sector_income: number;
|
|
98
|
+
address: string;
|
|
99
|
+
province_code: string;
|
|
100
|
+
province_name: string;
|
|
101
|
+
ward_code: string;
|
|
102
|
+
ward_name: string;
|
|
103
|
+
district_code: string;
|
|
104
|
+
district_name: string;
|
|
105
|
+
marital_status: string;
|
|
106
|
+
ekyc_request_id: number;
|
|
107
|
+
id_front_image: string;
|
|
108
|
+
id_back_image: string;
|
|
109
|
+
id_issue_date: string;
|
|
110
|
+
id_issue_loc: string;
|
|
111
|
+
identification_number?: number;
|
|
112
|
+
contact_person_list: ContactPersonList[];
|
|
113
|
+
tem_address?: string;
|
|
114
|
+
tem_district_code?: string;
|
|
115
|
+
tem_district_name?: string;
|
|
116
|
+
tem_province_code?: string;
|
|
117
|
+
tem_province_name?: string;
|
|
118
|
+
tem_ward_code?: string;
|
|
119
|
+
tem_ward_name?: string;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface ContactPersonList {
|
|
123
|
+
full_name: string;
|
|
124
|
+
phone_number: string;
|
|
125
|
+
relation_ship: string;
|
|
126
|
+
identification_number?: string;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export interface UnderwritingDecisionResult {
|
|
130
|
+
hard_rule?: {
|
|
131
|
+
error_message: string;
|
|
132
|
+
screen_solution: string;
|
|
133
|
+
trace_id: string;
|
|
134
|
+
hard_rule_criteria: HardRuleCriteria[];
|
|
135
|
+
pass: boolean;
|
|
136
|
+
};
|
|
137
|
+
segment_rule?: SegmentRuleCriteria;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export interface HardRuleCriteria {
|
|
141
|
+
criteria: string;
|
|
142
|
+
is_passed: boolean;
|
|
143
|
+
key: string;
|
|
144
|
+
key_banned: string;
|
|
145
|
+
value: any;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export interface SegmentRuleCriteria {
|
|
149
|
+
portfolio: string;
|
|
150
|
+
product_scheme: any;
|
|
151
|
+
income: number;
|
|
152
|
+
seniority: number;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export enum LendingApplicationStatus {
|
|
156
|
+
APPRAISAL = "APPRAISAL",
|
|
157
|
+
APPROVAL = "APPROVAL",
|
|
158
|
+
CONFIRMED = "CONFIRMED",
|
|
159
|
+
REJECTED = "REJECTED",
|
|
160
|
+
SIGNED = "SIGNED",
|
|
161
|
+
CLOSED = "CLOSED",
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export enum LoanDisbursementStatus {
|
|
165
|
+
DISBURSING = "DISBURSING",
|
|
166
|
+
DISBURSED = "DISBURSED",
|
|
167
|
+
FAILED = "FAILED",
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export interface StatisticX3 {
|
|
171
|
+
total?: number;
|
|
172
|
+
total_appraisal?: number;
|
|
173
|
+
total_approval?: number;
|
|
174
|
+
total_confrimed?: number;
|
|
175
|
+
total_rejected?: number;
|
|
176
|
+
total_signed?: number;
|
|
177
|
+
total_closed?: number;
|
|
178
|
+
total_dibursed?: number;
|
|
179
|
+
loan_statistic?: GimoLending.LoanStatistic;
|
|
180
|
+
}
|
|
181
|
+
}
|
package/src/test.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ensureEnvVariables, getEnv } from "./env";
|
|
2
|
+
import { sendLarkTextMessage, sendMessageToX3Group } from "./services/lark.service";
|
|
3
|
+
import {
|
|
4
|
+
statisticX3RangeTool,
|
|
5
|
+
statisticX3TodayTool,
|
|
6
|
+
statisticX3Tool,
|
|
7
|
+
statisticX3WeekTool,
|
|
8
|
+
statisticX3YesterdayTool,
|
|
9
|
+
} from "./tools";
|
|
10
|
+
|
|
11
|
+
async function setupTest() {
|
|
12
|
+
ensureEnvVariables();
|
|
13
|
+
const sendMessageToLark = getEnv().SEND_MESSAGE_TO_LARK;
|
|
14
|
+
|
|
15
|
+
// const reuslt = await statisticX3TodayTool({ sendMessageToLark: false });
|
|
16
|
+
// console.log(reuslt);
|
|
17
|
+
// const reuslt = await statisticX3Tool({ sendMessageToLark: false, date: "11/06/2025" });
|
|
18
|
+
// console.log(reuslt);
|
|
19
|
+
// const reuslt = await statisticX3WeekTool({ sendMessageToLark: false });
|
|
20
|
+
// console.log(reuslt);
|
|
21
|
+
// const reuslt = await statisticX3YesterdayTool({ sendMessageToLark: false });
|
|
22
|
+
// console.log(reuslt);
|
|
23
|
+
|
|
24
|
+
// const reuslt = await statisticX3RangeTool({
|
|
25
|
+
// sendMessageToLark: sendMessageToLark,
|
|
26
|
+
// startDateStr: "10-06-2025",
|
|
27
|
+
// endDateStr: "20-06-2025",
|
|
28
|
+
// });
|
|
29
|
+
// console.log(reuslt);
|
|
30
|
+
// const inovationMess =
|
|
31
|
+
// "Một tuần làm việc sắp kết thúc, tất cả chúng ta đều đã rất nỗ lực và cố gắng. Hãy cùng điểm nhanh lại những thông số của dự án nhé. Dành thời gian cho bản thân và nạp năng lượng cho tuần mới nhé cả nhé GIMO";
|
|
32
|
+
// const inovationMess2 = "end of week";
|
|
33
|
+
// await sendMessageToX3Group({ text: inovationMess });
|
|
34
|
+
// await statisticX3WeekTool({ sendMessageToLark: true });
|
|
35
|
+
// console.log('done');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
setupTest();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './statistic-x3';
|