-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path058f26eef9434b33bf81d0e3b0119c70_t82zlgqp.js
48 lines (48 loc) · 1.62 KB
/
058f26eef9434b33bf81d0e3b0119c70_t82zlgqp.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
let AbstractTrigger = require("AbstractTrigger");
class MyTrigger extends AbstractTrigger {
execute(context, param) {
let func1 = extrequire("GT80266AT1.backDefaultGroup.getOpenApiToken");
let res = func1.execute(null);
var token = res.access_token;
let org = param.org;
let warehouse = param.warehouse;
let product = param.product;
let productsku = param.productsku;
let getsdUrl = "https://www.example.com/" + token;
let body = {
org: org,
warehouse: warehouse,
product: product,
productsku: productsku
};
var contenttype = "application/json;charset=UTF-8";
var header = { "Content-Type": contenttype };
let apiResponse = postman("POST", getsdUrl, JSON.stringify(header), JSON.stringify(body));
let apiResponsejson = JSON.parse(apiResponse);
let availableqty = 0;
let message = apiResponsejson.message;
let code = undefined;
if (apiResponsejson.code == "200") {
let data = apiResponsejson.data;
code = 200;
if (data != null && data.length > 0) {
for (var i = 0; i < data.length; i++) {
let availableqtyData = data[i];
//库存状态为0和正常的数据之和等于剩余现存量
if (availableqtyData.stockStatusDoc == 0 || availableqtyData.stockStatusDoc == "2114873437102017") {
availableqty = availableqty + availableqtyData.availableqty;
}
}
}
} else {
code = apiResponsejson.code;
}
let result = {
code: code,
availableqty: availableqty,
message: message
};
return { result };
}
}
exports({ entryPoint: MyTrigger });