Merge branch 'feature/cart' into 'release/5.4.1'
结算部分日志添加 See merge request !265
Showing
13 changed files
with
47 additions
and
15 deletions
@@ -9,6 +9,7 @@ const addressModel = require('../../serverAPI/user/address'); | @@ -9,6 +9,7 @@ const addressModel = require('../../serverAPI/user/address'); | ||
9 | const orderModel = require('../models/order'); | 9 | const orderModel = require('../models/order'); |
10 | const crypto = global.yoho.crypto; | 10 | const crypto = global.yoho.crypto; |
11 | const authcode = require(global.utils + '/authcode'); | 11 | const authcode = require(global.utils + '/authcode'); |
12 | +const logger = global.yoho.logger; | ||
12 | 13 | ||
13 | // cookie 参数 | 14 | // cookie 参数 |
14 | const actCkOpthn = { | 15 | const actCkOpthn = { |
@@ -31,6 +32,7 @@ exports.orderEnsure = (req, res, next) => { | @@ -31,6 +32,7 @@ exports.orderEnsure = (req, res, next) => { | ||
31 | try { | 32 | try { |
32 | orderInfo = JSON.parse(req.cookies['order-info']); | 33 | orderInfo = JSON.parse(req.cookies['order-info']); |
33 | } catch (e) { | 34 | } catch (e) { |
35 | + logger.info(`orderEnsure: get orderInfo from cookie error:${JSON.stringify(e)}`); | ||
34 | orderInfo = {}; | 36 | orderInfo = {}; |
35 | res.cookie('order-info', null, actCkOpthn); | 37 | res.cookie('order-info', null, actCkOpthn); |
36 | } | 38 | } |
@@ -68,11 +70,13 @@ exports.orderEnsure = (req, res, next) => { | @@ -68,11 +70,13 @@ exports.orderEnsure = (req, res, next) => { | ||
68 | let userProfile = result[1]; | 70 | let userProfile = result[1]; |
69 | let address = result[2]; | 71 | let address = result[2]; |
70 | 72 | ||
71 | - if (order.cartUrl) { // TODO? 普通或者预售商品为空时, BUT WHEN AJAX? | 73 | + if (order.cartUrl) { |
74 | + logger.info(`orderEnsure: order cartUrl has value:${order.cartUrl}, order data is null`); | ||
72 | return res.redirect(order.cartUrl); | 75 | return res.redirect(order.cartUrl); |
73 | } | 76 | } |
74 | 77 | ||
75 | if (req.xhr) { | 78 | if (req.xhr) { |
79 | + logger.info(`orderEnsure: ajax request, return json:${JSON.stringify(order)}`); | ||
76 | return res.json(order); | 80 | return res.json(order); |
77 | } | 81 | } |
78 | 82 | ||
@@ -183,7 +187,6 @@ exports.orderSub = (req, res, next) => { | @@ -183,7 +187,6 @@ exports.orderSub = (req, res, next) => { | ||
183 | let userAgent = null; | 187 | let userAgent = null; |
184 | let unionKey = ''; | 188 | let unionKey = ''; |
185 | let unionInfo = {}; | 189 | let unionInfo = {}; |
186 | - let testQyhUnion = {}; | ||
187 | 190 | ||
188 | if (req.cookies.mkt_code || req.cookies._QYH_UNION) { | 191 | if (req.cookies.mkt_code || req.cookies._QYH_UNION) { |
189 | /* | 192 | /* |
@@ -198,8 +201,10 @@ exports.orderSub = (req, res, next) => { | @@ -198,8 +201,10 @@ exports.orderSub = (req, res, next) => { | ||
198 | 201 | ||
199 | if (!unionKey) { | 202 | if (!unionKey) { |
200 | let encryData = crypto.decrypt('', decodeURIComponent(req.cookies._QYH_UNION)); | 203 | let encryData = crypto.decrypt('', decodeURIComponent(req.cookies._QYH_UNION)); |
204 | + | ||
201 | encryData = encryData.substr(0, encryData.lastIndexOf('}') + 1); | 205 | encryData = encryData.substr(0, encryData.lastIndexOf('}') + 1); |
202 | let testQyhUnion = JSON.parse(encryData); | 206 | let testQyhUnion = JSON.parse(encryData); |
207 | + | ||
203 | unionKey = testQyhUnion.client_id ? encryData : ''; | 208 | unionKey = testQyhUnion.client_id ? encryData : ''; |
204 | } | 209 | } |
205 | } else { | 210 | } else { |
@@ -232,6 +237,8 @@ exports.orderSub = (req, res, next) => { | @@ -232,6 +237,8 @@ exports.orderSub = (req, res, next) => { | ||
232 | 237 | ||
233 | if (unionInfo && result.data) { | 238 | if (unionInfo && result.data) { |
234 | result.data.unionCookie = unionInfo; | 239 | result.data.unionCookie = unionInfo; |
240 | + } else { | ||
241 | + logger.info(`orderEnsure: unionInfo:${JSON.stringify(unionInfo)}, result data:${JSON.stringify(result.data)}`); | ||
235 | } | 242 | } |
236 | 243 | ||
237 | // 提交成功清除Cookie | 244 | // 提交成功清除Cookie |
@@ -3,7 +3,7 @@ | @@ -3,7 +3,7 @@ | ||
3 | * @Author: Targaryen | 3 | * @Author: Targaryen |
4 | * @Date: 2017-01-04 15:17:51 | 4 | * @Date: 2017-01-04 15:17:51 |
5 | * @Last Modified by: Targaryen | 5 | * @Last Modified by: Targaryen |
6 | - * @Last Modified time: 2017-02-17 09:52:57 | 6 | + * @Last Modified time: 2017-02-20 10:43:10 |
7 | */ | 7 | */ |
8 | 8 | ||
9 | 'use strict'; | 9 | 'use strict'; |
@@ -17,6 +17,7 @@ const helpers = global.yoho.helpers; | @@ -17,6 +17,7 @@ const helpers = global.yoho.helpers; | ||
17 | const Payment = require('../helpers/payment'); | 17 | const Payment = require('../helpers/payment'); |
18 | const WxPay = require('../helpers/pay/wechat'); | 18 | const WxPay = require('../helpers/pay/wechat'); |
19 | const common = require('../helpers/pay/common'); | 19 | const common = require('../helpers/pay/common'); |
20 | +const logger = global.yoho.logger; | ||
20 | 21 | ||
21 | /** | 22 | /** |
22 | * 支付中心 | 23 | * 支付中心 |
@@ -32,11 +33,14 @@ const payCenter = (req, res, next) => { | @@ -32,11 +33,14 @@ const payCenter = (req, res, next) => { | ||
32 | let hasWxShare = Boolean(userAgent.match(/MicroMessenger/i) && userAgent.match(/MicroMessenger/i).length > 0); | 33 | let hasWxShare = Boolean(userAgent.match(/MicroMessenger/i) && userAgent.match(/MicroMessenger/i).length > 0); |
33 | 34 | ||
34 | if (!orderCode || !uid) { | 35 | if (!orderCode || !uid) { |
36 | + logger.info(`payCenter:no orderCode or uid:orderCode ${orderCode}, uid ${uid}`); | ||
35 | res.redirect('/'); | 37 | res.redirect('/'); |
36 | } | 38 | } |
37 | 39 | ||
38 | if (sessionKey) { | 40 | if (sessionKey) { |
39 | sessionKey = sessionKey.substr(0, sessionKey.length - 8); | 41 | sessionKey = sessionKey.substr(0, sessionKey.length - 8); |
42 | + } else { | ||
43 | + logger.info(`payCenter: orderCode-${orderCode} no sessionKey`); | ||
40 | } | 44 | } |
41 | 45 | ||
42 | co(function* () { | 46 | co(function* () { |
@@ -48,6 +52,7 @@ const payCenter = (req, res, next) => { | @@ -48,6 +52,7 @@ const payCenter = (req, res, next) => { | ||
48 | 52 | ||
49 | /* 判断订单是否已付款, 已付款跳到订单详情页 */ | 53 | /* 判断订单是否已付款, 已付款跳到订单详情页 */ |
50 | if (orderDetail.isPay) { | 54 | if (orderDetail.isPay) { |
55 | + logger.info(`payCenter: orderCode-${orderCode} already paied`); | ||
51 | return res.redirect(helpers.urlFormat('/cart/shopping/pay/payZero', {order_code: orderCode})); | 56 | return res.redirect(helpers.urlFormat('/cart/shopping/pay/payZero', {order_code: orderCode})); |
52 | } | 57 | } |
53 | 58 | ||
@@ -110,7 +115,7 @@ const pay = (req, res, next) => { | @@ -110,7 +115,7 @@ const pay = (req, res, next) => { | ||
110 | let paymentCode = common.getPaymentCode(payment); | 115 | let paymentCode = common.getPaymentCode(payment); |
111 | let openId = req.cookies['weixinOpenId' + orderCode]; | 116 | let openId = req.cookies['weixinOpenId' + orderCode]; |
112 | 117 | ||
113 | - if (!orderCode || !uid || !sessionKey) { | 118 | + if (!orderCode || !uid) { |
114 | return res.redirect('/'); | 119 | return res.redirect('/'); |
115 | } | 120 | } |
116 | 121 |
@@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
2 | * 秒杀结算 | 2 | * 秒杀结算 |
3 | */ | 3 | */ |
4 | 'use strict'; | 4 | 'use strict'; |
5 | +const _ = require('lodash'); | ||
5 | const crypto = global.yoho.crypto; | 6 | const crypto = global.yoho.crypto; |
6 | const co = require('bluebird').coroutine; | 7 | const co = require('bluebird').coroutine; |
7 | const seckillModel = require('../models/seckill'); | 8 | const seckillModel = require('../models/seckill'); |
@@ -55,8 +56,18 @@ exports.ensure = (req, res, next) => { | @@ -55,8 +56,18 @@ exports.ensure = (req, res, next) => { | ||
55 | 56 | ||
56 | paymentOption.activity_id = activityId = skillData.activityId; | 57 | paymentOption.activity_id = activityId = skillData.activityId; |
57 | 58 | ||
59 | + let orderComputerData; | ||
60 | + | ||
61 | + if (orderInfo) { | ||
62 | + orderComputerData = yield seckillModel.compute(_.assign(paymentOption, { | ||
63 | + delivery_way: orderInfo.deliveryId, | ||
64 | + payment_type: orderInfo.paymentType, | ||
65 | + use_yoho_coin: orderInfo.yohoCoin | ||
66 | + })); | ||
67 | + } | ||
68 | + | ||
58 | // 获取结算 数据 | 69 | // 获取结算 数据 |
59 | - let paymentInfo = yield seckillModel.payment(paymentOption, orderInfo); | 70 | + let paymentInfo = yield seckillModel.payment(paymentOption, orderInfo, orderComputerData.data); |
60 | let view; | 71 | let view; |
61 | 72 | ||
62 | if (paymentInfo.code !== 200) { | 73 | if (paymentInfo.code !== 200) { |
@@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
2 | * @Author: Targaryen | 2 | * @Author: Targaryen |
3 | * @Date: 2017-01-03 17:42:41 | 3 | * @Date: 2017-01-03 17:42:41 |
4 | * @Last Modified by: Targaryen | 4 | * @Last Modified by: Targaryen |
5 | - * @Last Modified time: 2017-01-09 17:53:16 | 5 | + * @Last Modified time: 2017-02-20 10:15:03 |
6 | */ | 6 | */ |
7 | 7 | ||
8 | 'use strict'; | 8 | 'use strict'; |
@@ -146,6 +146,7 @@ const Wechat = { | @@ -146,6 +146,7 @@ const Wechat = { | ||
146 | let baseUrl = 'http://m.yohobuy.com' + originalUrl; | 146 | let baseUrl = 'http://m.yohobuy.com' + originalUrl; |
147 | let redirectUrl = tools.createOauthUrlForCode(baseUrl); | 147 | let redirectUrl = tools.createOauthUrlForCode(baseUrl); |
148 | 148 | ||
149 | + logger.info('payCenter: wechat pay no code'); | ||
149 | return Promise.resolve({ redirectUrl: redirectUrl }); | 150 | return Promise.resolve({ redirectUrl: redirectUrl }); |
150 | } else { | 151 | } else { |
151 | return tools.getOpenidFromMp(code).then(openid => { | 152 | return tools.getOpenidFromMp(code).then(openid => { |
@@ -187,6 +188,7 @@ const Wechat = { | @@ -187,6 +188,7 @@ const Wechat = { | ||
187 | } | 188 | } |
188 | }; | 189 | }; |
189 | } else { | 190 | } else { |
191 | + logger.info('payCenter: wechat pay no unifiedOrderResult'); | ||
190 | return {}; | 192 | return {}; |
191 | } | 193 | } |
192 | 194 |
@@ -49,6 +49,7 @@ const Payment = { | @@ -49,6 +49,7 @@ const Payment = { | ||
49 | let method = common.getPaymentCode(payType); | 49 | let method = common.getPaymentCode(payType); |
50 | 50 | ||
51 | if (!method) { | 51 | if (!method) { |
52 | + logger.info('payCenter: payment no method params'); | ||
52 | return result; | 53 | return result; |
53 | } | 54 | } |
54 | 55 |
@@ -4,6 +4,7 @@ const _ = require('lodash'); | @@ -4,6 +4,7 @@ const _ = require('lodash'); | ||
4 | const helpers = global.yoho.helpers; | 4 | const helpers = global.yoho.helpers; |
5 | const paymentProcess = require(global.utils + '/payment-process'); | 5 | const paymentProcess = require(global.utils + '/payment-process'); |
6 | const shoppingAPI = require('../../serverAPI/order/shopping'); | 6 | const shoppingAPI = require('../../serverAPI/order/shopping'); |
7 | +const logger = global.yoho.logger; | ||
7 | 8 | ||
8 | /** | 9 | /** |
9 | * 转换价格 | 10 | * 转换价格 |
@@ -62,7 +63,7 @@ exports.cartPay = (uid, cartType, orderInfo, limitProductCode, sku, skn, buyNumb | @@ -62,7 +63,7 @@ exports.cartPay = (uid, cartType, orderInfo, limitProductCode, sku, skn, buyNumb | ||
62 | } | 63 | } |
63 | 64 | ||
64 | // cookie保存的数据 | 65 | // cookie保存的数据 |
65 | - if (!_.isEmpty(orderInfo)) { | 66 | + if (orderInfo) { |
66 | orderInfo.paymentType = orderInfo.paymentType ? orderInfo.paymentType : ''; | 67 | orderInfo.paymentType = orderInfo.paymentType ? orderInfo.paymentType : ''; |
67 | orderComputeAPI = shoppingAPI.orderComputeAPI( | 68 | orderComputeAPI = shoppingAPI.orderComputeAPI( |
68 | uid, | 69 | uid, |
@@ -95,6 +96,7 @@ exports.cartPay = (uid, cartType, orderInfo, limitProductCode, sku, skn, buyNumb | @@ -95,6 +96,7 @@ exports.cartPay = (uid, cartType, orderInfo, limitProductCode, sku, skn, buyNumb | ||
95 | let goodsList = _.get(pay, 'data.goods_list', []); | 96 | let goodsList = _.get(pay, 'data.goods_list', []); |
96 | 97 | ||
97 | if (_.isEmpty(goodsList)) { | 98 | if (_.isEmpty(goodsList)) { |
99 | + logger.info(`orderEnsure: goodsList is empty, isLimitGoods: ${isLimitGoods}`); | ||
98 | if (isLimitGoods) { | 100 | if (isLimitGoods) { |
99 | result.error = true; | 101 | result.error = true; |
100 | result.message = pay.message; | 102 | result.message = pay.message; |
@@ -17,7 +17,7 @@ exports.skillData = product_skn => { | @@ -17,7 +17,7 @@ exports.skillData = product_skn => { | ||
17 | }; | 17 | }; |
18 | 18 | ||
19 | 19 | ||
20 | -exports.payment = (options, orderInfo) => { | 20 | +exports.payment = (options, orderInfo, orderComputerData) => { |
21 | let queryData = Object.assign({ | 21 | let queryData = Object.assign({ |
22 | method: 'app.Seckill.payment', | 22 | method: 'app.Seckill.payment', |
23 | }, options); | 23 | }, options); |
@@ -26,7 +26,7 @@ exports.payment = (options, orderInfo) => { | @@ -26,7 +26,7 @@ exports.payment = (options, orderInfo) => { | ||
26 | .then(result => { | 26 | .then(result => { |
27 | // TODO 数据处理 | 27 | // TODO 数据处理 |
28 | if (result.code === 200 && result.data) { | 28 | if (result.code === 200 && result.data) { |
29 | - result.data = paymentProcess.tranformPayment(result.data, orderInfo); | 29 | + result.data = paymentProcess.tranformPayment(result.data, orderInfo, null, null, orderComputerData); |
30 | } | 30 | } |
31 | return result; | 31 | return result; |
32 | }); | 32 | }); |
@@ -19,6 +19,10 @@ const orderDetailData = (req, res, next) => { | @@ -19,6 +19,10 @@ const orderDetailData = (req, res, next) => { | ||
19 | 'http://chat8.live800.com/live800/chatClient/chatbox.jsp?companyID=620092&configID=149091&jid=8732423409&info='; | 19 | 'http://chat8.live800.com/live800/chatClient/chatbox.jsp?companyID=620092&configID=149091&jid=8732423409&info='; |
20 | 20 | ||
21 | orderDetailModel.orderDetailData(uid, orderCode).then(result => { | 21 | orderDetailModel.orderDetailData(uid, orderCode).then(result => { |
22 | + if (!result || _.isEmpty(result)) { | ||
23 | + return next(404); | ||
24 | + } | ||
25 | + | ||
22 | result.serviceUrl = serviceUrl; | 26 | result.serviceUrl = serviceUrl; |
23 | res.render('orderDetail', { | 27 | res.render('orderDetail', { |
24 | module: 'home', | 28 | module: 'home', |
@@ -104,6 +104,6 @@ $buyNowBtn.on('click', function() { | @@ -104,6 +104,6 @@ $buyNowBtn.on('click', function() { | ||
104 | activity_id: bundleId | 104 | activity_id: bundleId |
105 | }), actCkOpthn); | 105 | }), actCkOpthn); |
106 | 106 | ||
107 | - window.location.href = '/cart/index/orderEnsure?cartType=bundle&activityType=bundle'; | 107 | + window.location.href = '/cart/index/new/orderEnsure?cartType=bundle&activityType=bundle'; |
108 | } | 108 | } |
109 | }); | 109 | }); |
1 | /** | 1 | /** |
2 | - * 购物车选择尺寸、颜色和数量面板 | 2 | + * 套餐购物车选择尺寸、颜色和数量面板 |
3 | * 显示时构造当前商品信息的HTML插入yoho-page;消失则是直接清除HTML | 3 | * 显示时构造当前商品信息的HTML插入yoho-page;消失则是直接清除HTML |
4 | * @author: xuqi<qi.xu@yoho.cn> | 4 | * @author: xuqi<qi.xu@yoho.cn> |
5 | * @date: 2015/10/21 | 5 | * @date: 2015/10/21 |
@@ -416,7 +416,7 @@ $yohoPage.on('touchstart', '.btn-minus', function () { | @@ -416,7 +416,7 @@ $yohoPage.on('touchstart', '.btn-minus', function () { | ||
416 | function () { | 416 | function () { |
417 | var sizeChose = $('.size-list').find('.chosed'), | 417 | var sizeChose = $('.size-list').find('.chosed'), |
418 | productSku = sizeChose.data('skuid'), | 418 | productSku = sizeChose.data('skuid'), |
419 | - color = $('.color-list').find('.chosed').html(), | 419 | + color = $('.color-list').find('.chosed').html().substring(0,4) + '...', |
420 | size = sizeChose.html(); | 420 | size = sizeChose.html(); |
421 | choseEnsure(productSkn, productSku, color, size); | 421 | choseEnsure(productSkn, productSku, color, size); |
422 | hide(); | 422 | hide(); |
@@ -159,7 +159,7 @@ | @@ -159,7 +159,7 @@ | ||
159 | background: #fff; | 159 | background: #fff; |
160 | padding: 0.5rem 0.75rem; | 160 | padding: 0.5rem 0.75rem; |
161 | height: 1.5rem; | 161 | height: 1.5rem; |
162 | - line-height: 1.5rem; | 162 | + line-height: 0.5rem; |
163 | font-size: 0.7rem; | 163 | font-size: 0.7rem; |
164 | 164 | ||
165 | .bg-dollar { | 165 | .bg-dollar { |
@@ -183,7 +183,7 @@ function tranformPayment(data, orderInfo, cartType, skuList, orderComputeData) { | @@ -183,7 +183,7 @@ function tranformPayment(data, orderInfo, cartType, skuList, orderComputeData) { | ||
183 | }); | 183 | }); |
184 | 184 | ||
185 | result.goods = goods; | 185 | result.goods = goods; |
186 | - result.goodsPrice = goodsPrice; | 186 | + result.goodsPrice = goodsPrice.toFixed(2); |
187 | } | 187 | } |
188 | 188 | ||
189 | // 支付方式 | 189 | // 支付方式 |
-
Please register or login to post a comment