-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path044b099deaf84f6db766b23b7119a11a_kgrtzk0r.js
178 lines (178 loc) · 7.58 KB
/
044b099deaf84f6db766b23b7119a11a_kgrtzk0r.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
let AbstractTrigger = require("AbstractTrigger");
class MyTrigger extends AbstractTrigger {
execute(context, param) {
try {
//发送人
var username = JSON.parse(AppContext()).currentUser.name;
//有效性后端链接
var EffiveAPI = "AT18DC6E5E09E00008.backDesignerFunction.getEffive";
//接口地址后端链接
var HttpsAPI = "AT18DC6E5E09E00008.backDesignerFunction.getHttps";
//解析后勤策后端链接
var ZEQCHttpAPI = "AT18DC6E5E09E00008.backDesignerFunction.getZEQCHttp";
var header = {
"Content-Type": "application/json"
};
var soid = param.data[0].id;
var url = "https://www.example.com/" + soid + "";
var apiResponse = openLinker("GET", url, "ST", JSON.stringify({}));
var retapiResponse = JSON.parse(apiResponse);
if (retapiResponse.code == "200") {
if (retapiResponse.data != undefined) {
var sodata = retapiResponse.data;
var yzck = sodata.warehouse;
if (yzck == "" || yzck == undefined) {
return {};
} else {
var yzckurl = "https://www.example.com/" + yzck + "";
var yzckResponse = openLinker("GET", yzckurl, "ST", JSON.stringify({}));
var yzckResponseres = JSON.parse(yzckResponse);
if (yzckResponseres.code == "200") {
if (yzckResponseres.data != undefined && yzckResponseres.data.defineCharacter != undefined && yzckResponseres.data.defineCharacter.A0010 == "1") {
} else {
return {};
}
} else {
return {};
}
}
var pinpai = "";
if (sodata.salesOutDefineCharacter != undefined) {
pinpai = sodata.salesOutDefineCharacter.attrext6;
if (pinpai == "" || pinpai == undefined) {
return {};
}
var resattrext6 = ObjectStore.queryByYonQL("select code,randKeywords from pc.brand.Brand where id=" + pinpai + "", "productcenter");
if (resattrext6.length > 0) {
if (resattrext6[0].randKeywords != "接口") {
return {};
}
} else {
return {};
}
} else {
return {};
}
if (sodata.accountOrg == 2830809192386816 || sodata.salesOrgId_code == 2830809192386816) {
var funAPI12 = extrequire(EffiveAPI);
var resAPI12 = funAPI12.execute("API12");
if (resAPI12.r) {
var srcno = "";
srcno = sodata.srcBillNO;
sodata.details.forEach((row) => {
if (srcno != "" || srcno != undefined) {
srcno = row.upcode;
}
});
var ckcode = "";
if (sodata.warehouse != undefined) {
var ckres = ObjectStore.queryByYonQL(" select code from aa.warehouse.Warehouse where id=" + sodata.warehouse + "", "productcenter");
if (ckres.length > 0) {
ckcode = ckres[0].code;
}
}
var qcinsert = {
sent_no: sodata.code,
sent_date: sodata.vouchdate,
order_no: srcno,
order_id: "",
sent_storehouse_code: ckcode,
sign_status: "FH_DQS",
business_status: "",
receive_name: sodata.cReceiver,
receive_phone: sodata.cReceiveMobile,
receive_tel: sodata.cReceiveMobile,
receive_addr: sodata.cReceiveAddress,
receive_addr_id: "",
sent_receive_code: "",
prods: []
};
sodata.details.forEach((row) => {
var prod = {
posnr: row.lineno / 10,
sent_num: row.qty,
sent_input_unit: "",
sent_input_unit_name: row.unitName,
sent_remark: ""
};
qcinsert.prods.push(prod);
});
var funhttp12 = extrequire(HttpsAPI);
var reshttp12 = funhttp12.execute("HttpAPI12");
var http12 = reshttp12.http;
//获取顺丰接口1地址
var funhttpqc12 = extrequire(ZEQCHttpAPI);
var reshttpqc12 = funhttpqc12.execute(http12, qcinsert);
var getdizhi = reshttpqc12.di;
//调用勤策接口1
var apiResponse12 = postman("post", getdizhi, JSON.stringify(header), JSON.stringify(qcinsert));
var urllog12 = "https://www.example.com/";
var bodylog12 = { fasongren: username, SrcJSON: JSON.stringify(qcinsert), ToJSON: apiResponse12, Actype: 12 }; //请求参数
var apiResponselog12 = openLinker("POST", urllog12, "ST", JSON.stringify(bodylog12));
var apiResponsejson12 = JSON.parse(apiResponse12);
if (apiResponsejson12.return_code == "0") {
} else {
throw new Error("勤策接口:" + sodata.code + apiResponsejson12.return_msg);
}
}
}
if (sodata.accountOrg == 1772610381349388297 || sodata.salesOrgId_code == 1772610381349388297) {
var funAPI13 = extrequire(EffiveAPI);
var resAPI13 = funAPI13.execute("API13");
if (resAPI13.r) {
var ckcode = "";
if (sodata.warehouse != undefined) {
var ckres = ObjectStore.queryByYonQL(" select code from aa.warehouse.Warehouse where id=" + sodata.warehouse + "", "productcenter");
if (ckres.length > 0) {
ckcode = ckres[0].code;
}
}
var khcode1 = "";
var khdata1 = ObjectStore.queryByYonQL("select code from aa.merchant.Merchant where id=" + sodata.cust + "", "productcenter");
if (khdata1.length > 0) {
khcode1 = khdata1[0].code;
}
var lsdoc = "";
sodata.details.forEach((row) => {
lsdoc = row.upcode;
});
var qcdh = {
cmCode: khcode1,
cmName: sodata.cust_name,
distSendNo: lsdoc,
sendTime: sodata.vouchdate,
logNo: sodata.cLogisticsBillNo,
logState: ""
};
var funhttp13 = extrequire(HttpsAPI);
var reshttp13 = funhttp13.execute("HttpAPI13");
var http13 = reshttp13.http;
//获取顺丰接口1地址
var funhttpqc13 = extrequire(ZEQCHttpAPI);
var reshttpqc13 = funhttpqc13.execute(http13, qcdh);
var getdizhi = reshttpqc13.di;
//调用勤策接口1
var apiResponse13 = postman("post", getdizhi, JSON.stringify(header), JSON.stringify(qcdh));
var urllog13 = "https://www.example.com/";
var bodylog13 = { fasongren: username, SrcJSON: JSON.stringify(qcdh), ToJSON: apiResponse13, Actype: 13 }; //请求参数
var apiResponselog13 = openLinker("POST", urllog13, "ST", JSON.stringify(bodylog13));
var apiResponsejson13 = JSON.parse(apiResponse13);
if (apiResponsejson13.return_code == "0") {
} else {
throw new Error("勤策接口:" + sodata.code + apiResponsejson13.return_msg);
}
}
}
}
} else {
throw new Error(retapiResponse.message);
}
} catch (e) {
throw new Error(e);
}
return {};
}
}
exports({
entryPoint: MyTrigger
});