Showing
6 changed files
with
468 additions
and
12 deletions
@@ -7,7 +7,7 @@ const headerModel = require('../../../doraemon/models/header'); | @@ -7,7 +7,7 @@ const headerModel = require('../../../doraemon/models/header'); | ||
7 | const userModel = require('../../serverAPI/user'); | 7 | const userModel = require('../../serverAPI/user'); |
8 | const addressModel = require('../../serverAPI/user/address'); | 8 | const addressModel = require('../../serverAPI/user/address'); |
9 | const orderModel = require('../models/order'); | 9 | const orderModel = require('../models/order'); |
10 | - | 10 | +const crypt = global.yoho.crypt; |
11 | 11 | ||
12 | exports.orderEnsure = (req, res, next) => { | 12 | exports.orderEnsure = (req, res, next) => { |
13 | let headerData = headerModel.setNav({ | 13 | let headerData = headerModel.setNav({ |
@@ -134,6 +134,132 @@ exports.fastPay = (req, res, next) => { | @@ -134,6 +134,132 @@ exports.fastPay = (req, res, next) => { | ||
134 | }; | 134 | }; |
135 | 135 | ||
136 | /** | 136 | /** |
137 | + * 购物车选择改变字段,重新运算订单数据 | ||
138 | + */ | ||
139 | +exports.orderCompute = (req, res, next) => { | ||
140 | + let cartType = req.body.cartType || 'ordinary'; | ||
141 | + let deliveryId = req.body.deliveryId || 1; | ||
142 | + let paymentTypeId = req.body.paymentTypeId || 1; | ||
143 | + let couponCode = req.body.couponCode || null; | ||
144 | + let yohoCoin = req.body.yohoCoin || null; | ||
145 | + let productSku = req.body.productSku || null; | ||
146 | + let buyNumber = req.body.buyNumber || null; | ||
147 | + let uid = req.user.uid; | ||
148 | + let skuList = req.body.skuList; | ||
149 | + let type = req.body.type; | ||
150 | + | ||
151 | + if (type !== 'tickets') { | ||
152 | + cartModel.orderCompute(uid, cartType, deliveryId, paymentTypeId, couponCode, yohoCoin, skuList).then(result => { | ||
153 | + res.json(result); | ||
154 | + }).catch(next); | ||
155 | + } else { | ||
156 | + cartModel.ticketsOrderCompute(uid, productSku, buyNumber, yohoCoin).then(result => { | ||
157 | + res.json(result); | ||
158 | + }).catch(next); | ||
159 | + } | ||
160 | +}; | ||
161 | + | ||
162 | +/** | ||
163 | + * 确认结算订单 | ||
164 | + */ | ||
165 | +exports.orderSub = (req, res) => { | ||
166 | + let uid = req.user.uid; | ||
167 | + let addressId = crypt.decrypt('', req.body.addressId); | ||
168 | + let cartType = req.body.cartType || 'ordinary'; | ||
169 | + let deliveryTimeId = req.body.deliveryTimeId || 1; | ||
170 | + let deliveryId = req.body.deliveryId || 1; | ||
171 | + let paymentTypeId = req.body.paymentTypeId || 15; | ||
172 | + let paymentType = req.body.paymentType || 1; | ||
173 | + let msg = req.body.msg || null; | ||
174 | + let couponCode = req.body.couponCode || null; | ||
175 | + let yohoCoin = req.body.yohoCoin || 1; | ||
176 | + let skuList = req.body.skuList || ''; | ||
177 | + let orderInfo; | ||
178 | + | ||
179 | + try { | ||
180 | + orderInfo = JSON.parse(req.cookies['order-info']); | ||
181 | + } catch (e) { | ||
182 | + orderInfo = {}; | ||
183 | + } | ||
184 | + | ||
185 | + let times = req.body.times || 1; | ||
186 | + | ||
187 | + // 电子发票信息数组 | ||
188 | + let invoices = {}; | ||
189 | + | ||
190 | + if (orderInfo) { | ||
191 | + invoices = { | ||
192 | + invoices_type_id: orderInfo.invoiceType, | ||
193 | + invoices_type: orderInfo.invoicesType, | ||
194 | + receiverMobile: orderInfo.receiverMobile, | ||
195 | + invoices_title: orderInfo.invoiceText ? orderInfo.invoiceText : '个人' | ||
196 | + }; | ||
197 | + } | ||
198 | + | ||
199 | + /* 判断是否是友盟过来的用户 */ | ||
200 | + let userAgent = null; | ||
201 | + let unionKey = ''; | ||
202 | + let unionInfo = {}; | ||
203 | + | ||
204 | + if (req.cookies.mkt_code || req.cookies._QYH_UNION) { | ||
205 | + | ||
206 | + /* tar modified 161108 添加新的联盟数据处理逻辑,兼容原有联盟数据处理, | ||
207 | + 区别是旧的北京写 cookie 加密过来,新的 node 写 cookie,没有加密 */ | ||
208 | + if (req.cookies._QYH_UNION) { | ||
209 | + let encryData = decodeURI(req.cookies._QYH_UNION); | ||
210 | + let testQyhUnion = JSON.parse(encryData); | ||
211 | + | ||
212 | + if (testQyhUnion.client_id) { | ||
213 | + unionKey = encryData; | ||
214 | + } else { | ||
215 | + // unionKey = helpers.unionDecode(req.cookies._QYH_UNION, 'q_union_yohobuy'); // TODO 这个方法没有 | ||
216 | + } | ||
217 | + } else { | ||
218 | + unionKey = '{"client_id":' + req.cookies.mkt_code + '}'; | ||
219 | + } | ||
220 | + | ||
221 | + /* 检查联盟参数是否有效 */ | ||
222 | + unionInfo = unionKey ? JSON.parse(unionKey) : {}; | ||
223 | + | ||
224 | + /* 模拟APP的User-Agent */ | ||
225 | + userAgent = unionInfo.client_id ? 'YOHO!Buy/3.8.2.259(Model/PC;Channel/' + | ||
226 | + unionInfo.client_id + ';uid/' + uid + ')' : null; | ||
227 | + } | ||
228 | + | ||
229 | + return co(function* () { | ||
230 | + let result; | ||
231 | + | ||
232 | + /* tar modified 161206 套餐 */ | ||
233 | + if (req.body.activityType === 'bundle') { | ||
234 | + let activityInfo = JSON.parse(req.cookies['activity-info']); | ||
235 | + | ||
236 | + result = yield cartModel.orderSub(uid, addressId, 'bundle', deliveryTimeId, | ||
237 | + deliveryId, invoices, paymentTypeId, paymentType, msg, couponCode, | ||
238 | + yohoCoin, null, unionKey, userAgent, times, activityInfo); | ||
239 | + } else { | ||
240 | + result = yield cartModel.orderSub(uid, addressId, cartType, deliveryTimeId, | ||
241 | + deliveryId, invoices, paymentTypeId, paymentType, msg, couponCode, | ||
242 | + yohoCoin, skuList, unionKey, userAgent); | ||
243 | + } | ||
244 | + | ||
245 | + if (unionInfo) { | ||
246 | + result.data.unionCookie = unionInfo; | ||
247 | + } | ||
248 | + | ||
249 | + // 提交成功清除Cookie | ||
250 | + res.cookie('order-info', null, { | ||
251 | + domain: 'yohobuy.com' | ||
252 | + }); | ||
253 | + | ||
254 | + if (result.code === 409) { | ||
255 | + return res.json(decodeURI(result)); | ||
256 | + } else { | ||
257 | + return res.json(result); | ||
258 | + } | ||
259 | + })(); | ||
260 | +}; | ||
261 | + | ||
262 | +/** | ||
137 | * 下单流程 选择优惠券 | 263 | * 下单流程 选择优惠券 |
138 | */ | 264 | */ |
139 | exports.selectCoupon = (req, res) => { | 265 | exports.selectCoupon = (req, res) => { |
@@ -6,6 +6,57 @@ const paymentProcess = require(global.utils + '/payment-process'); | @@ -6,6 +6,57 @@ const paymentProcess = require(global.utils + '/payment-process'); | ||
6 | const shoppingAPI = require('../../serverAPI/order/shopping'); | 6 | const shoppingAPI = require('../../serverAPI/order/shopping'); |
7 | 7 | ||
8 | /** | 8 | /** |
9 | + * 转换价格 | ||
10 | + * | ||
11 | + * @param float|string $price 价格 | ||
12 | + * @param boolean $isSepcialZero 是否需要特殊的0,默认否 | ||
13 | + * @return float|string 转换之后的价格 | ||
14 | + */ | ||
15 | +const transPrice = (price, isSepcialZero) => { | ||
16 | + if (!isSepcialZero) { | ||
17 | + isSepcialZero = false; | ||
18 | + } | ||
19 | + | ||
20 | + return price; | ||
21 | +}; | ||
22 | + | ||
23 | +/** | ||
24 | + *有货币使用前端方案显示及是否可单击判断 | ||
25 | + */ | ||
26 | +const _yohoCoinCompute = (orderCompute) => { | ||
27 | + let yohoCoinData = { | ||
28 | + totalYohoCoinNum: 0, | ||
29 | + yohoCoin: 0, | ||
30 | + useYohoCoin: 0, | ||
31 | + yohoCoinClick: 0, | ||
32 | + yohoCoinMsg: '', | ||
33 | + yoho_coin_pay_rule: [] | ||
34 | + }; | ||
35 | + | ||
36 | + if (!orderCompute || !orderCompute.yoho_coin_pay_rule) { | ||
37 | + return yohoCoinData; | ||
38 | + } | ||
39 | + | ||
40 | + _.assign(yohoCoinData, { | ||
41 | + totalYohoCoinNum: orderCompute.total_yoho_coin_num ? parseInt(orderCompute.total_yoho_coin_num, 10) : 0, | ||
42 | + yohoCoin: orderCompute.yoho_coin ? transPrice(orderCompute.yoho_coin) : 0, | ||
43 | + useYohoCoin: orderCompute.use_yoho_coin ? transPrice(orderCompute.use_yoho_coin) : 0, | ||
44 | + yoho_coin_pay_rule: orderCompute.yoho_coin_pay_rule | ||
45 | + }); | ||
46 | + | ||
47 | + if (yohoCoinData.totalYohoCoinNum < 100) { | ||
48 | + yohoCoinData.yohoCoinMsg = `共${yohoCoinData.totalYohoCoinNum}有货币,满${orderCompute.yoho_coin_pay_rule.num_limit}可用`; | ||
49 | + } else if (yohoCoinData.useYohoCoin > 0 || yohoCoinData.yohoCoin > 0) { | ||
50 | + yohoCoinData.yohoCoinMsg = '可抵¥' + (yohoCoinData.useYohoCoin > 0 ? yohoCoinData.useYohoCoin : yohoCoinData.yohoCoin); | ||
51 | + yohoCoinData.yohoCoinClick = 1; | ||
52 | + } else { | ||
53 | + yohoCoinData.yohoCoinMsg = '不满足有货币使用条件'; | ||
54 | + } | ||
55 | + | ||
56 | + return yohoCoinData; | ||
57 | +}; | ||
58 | + | ||
59 | +/** | ||
9 | * 调用购物车结算接口返回的数据处理 | 60 | * 调用购物车结算接口返回的数据处理 |
10 | * | 61 | * |
11 | * | 62 | * |
@@ -98,6 +149,143 @@ exports.easyPayment = (uid, skuList) => { | @@ -98,6 +149,143 @@ exports.easyPayment = (uid, skuList) => { | ||
98 | }; | 149 | }; |
99 | 150 | ||
100 | /** | 151 | /** |
152 | + * 购物车结算--支付方式和配送方式选择以及是否使用有货币接口返回的数据处理 | ||
153 | + * | ||
154 | + * @param int $uid 用户ID | ||
155 | + * @param string $cartType 购物车类型,ordinary表示普通购物车 | ||
156 | + * @param int $deliveryWay 配送方式,1表示普通快递,2表示顺丰速运 | ||
157 | + * @param int $paymentType 支付方式,1表示在线支付,2表示货到付款 | ||
158 | + * @param string $couponCode 优惠券码 | ||
159 | + * @param mixed $yohoCoin 使用的有货币数量 | ||
160 | + * @param string $skuList 购买限购商品时需要传递的参数 | ||
161 | + * @return array 接口返回的数据 | ||
162 | + */ | ||
163 | +exports.orderCompute = (uid, cartType, deliveryWay, paymentType, couponCode, yohoCoin, skuList) => { | ||
164 | + return shoppingAPI.orderComputeAPI(uid, cartType, deliveryWay, paymentType, couponCode, yohoCoin, skuList).then(result => { | ||
165 | + if (result && result.data) { | ||
166 | + result.data.use_yoho_coin = transPrice(result.data.use_yoho_coin); | ||
167 | + result.data.yohoCoinCompute = _yohoCoinCompute(result.data); | ||
168 | + return result.data; | ||
169 | + } else { | ||
170 | + return {}; | ||
171 | + } | ||
172 | + }); | ||
173 | +}; | ||
174 | + | ||
175 | + | ||
176 | +exports.ticketsOrderCompute = (uid, productSku, buyNumber, yohoCoin) => { | ||
177 | + return shoppingAPI.checkTickets(uid, productSku, buyNumber, yohoCoin).then(result => { | ||
178 | + if (result && result.data) { | ||
179 | + result.data.shopping_cart_data.use_yoho_coin = transPrice(result.data.shopping_cart_data.use_yoho_coin); | ||
180 | + result.data.yohoCoinCompute = _.yohoCoinCompute(result.data.shopping_cart_data); | ||
181 | + | ||
182 | + return result.data; | ||
183 | + } else { | ||
184 | + return {}; | ||
185 | + } | ||
186 | + }); | ||
187 | +}; | ||
188 | + | ||
189 | +/** | ||
190 | + * 购物车结算--提交结算信息 | ||
191 | + * | ||
192 | + * @param int $uid 用户ID | ||
193 | + * @param int $addressId 地址ID | ||
194 | + * @param int $cartType 购物车类型ID | ||
195 | + * @param int $deliveryTime 寄送时间ID | ||
196 | + * @param int $deliveryWay 寄送方式ID | ||
197 | + * @param array $invoices 发票参数数组 | ||
198 | + * @param int $paymentId 支付方式ID | ||
199 | + * @param int $paymentType 支付类型ID | ||
200 | + * @param string $remark 留言 | ||
201 | + * @param string $couponCode 优惠券码 | ||
202 | + * @param mixed $yohoCoin 使用的有货币数量或为空 | ||
203 | + * @param string $skuList 购买限购商品时需要传递的参数 | ||
204 | + * @param string $qhyUnio 友盟有关信息 | ||
205 | + * @param string|null $userAgent 联盟过来用户下单时需要的User-Agent信息 | ||
206 | + * @param int $times | ||
207 | + * @param null $activityInfo 套餐数据 | ||
208 | + * @return array 接口返回的数据 | ||
209 | + */ | ||
210 | +exports.orderSub = (uid, addressId, cartType, deliveryTime, | ||
211 | + deliveryWay, invoices, paymentId, paymentType, remark, | ||
212 | + couponCode, yohoCoin, skuList, qhyUnio = '', | ||
213 | + userAgent, times, activityInfo = null) => { | ||
214 | + | ||
215 | + if (!userAgent) { | ||
216 | + userAgent = null; | ||
217 | + } | ||
218 | + | ||
219 | + if (!times) { | ||
220 | + times = 1; | ||
221 | + } | ||
222 | + | ||
223 | + if (!activityInfo) { | ||
224 | + activityInfo = null; | ||
225 | + } | ||
226 | + | ||
227 | + if (!addressId) { | ||
228 | + return Promise.resolve({code: 401, message: '配送地址不能为空'}); | ||
229 | + } | ||
230 | + | ||
231 | + if (!deliveryTime) { | ||
232 | + return Promise.resolve({code: 402, message: '请选择配送时间'}); | ||
233 | + } | ||
234 | + | ||
235 | + if (!deliveryWay) { | ||
236 | + return Promise.resolve({code: 403, message: '请选择配送方式'}); | ||
237 | + } | ||
238 | + | ||
239 | + return shoppingAPI.orderSub(uid, addressId, cartType, deliveryTime, | ||
240 | + deliveryWay, invoices, paymentId, paymentType, | ||
241 | + remark, couponCode, yohoCoin, skuList, qhyUnio, | ||
242 | + userAgent, times, activityInfo).then(orderSubRes => { | ||
243 | + let finalResult = {}; | ||
244 | + | ||
245 | + if (orderSubRes && orderSubRes.data && orderSubRes.data.is_hint === 'Y') { | ||
246 | + finalResult.code = 409; | ||
247 | + | ||
248 | + if (orderSubRes.data.hintInfo) { | ||
249 | + let productName = _.get('orderSubRes', 'data.hintInfo.productName', ''); | ||
250 | + | ||
251 | + if (productName.length > 50) { // TODO 需要检查长度是否正确 | ||
252 | + orderSubRes.data.hintInfo.productName = | ||
253 | + productName.substring(0, 47) + '...'; | ||
254 | + } | ||
255 | + | ||
256 | + finalResult.message = [ | ||
257 | + encodeURI(productName + _.get(orderSubRes, 'data.hintInfo.suffix', '')), | ||
258 | + encodeURI(_.get(orderSubRes, 'data.hintInfo.lastLine', '')) | ||
259 | + ]; | ||
260 | + } | ||
261 | + | ||
262 | + finalResult.buttons = [ | ||
263 | + { | ||
264 | + href: helpers.urlFormat('/cart/index/index'), | ||
265 | + text: '重新选择商品', | ||
266 | + class: '' | ||
267 | + }, | ||
268 | + { | ||
269 | + href: '', | ||
270 | + text: '继续结算', | ||
271 | + class: 'order-tip-btnred' | ||
272 | + } | ||
273 | + ]; | ||
274 | + } else if (orderSubRes && orderSubRes.code) { | ||
275 | + finalResult = orderSubRes; | ||
276 | + } else { | ||
277 | + finalResult = { | ||
278 | + code: 400, | ||
279 | + message: '出错啦' | ||
280 | + }; | ||
281 | + } | ||
282 | + | ||
283 | + return finalResult; | ||
284 | + }); | ||
285 | + | ||
286 | +}; | ||
287 | + | ||
288 | +/** | ||
101 | * 处理优惠券列表数据 | 289 | * 处理优惠券列表数据 |
102 | * | 290 | * |
103 | * @param int $uid 用户ID | 291 | * @param int $uid 用户ID |
@@ -31,6 +31,8 @@ router.get('/index/new/pay/alipayresult', authMW, payController.payAli);// æ”¯ä» | @@ -31,6 +31,8 @@ router.get('/index/new/pay/alipayresult', authMW, payController.payAli);// æ”¯ä» | ||
31 | 31 | ||
32 | router.get('/index/new/orderEnsure', authMW, order.orderEnsure); // 订单结算 | 32 | router.get('/index/new/orderEnsure', authMW, order.orderEnsure); // 订单结算 |
33 | router.get('/index/new/fast', authMW, order.fastPay); // 快速结算订单提交 | 33 | router.get('/index/new/fast', authMW, order.fastPay); // 快速结算订单提交 |
34 | +router.post('/index/new/orderCompute', authMW, order.orderCompute); // 结算页参数改变,重新运算 | ||
35 | +router.post('/index/new/orderSub', authMW, order.orderSub); // 结算页参数改变,重新运算 | ||
34 | router.get('/index/new/selectCoupon', authMW, order.selectCoupon); // 选择优惠券 页面 | 36 | router.get('/index/new/selectCoupon', authMW, order.selectCoupon); // 选择优惠券 页面 |
35 | router.get('/index/new/couponList', order.couponList); // [ajax]获取优惠券列表 | 37 | router.get('/index/new/couponList', order.couponList); // [ajax]获取优惠券列表 |
36 | router.post('/index/new/couponSearch', order.couponSearch); // [ajax]购物车输入优惠券码使用优惠券 | 38 | router.post('/index/new/couponSearch', order.couponSearch); // [ajax]购物车输入优惠券码使用优惠券 |
@@ -2,6 +2,14 @@ | @@ -2,6 +2,14 @@ | ||
2 | const _ = require('lodash'); | 2 | const _ = require('lodash'); |
3 | const api = global.yoho.API; | 3 | const api = global.yoho.API; |
4 | 4 | ||
5 | +const privateKeyList = { | ||
6 | + android: 'fd4ad5fcfa0de589ef238c0e7331b585', | ||
7 | + iphone: 'a85bb0674e08986c6b115d5e3a4884fa', | ||
8 | + ipad: 'ad9fcda2e679cf9229e37feae2cdcf80', | ||
9 | + web: '0ed29744ed318fd28d2c07985d3ba633', | ||
10 | + h5: 'fd4ad5fcfa0de589ef238c0e7331b585' | ||
11 | +}; | ||
12 | + | ||
5 | /** | 13 | /** |
6 | * 购物车结算 | 14 | * 购物车结算 |
7 | * doc: http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/订单/shopping.md | 15 | * doc: http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/订单/shopping.md |
@@ -42,7 +50,7 @@ exports.easyPayment = (uid, skuList) => { | @@ -42,7 +50,7 @@ exports.easyPayment = (uid, skuList) => { | ||
42 | product_sku_list: skuList | 50 | product_sku_list: skuList |
43 | }; | 51 | }; |
44 | 52 | ||
45 | - return api.get('', param); | 53 | + return api.get('', param, {code: 200}); |
46 | }; | 54 | }; |
47 | 55 | ||
48 | 56 | ||
@@ -84,7 +92,139 @@ exports.orderComputeAPI = (uid, cartType, deliveWay, paymentType, couponCode, yo | @@ -84,7 +92,139 @@ exports.orderComputeAPI = (uid, cartType, deliveWay, paymentType, couponCode, yo | ||
84 | param.product_sku_list = skuList; | 92 | param.product_sku_list = skuList; |
85 | } | 93 | } |
86 | 94 | ||
87 | - return api.get('', param); | 95 | + return api.get('', param, {code: 200}); |
96 | +}; | ||
97 | + | ||
98 | +/** | ||
99 | + * 校验电子票 | ||
100 | + * @param int $uid | ||
101 | + * @param int $productSku | ||
102 | + * @param int $buyNumber | ||
103 | + * @param int $useYohoCoin | ||
104 | + * @param bool|int $yohoCoinMode 1:使用有货币;0:不使用有货币 | ||
105 | + * @return array | ||
106 | + * @author sefon 2016-7-2 18:12:30 | ||
107 | + */ | ||
108 | +exports.checkTickets = (uid, productSku, buyNumber, useYohoCoin, yohoCoinMode) => { | ||
109 | + if (!useYohoCoin) { | ||
110 | + useYohoCoin = 0; | ||
111 | + } | ||
112 | + | ||
113 | + if (!yohoCoinMode) { | ||
114 | + yohoCoinMode = true; | ||
115 | + } | ||
116 | + | ||
117 | + let params = { | ||
118 | + method: 'app.shopping.ticket', | ||
119 | + uid: uid, | ||
120 | + product_sku: productSku, | ||
121 | + buy_number: buyNumber, | ||
122 | + use_yoho_coin: useYohoCoin | ||
123 | + }; | ||
124 | + | ||
125 | + if (!yohoCoinMode) { | ||
126 | + _.assign(params, { | ||
127 | + yoho_coin_mode: 0 | ||
128 | + }); | ||
129 | + } | ||
130 | + | ||
131 | + return api.get('', params, {code: 200}); | ||
132 | +}; | ||
133 | + | ||
134 | +/** | ||
135 | + * 购物车结算--提交结算信息 | ||
136 | + * | ||
137 | + * @param int $uid 用户ID | ||
138 | + * @param int $addressId 地址ID | ||
139 | + * @param int $cartType 购物车类型ID | ||
140 | + * @param int $deliveryTime 寄送时间ID | ||
141 | + * @param int $deliveryWay 寄送方式ID | ||
142 | + * @param array $invoices 发票参数数组 | ||
143 | + * @param int $paymentId 支付方式ID | ||
144 | + * @param int $paymentType 支付类型ID | ||
145 | + * @param string $remark 留言 | ||
146 | + * @param string $couponCode 优惠券码 | ||
147 | + * @param mixed $yohoCoin 使用的有货币数量或为空 | ||
148 | + * @param string $skuList 购买限购商品时需要传递的参数 | ||
149 | + * @param string $qhyUnion 友盟有关信息 | ||
150 | + * @param string|null $userAgent 联盟过来用户下单时需要的User-Agent信息 | ||
151 | + * @param $times | ||
152 | + * @param null $activityInfo 套餐信息 | ||
153 | + * @return array 接口返回的数据 | ||
154 | + */ | ||
155 | +exports.orderSub = (uid, addressId, cartType, deliveryTime, | ||
156 | + deliveryWay, invoices, paymentId, paymentType, remark, couponCode, | ||
157 | + yohoCoin, skuList, qhyUnion, userAgent, times, activityInfo) => { | ||
158 | + if (!activityInfo) { | ||
159 | + activityInfo = null; | ||
160 | + } | ||
161 | + | ||
162 | + let params = { | ||
163 | + debug: 'Y', | ||
164 | + private_key: privateKeyList.h5, | ||
165 | + method: activityInfo ? 'app.Shopping.easySubmit' : 'app.Shopping.submit', | ||
166 | + address_id: addressId, | ||
167 | + cart_type: cartType, | ||
168 | + delivery_time: deliveryTime, | ||
169 | + delivery_way: deliveryWay, | ||
170 | + payment_id: paymentId, | ||
171 | + payment_type: paymentType, | ||
172 | + remark: remark, | ||
173 | + uid: uid | ||
174 | + }; | ||
175 | + | ||
176 | + /* tar add 161130 结算优化 */ | ||
177 | + if (times === 2 || times === '2') { | ||
178 | + params.is_continue_buy = 'Y'; | ||
179 | + } else { | ||
180 | + params.is_continue_buy = 'N'; | ||
181 | + } | ||
182 | + | ||
183 | + if (invoices.invoices_type_id) { | ||
184 | + // 发票内容id--图书:1 | ||
185 | + params.invoice_content = invoices.invoices_type_id; | ||
186 | + } | ||
187 | + | ||
188 | + if (invoices.invoices_type) { | ||
189 | + // 数字类型 发票类型 纸质 1 ,电子 2 | ||
190 | + params.invoices_type = invoices.invoices_type; | ||
191 | + } | ||
192 | + | ||
193 | + if (invoices.receiverMobile) { | ||
194 | + // 发票人手机 | ||
195 | + params.receiverMobile = invoices.receiverMobile; | ||
196 | + } | ||
197 | + | ||
198 | + if (invoices.invoices_title) { | ||
199 | + // 发票抬头 OR 填写单位名称,这二个是一个意思,只是叫法不一样 | ||
200 | + params.invoices_title = invoices.invoices_title; | ||
201 | + } | ||
202 | + | ||
203 | + if (couponCode) { | ||
204 | + params.coupon_code = couponCode; | ||
205 | + } | ||
206 | + | ||
207 | + if (yohoCoin) { | ||
208 | + params.use_yoho_coin = yohoCoin; | ||
209 | + } | ||
210 | + | ||
211 | + // 购买限购商品时需要传递product_sku_list参数 | ||
212 | + if (skuList && !activityInfo) { | ||
213 | + params.product_sku_list = skuList; | ||
214 | + } | ||
215 | + | ||
216 | + // 购买套餐商品需要的数据 | ||
217 | + if (activityInfo) { | ||
218 | + params.activity_id = activityInfo.activity_id; | ||
219 | + params.product_sku_list = activityInfo.product_sku_list; // TODO 检查 JSON 是否正常 | ||
220 | + } | ||
221 | + | ||
222 | + // 友盟有关信息的传递 | ||
223 | + if (qhyUnion) { | ||
224 | + params.qhy_union = qhyUnion; | ||
225 | + } | ||
226 | + | ||
227 | + return api.get('', params); | ||
88 | }; | 228 | }; |
89 | 229 | ||
90 | 230 |
@@ -17,15 +17,15 @@ module.exports = { | @@ -17,15 +17,15 @@ module.exports = { | ||
17 | assetUrl: '//127.0.0.1:5001', | 17 | assetUrl: '//127.0.0.1:5001', |
18 | testCode: 'yoho4946abcdef#$%&!@', | 18 | testCode: 'yoho4946abcdef#$%&!@', |
19 | domains: { | 19 | domains: { |
20 | - // api: 'http://api-test3.yohops.com:9999/', | ||
21 | - // service: 'http://service-test3.yohops.com:9999/', | ||
22 | - // liveApi: 'http://testapi.live.yohops.com:9999/', | ||
23 | - // singleApi: 'http://api-test3.yohops.com:9999/', | 20 | + api: 'http://api-test3.yohops.com:9999/', |
21 | + service: 'http://service-test3.yohops.com:9999/', | ||
22 | + liveApi: 'http://testapi.live.yohops.com:9999/', | ||
23 | + singleApi: 'http://api-test3.yohops.com:9999/', | ||
24 | 24 | ||
25 | - api: 'http://dev-api.yohops.com:9999/', | ||
26 | - service: 'http://dev-service.yohops.com:9999/', | ||
27 | - liveApi: 'http://api.live.yoho.cn/', | ||
28 | - singleApi: 'http://single.yoho.cn/', | 25 | + // api: 'http://dev-api.yohops.com:9999/', |
26 | + // service: 'http://dev-service.yohops.com:9999/', | ||
27 | + // liveApi: 'http://api.live.yoho.cn/', | ||
28 | + // singleApi: 'http://single.yoho.cn/', | ||
29 | 29 | ||
30 | imSocket: 'wss://imsocket.yohobuy.com:443', | 30 | imSocket: 'wss://imsocket.yohobuy.com:443', |
31 | imCs: 'https://imhttp.yohobuy.com/api', | 31 | imCs: 'https://imhttp.yohobuy.com/api', |
@@ -207,7 +207,7 @@ function orderCompute() { | @@ -207,7 +207,7 @@ function orderCompute() { | ||
207 | loading.showLoadingMask(); | 207 | loading.showLoadingMask(); |
208 | $.ajax({ | 208 | $.ajax({ |
209 | method: 'POST', | 209 | method: 'POST', |
210 | - url: '/cart/index/orderCompute', | 210 | + url: '/cart/index/new/orderCompute', |
211 | data: data | 211 | data: data |
212 | }).then(function(res) { | 212 | }).then(function(res) { |
213 | if ($.type(res) !== 'object') { | 213 | if ($.type(res) !== 'object') { |
-
Please register or login to post a comment