-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path020fc6d172724017bd6ad391a5b3177d_zjhrilpq.js
60 lines (60 loc) · 2.01 KB
/
020fc6d172724017bd6ad391a5b3177d_zjhrilpq.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
let AbstractAPIHandler = require("AbstractAPIHandler");
class MyAPIHandler extends AbstractAPIHandler {
execute(request) {
var failurl = "https://test-aipos.honghuotai.com:8261/erpService/syncShopDayDataForUploadFail";
var succselurl = "https://test-aipos.honghuotai.com:8261/erpService/syncShopDayDataForUploadSuccess";
var akey = "yourkeyHere";
var header = {
"Content-Type": "application/json;charset=UTF-8"
};
var objects = request.data;
objects.forEach((object) => {
var salemoneydetails = object.salemoneydetailList;
salemoneydetails.forEach((salemoneydetail) => {
salemoneydetail.aftermoveaccmoney = salemoneydetail.realmoney;
});
});
var res = "";
//插入数据
try {
res = ObjectStore.insert("GT13741AT37.GT13741AT37.dayclosebill", objects, "e297ef0b");
} catch (err) {
res = "123";
objects.forEach((data) => {
let hhtObj = {
akey: akey,
billNo: data.dayclosecode,
shopCode: data.erporgcode,
loginCode: "001",
loginName: "YonSuite默认用户",
remark: err
};
var strResponse = postman("post", failurl, JSON.stringify(header), JSON.stringify(hhtObj));
var strResponseobj = JSON.parse(strResponse);
});
return { err: err };
}
var billNos = new Array();
var billNosMaps = new Array();
objects.forEach((data) => {
billNos.push(data.dayclosecode);
var billNosMap = {
billNo: data.dayclosecode,
erpBillNo: data.dayclosecode
};
billNosMaps.push(billNosMap);
});
var hhtsuccObj = {
akey: akey,
billNos: billNos,
billNosMap: billNosMaps,
shopCode: objects[0].erporgcode,
loginCode: "001",
loginName: "YonSuite默认用户"
};
var strResponse = postman("post", succselurl, JSON.stringify(header), JSON.stringify(hhtsuccObj));
var strResponseobj = JSON.parse(strResponse);
return { res: res };
}
}
exports({ entryPoint: MyAPIHandler });