ticket-api.js
1.37 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
62
63
64
65
66
67
68
69
70
71
72
73
74
/**
* Created by TaoHuang on 2017/6/22.
*/
const api = global.yoho.API;
/**
* 电子票下单
* @param uid 用户id
* @param sku 商品sku
* @param count 购买数量 1-4
* @param mobile 手机号码
* @param yohoCoin 有货币
*/
function submit(uid, sku, count, mobile, yohoCoin, other = {}) {
let params = {
method: 'app.shopping.submitTicket',
uid,
product_sku: sku,
buy_number: count,
mobile: mobile
};
if (yohoCoin) {
params.use_yoho_coin = yohoCoin / 100;
}
if (other.giftCard) {
Object.assign(params, {
gift_card_code: other.giftCard
});
}
if (other.udid) {
Object.assign(params, {
udid: other.udid
});
}
return api.get('', params);
}
/**
* 电子票添加和查询
* @param uid 用户 id
* @param sku 商品sku
* @param count 购买数量 1-4
* @param yohoCoin 有货币
*/
function add(uid, sku, count, yohoCoin, other = {}) {
let params = {
method: 'app.shopping.ticket',
uid,
product_sku: sku,
buy_number: count
};
if (yohoCoin) {
params.use_yoho_coin = yohoCoin / 100;
}
if (other.giftCard) {
Object.assign(params, {
gift_card_code: other.giftCard
});
}
return api.get('', params);
}
module.exports = {
submit,
add
};