seckill.js
1.65 KB
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
'use strict';
const API = global.yoho.API;
const paymentProcess = require(global.utils + '/payment-process');
/**
* 获取 获取秒杀信息接口
* doc: http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/%E5%95%86%E5%93%81%E5%88%97%E8%A1%A8/seckill.md
*/
exports.skillData = product_skn => {
let queryData = {
method: 'app.seckill.data',
product_skn
};
return API.post('', queryData);
};
exports.payment = (options, orderInfo, orderComputerData) => {
let queryData = Object.assign({
method: 'app.Seckill.payment',
}, options);
return API.post('', queryData)
.then(result => {
// TODO 数据处理
if (result.code === 200 && result.data) {
result.data = paymentProcess.tranformPayment(result.data, orderInfo, null, null, orderComputerData);
}
return result;
});
};
// http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/%E8%AE%A2%E5%8D%95/%E7%AB%8B%E5%8D%B3%E8%B4%AD%E4%B9%B0.md#L628
exports.compute = options => {
let url = '';
let queryData = Object.assign({
method: 'app.Seckill.compute',
}, options);
return API.post(url, queryData).then(result => {
// TODO 数据处理
if (result.code === 200 && result.data) {
result.data.yohoCoinCompute = paymentProcess.yohoCoinCompute(result.data);
}
return result;
});
};
exports.submit = options => {
let url = '';
let queryData = Object.assign({
method: 'app.Seckill.submit'
}, options);
return API.post(url, queryData, {
headers: {'X-Forwarded-For': options.ip || ''}
});
};