|
@@ -5,71 +5,158 @@ |
|
@@ -5,71 +5,158 @@ |
5
|
*/
|
5
|
*/
|
6
|
'use strict';
|
6
|
'use strict';
|
7
|
|
7
|
|
8
|
-const api = global.yoho.API;
|
|
|
9
|
-
|
|
|
10
|
-const getEasyPaymentAsync = (uid, goods, activity) => {
|
|
|
11
|
- let param = {
|
|
|
12
|
- method: 'app.Shopping.easyPayment',
|
|
|
13
|
- uid: uid,
|
|
|
14
|
- cart_type: 'ordinary',
|
|
|
15
|
- product_sku_list: goods,
|
|
|
16
|
- yoho_coin_mode: 0,
|
|
|
17
|
- is_support_apple_pay: 'N'
|
|
|
18
|
- };
|
|
|
19
|
-
|
|
|
20
|
- if (activity) {
|
|
|
21
|
- param.activity_id = activity;
|
8
|
+module.exports = class extends global.yoho.BaseModel {
|
|
|
9
|
+ constructor(ctx) {
|
|
|
10
|
+ super(ctx);
|
22
|
}
|
11
|
}
|
23
|
|
12
|
|
24
|
- return api.get('', param, {code: 200});
|
|
|
25
|
-};
|
13
|
+ getEasyPaymentAsync(uid, goods, activity) {
|
|
|
14
|
+ let param = {
|
|
|
15
|
+ method: 'app.Shopping.easyPayment',
|
|
|
16
|
+ uid: uid,
|
|
|
17
|
+ cart_type: 'ordinary',
|
|
|
18
|
+ product_sku_list: goods,
|
|
|
19
|
+ yoho_coin_mode: 0,
|
|
|
20
|
+ is_support_apple_pay: 'N'
|
|
|
21
|
+ };
|
|
|
22
|
+
|
|
|
23
|
+ if (activity) {
|
|
|
24
|
+ param.activity_id = activity;
|
|
|
25
|
+ }
|
26
|
|
26
|
|
|
|
27
|
+ return this.get({data: param});
|
|
|
28
|
+ }
|
27
|
|
29
|
|
28
|
-/**
|
|
|
29
|
- * 订单计算API
|
|
|
30
|
- * @param uid [number] uid
|
|
|
31
|
- * @param cartType [string] 购物车类型,ordinary表示普通, advance表示预售
|
|
|
32
|
- * @param paymentType [number] 支付方式,1表示在线支付,2表示货到付款
|
|
|
33
|
- * @param deliveryWay [number] 配送方式,1表示普通快递,2表示顺丰速运
|
|
|
34
|
- * @param coin [number] 使用的有货币
|
|
|
35
|
- * @param useRedEnvelops [number] 红包
|
|
|
36
|
- * @param couponCode [string] 优惠券码
|
|
|
37
|
- * @param promotionCode [string] 优惠码
|
|
|
38
|
- * @param productSkuList [string] 限购商品
|
30
|
+ /**
|
|
|
31
|
+ * 订单计算API
|
|
|
32
|
+ * @param uid [number] uid
|
|
|
33
|
+ * @param cartType [string] 购物车类型,ordinary表示普通, advance表示预售
|
|
|
34
|
+ * @param paymentType [number] 支付方式,1表示在线支付,2表示货到付款
|
|
|
35
|
+ * @param deliveryWay [number] 配送方式,1表示普通快递,2表示顺丰速运
|
|
|
36
|
+ * @param coin [number] 使用的有货币
|
|
|
37
|
+ * @param useRedEnvelops [number] 红包
|
|
|
38
|
+ * @param couponCode [string] 优惠券码
|
|
|
39
|
+ * @param promotionCode [string] 优惠码
|
|
|
40
|
+ * @param productSkuList [string] 限购商品
|
|
|
41
|
+ */
|
|
|
42
|
+ getEasypayComputeAsync(uid, cartType, paymentType, deliveryWay, other) {
|
|
|
43
|
+ let param = {
|
|
|
44
|
+ method: 'app.Shopping.easyCompute',
|
|
|
45
|
+ uid: uid,
|
|
|
46
|
+ cart_type: cartType || 'ordinary',
|
|
|
47
|
+ payment_type: paymentType,
|
|
|
48
|
+ delivery_way: deliveryWay
|
|
|
49
|
+ };
|
|
|
50
|
+
|
|
|
51
|
+ // 其他可选参数
|
|
|
52
|
+ if (other) {
|
|
|
53
|
+ if (other.coin) {
|
|
|
54
|
+ Object.assign(param, {
|
|
|
55
|
+ use_yoho_coin: other.coin / 100
|
|
|
56
|
+ });
|
|
|
57
|
+ }
|
39
|
|
58
|
|
40
|
- */
|
|
|
41
|
-const getEasypayComputeAsync = (uid, cartType, paymentType, deliveryWay, other) => {
|
|
|
42
|
- let param = {
|
|
|
43
|
- method: 'app.Shopping.easyCompute',
|
|
|
44
|
- uid: uid,
|
|
|
45
|
- cart_type: cartType || 'ordinary',
|
|
|
46
|
- payment_type: paymentType,
|
|
|
47
|
- delivery_way: deliveryWay
|
|
|
48
|
- };
|
|
|
49
|
-
|
|
|
50
|
- // 其他可选参数
|
|
|
51
|
- if (other) {
|
59
|
+ if (other.useRedEnvelops) {
|
|
|
60
|
+ Object.assign(param, {
|
|
|
61
|
+ use_red_envelopes: other.useRedEnvelops
|
|
|
62
|
+ });
|
|
|
63
|
+ }
|
|
|
64
|
+
|
|
|
65
|
+ if (other.couponCode) {
|
|
|
66
|
+ Object.assign(param, {
|
|
|
67
|
+ coupon_code: other.couponCode
|
|
|
68
|
+ });
|
|
|
69
|
+ }
|
|
|
70
|
+
|
|
|
71
|
+ if (other.promotionCode) {
|
|
|
72
|
+ Object.assign(param, {
|
|
|
73
|
+ promotion_code: other.promotionCode
|
|
|
74
|
+ });
|
|
|
75
|
+ }
|
|
|
76
|
+
|
|
|
77
|
+ if (other.productSkuList) {
|
|
|
78
|
+ Object.assign(param, {
|
|
|
79
|
+ product_sku_list: other.productSkuList
|
|
|
80
|
+ });
|
|
|
81
|
+
|
|
|
82
|
+ if (other.bundle) {
|
|
|
83
|
+ Object.assign(param, {
|
|
|
84
|
+ activity_id: other.bundle
|
|
|
85
|
+ });
|
|
|
86
|
+ }
|
|
|
87
|
+ }
|
|
|
88
|
+ }
|
|
|
89
|
+
|
|
|
90
|
+ return this.get({data: param});
|
|
|
91
|
+ }
|
|
|
92
|
+
|
|
|
93
|
+ /**
|
|
|
94
|
+ * 订单提交API
|
|
|
95
|
+ * @param uid [number] uid
|
|
|
96
|
+ * @param cartType [String] 购物车类型,ordinary表示普通, advance表示预售
|
|
|
97
|
+ * @param addressId [String] 地址
|
|
|
98
|
+ * @param deliveryTime [number] 寄送时间类型
|
|
|
99
|
+ * @param deliveryWay [number] 配送方式,1表示普通快递,2表示顺丰速运
|
|
|
100
|
+ * @param invoicesType [number] 发票类型
|
|
|
101
|
+ * @param invoicesTitle [string] 发票抬头
|
|
|
102
|
+ * @param invoicesContent [int] 发票类型
|
|
|
103
|
+ * @param receiverMobile [string] 发票收人电话
|
|
|
104
|
+ * @param coin [number] 使用的有货币金额
|
|
|
105
|
+ * @param redEnvelopes [number] 使用的红包
|
|
|
106
|
+ * @param paymentId [number] 支付id
|
|
|
107
|
+ * @param paymentType [number] 支付类型
|
|
|
108
|
+ * @param remark [string] 备注
|
|
|
109
|
+ * @param couponCode [string] 优惠券码
|
|
|
110
|
+ * @param printPrice [string] 是否打印价格
|
|
|
111
|
+ */
|
|
|
112
|
+ easypayOrderSubmitAsync(uid, cartType, addressId, deliveryTime, deliveryWay, paymentType, paymentId, printPrice, other, remoteIp) { // eslint-disable-line
|
|
|
113
|
+ let param = {
|
|
|
114
|
+ method: 'app.Shopping.easySubmit',
|
|
|
115
|
+ uid: uid,
|
|
|
116
|
+ cart_type: cartType || 'ordinary',
|
|
|
117
|
+ address_id: addressId,
|
|
|
118
|
+ delivery_time: deliveryTime,
|
|
|
119
|
+ delivery_way: deliveryWay,
|
|
|
120
|
+ payment_type: paymentType,
|
|
|
121
|
+ payment_id: paymentId,
|
|
|
122
|
+ is_print_price: printPrice
|
|
|
123
|
+ };
|
|
|
124
|
+
|
|
|
125
|
+ // 发票
|
|
|
126
|
+ if (other.invoicesType) {
|
|
|
127
|
+ Object.assign(param, {
|
|
|
128
|
+ invoices_type: other.invoicesType,
|
|
|
129
|
+ invoices_title: other.invoicesTitle,
|
|
|
130
|
+ invoice_content: other.invoicesContent,
|
|
|
131
|
+ receiverMobile: other.receiver
|
|
|
132
|
+ });
|
|
|
133
|
+ }
|
|
|
134
|
+
|
|
|
135
|
+ // 有货币
|
52
|
if (other.coin) {
|
136
|
if (other.coin) {
|
53
|
Object.assign(param, {
|
137
|
Object.assign(param, {
|
54
|
- use_yoho_coin: other.coin / 100
|
138
|
+ use_yoho_coin: other.coin / 100 // 有货币稀释
|
55
|
});
|
139
|
});
|
56
|
}
|
140
|
}
|
57
|
|
141
|
|
58
|
- if (other.useRedEnvelops) {
|
142
|
+ // 红包
|
|
|
143
|
+ if (other.redEnvelopes) {
|
59
|
Object.assign(param, {
|
144
|
Object.assign(param, {
|
60
|
- use_red_envelopes: other.useRedEnvelops
|
145
|
+ use_red_envelopes: other.redEnvelopes
|
61
|
});
|
146
|
});
|
62
|
}
|
147
|
}
|
63
|
|
148
|
|
64
|
- if (other.couponCode) {
|
149
|
+ // 备注
|
|
|
150
|
+ if (other.remark) {
|
65
|
Object.assign(param, {
|
151
|
Object.assign(param, {
|
66
|
- coupon_code: other.couponCode
|
152
|
+ remark: other.remark
|
67
|
});
|
153
|
});
|
68
|
}
|
154
|
}
|
69
|
|
155
|
|
70
|
- if (other.promotionCode) {
|
156
|
+ // 优惠券码
|
|
|
157
|
+ if (other.couponCode) {
|
71
|
Object.assign(param, {
|
158
|
Object.assign(param, {
|
72
|
- promotion_code: other.promotionCode
|
159
|
+ coupon_code: other.couponCode
|
73
|
});
|
160
|
});
|
74
|
}
|
161
|
}
|
75
|
|
162
|
|
|
@@ -85,106 +172,16 @@ const getEasypayComputeAsync = (uid, cartType, paymentType, deliveryWay, other) |
|
@@ -85,106 +172,16 @@ const getEasypayComputeAsync = (uid, cartType, paymentType, deliveryWay, other) |
85
|
}
|
172
|
}
|
86
|
}
|
173
|
}
|
87
|
|
174
|
|
88
|
- }
|
|
|
89
|
-
|
|
|
90
|
- return api.get('', param);
|
|
|
91
|
-};
|
|
|
92
|
-
|
|
|
93
|
-/**
|
|
|
94
|
- * 订单提交API
|
|
|
95
|
- * @param uid [number] uid
|
|
|
96
|
- * @param cartType [String] 购物车类型,ordinary表示普通, advance表示预售
|
|
|
97
|
- * @param addressId [String] 地址
|
|
|
98
|
- * @param deliveryTime [number] 寄送时间类型
|
|
|
99
|
- * @param deliveryWay [number] 配送方式,1表示普通快递,2表示顺丰速运
|
|
|
100
|
- * @param invoicesType [number] 发票类型
|
|
|
101
|
- * @param invoicesTitle [string] 发票抬头
|
|
|
102
|
- * @param invoicesContent [int] 发票类型
|
|
|
103
|
- * @param receiverMobile [string] 发票收人电话
|
|
|
104
|
- * @param coin [number] 使用的有货币金额
|
|
|
105
|
- * @param redEnvelopes [number] 使用的红包
|
|
|
106
|
- * @param paymentId [number] 支付id
|
|
|
107
|
- * @param paymentType [number] 支付类型
|
|
|
108
|
- * @param remark [string] 备注
|
|
|
109
|
- * @param couponCode [string] 优惠券码
|
|
|
110
|
- * @param printPrice [string] 是否打印价格
|
|
|
111
|
- */
|
|
|
112
|
-const easypayOrderSubmitAsync = (uid, cartType, addressId, deliveryTime, deliveryWay, paymentType, paymentId, printPrice, other, remoteIp) => { // eslint-disable-line
|
|
|
113
|
- let param = {
|
|
|
114
|
- method: 'app.Shopping.easySubmit',
|
|
|
115
|
- uid: uid,
|
|
|
116
|
- cart_type: cartType || 'ordinary',
|
|
|
117
|
- address_id: addressId,
|
|
|
118
|
- delivery_time: deliveryTime,
|
|
|
119
|
- delivery_way: deliveryWay,
|
|
|
120
|
- payment_type: paymentType,
|
|
|
121
|
- payment_id: paymentId,
|
|
|
122
|
- is_print_price: printPrice
|
|
|
123
|
- };
|
|
|
124
|
-
|
|
|
125
|
- // 发票
|
|
|
126
|
- if (other.invoicesType) {
|
|
|
127
|
- Object.assign(param, {
|
|
|
128
|
- invoices_type: other.invoicesType,
|
|
|
129
|
- invoices_title: other.invoicesTitle,
|
|
|
130
|
- invoice_content: other.invoicesContent,
|
|
|
131
|
- receiverMobile: other.receiver
|
|
|
132
|
- });
|
|
|
133
|
- }
|
|
|
134
|
-
|
|
|
135
|
- // 有货币
|
|
|
136
|
- if (other.coin) {
|
|
|
137
|
- Object.assign(param, {
|
|
|
138
|
- use_yoho_coin: other.coin / 100 // 有货币稀释
|
|
|
139
|
- });
|
|
|
140
|
- }
|
|
|
141
|
-
|
|
|
142
|
- // 红包
|
|
|
143
|
- if (other.redEnvelopes) {
|
|
|
144
|
- Object.assign(param, {
|
|
|
145
|
- use_red_envelopes: other.redEnvelopes
|
|
|
146
|
- });
|
|
|
147
|
- }
|
|
|
148
|
-
|
|
|
149
|
- // 备注
|
|
|
150
|
- if (other.remark) {
|
|
|
151
|
- Object.assign(param, {
|
|
|
152
|
- remark: other.remark
|
|
|
153
|
- });
|
|
|
154
|
- }
|
|
|
155
|
-
|
|
|
156
|
- // 优惠券码
|
|
|
157
|
- if (other.couponCode) {
|
|
|
158
|
- Object.assign(param, {
|
|
|
159
|
- coupon_code: other.couponCode
|
|
|
160
|
- });
|
|
|
161
|
- }
|
|
|
162
|
-
|
|
|
163
|
- if (other.productSkuList) {
|
|
|
164
|
- Object.assign(param, {
|
|
|
165
|
- product_sku_list: other.productSkuList
|
|
|
166
|
- });
|
|
|
167
|
-
|
|
|
168
|
- if (other.bundle) {
|
175
|
+ if (other.udid) {
|
169
|
Object.assign(param, {
|
176
|
Object.assign(param, {
|
170
|
- activity_id: other.bundle
|
177
|
+ udid: other.udid
|
171
|
});
|
178
|
});
|
172
|
}
|
179
|
}
|
173
|
- }
|
|
|
174
|
|
180
|
|
175
|
- if (other.udid) {
|
|
|
176
|
- Object.assign(param, {
|
|
|
177
|
- udid: other.udid
|
|
|
178
|
- });
|
181
|
+ return this.get({data: param, param: {
|
|
|
182
|
+ headers: {
|
|
|
183
|
+ 'X-Forwarded-For': remoteIp || ''
|
|
|
184
|
+ }
|
|
|
185
|
+ }});
|
179
|
}
|
186
|
}
|
180
|
-
|
|
|
181
|
- return api.get('', param, {
|
|
|
182
|
- headers: {'X-Forwarded-For': remoteIp || ''}
|
|
|
183
|
- });
|
|
|
184
|
-};
|
|
|
185
|
-
|
|
|
186
|
-module.exports = {
|
|
|
187
|
- getEasyPaymentAsync,
|
|
|
188
|
- getEasypayComputeAsync,
|
|
|
189
|
- easypayOrderSubmitAsync
|
|
|
190
|
}; |
187
|
}; |