ticketsConfirm.js
3.6 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
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
'use strict';
const api = global.yoho.API;
const helpers = global.yoho.helpers;
// 展览票(单日票)skn
const SINGLE_TICKETS_SKN = 51335912;
const checkTickets = (param) => {
return api.get('', {
method: 'app.shopping.ticket',
uid: param.uid,
product_sku: param.productSku,
buy_number: param.buyNumber,
use_yoho_coin: param.useYohoCoin || 0,
yoho_coin_mode: param.yohoCoinMode ? param.yohoCoinMode : 0
}, {
code: 200
}).then((result) => {
return result;
});
};
const yohoCoinCompute = ($orderCompute) => {
let $yohoCoinData = {
totalYohoCoinNum: 0,
yohoCoin: 0,
useYohoCoin: 0,
yohoCoinClick: 0,
yohoCoinMsg: '',
yoho_coin_pay_rule: []
};
if (!$orderCompute || !$orderCompute.yoho_coin_pay_rule) {
return $yohoCoinData;
}
$yohoCoinData = {
totalYohoCoinNum: $orderCompute.total_yoho_coin_num ? $orderCompute.total_yoho_coin_num : 0,
yohoCoin: $orderCompute.yoho_coin ? $orderCompute.yoho_coin : 0,
useYohoCoin: $orderCompute.use_yoho_coin ? $orderCompute.use_yoho_coin : 0,
yohoCoinClick: 0,
yohoCoinMsg: '',
yoho_coin_pay_rule: $orderCompute.yoho_coin_pay_rule
};
if ($yohoCoinData.totalYohoCoinNum < 100) {
$yohoCoinData.yohoCoinMsg = '共' + $yohoCoinData.totalYohoCoinNum +
'有货币,满' + $orderCompute.yoho_coin_pay_rule.num_limit + '可用';
} else if ($yohoCoinData.useYohoCoin > 0 || $yohoCoinData.yohoCoin > 0) {
let yohoCoin = parseInt($yohoCoinData.useYohoCoin > 0 ? $yohoCoinData.useYohoCoin : $yohoCoinData.yohoCoin, 10).toFixed(2);
$yohoCoinData.yohoCoinMsg = '可抵¥' + yohoCoin;
$yohoCoinData.yohoCoinClick = 1;
} else {
$yohoCoinData.yohoCoinMsg = '不满足有货币使用条件';
}
return $yohoCoinData;
};
const ticketsConfirm = (param) => {
return api.all([
checkTickets(param)
]).then((result) => {
let resu = {
goods: [],
productSku: param.productSku,
buyNumber: param.buyNumber,
orderEnsurePage: true
};
if (result && result[0] && result[0].data) {
let bulid = [];
result[0].data.goods_list.forEach((val) => {
bulid.push({
tickets: true,
id: val.product_sku,
thumb: helpers.image(val.goods_images, 120, 160),
name: val.product_name,
color: val.color_name,
size: val.product_skn == SINGLE_TICKETS_SKN ? '' : val.size_name,
count: val.buy_number,
price: parseInt(val.last_price, 10).toFixed(2)
});
resu.goods = bulid;
});
resu.cartPayData = result[0].data.shopping_cart_data.promotion_formula_list;
resu.price = parseInt(result[0].data.shopping_cart_data.last_order_amount, 10).toFixed(2);
resu.yohoCoinCompute = yohoCoinCompute(result[0].data.shopping_cart_data);
}
return resu;
});
};
// 门票下单
const submitTicket = (param) => {
return api.get('', {
method: 'app.shopping.submitTicket',
uid: param.uid,
product_sku: param.productSku,
buy_number: param.buyNumber,
mobile: param.mobile,
use_yoho_coin: param.useYohoCoin,
qhy_union: ''
}, {
code: 200
}).then((result) => {
return result;
});
};
module.exports = {
ticketsConfirm,
submitTicket,
checkTickets
};