Authored by 郭成尧

Merge branch 'feature/cart' into 'release/5.4.1'

修复了一些严重的BUG



See merge request !254
@@ -14,7 +14,7 @@ const authcode = require(global.utils + '/authcode'); @@ -14,7 +14,7 @@ const authcode = require(global.utils + '/authcode');
14 const actCkOpthn = { 14 const actCkOpthn = {
15 expires: 0, 15 expires: 0,
16 path: '/cart/index', 16 path: '/cart/index',
17 - domain: '.m.yohobuy.com' 17 + domain: 'm.yohobuy.com'
18 }; 18 };
19 19
20 exports.orderEnsure = (req, res, next) => { 20 exports.orderEnsure = (req, res, next) => {
@@ -81,9 +81,10 @@ exports.orderEnsure = (req, res, next) => { @@ -81,9 +81,10 @@ exports.orderEnsure = (req, res, next) => {
81 let orderAddress = _.get(order, 'address', []); 81 let orderAddress = _.get(order, 'address', []);
82 let addressList = _.get(address, 'data', []); 82 let addressList = _.get(address, 'data', []);
83 83
84 - orderAddress.length && addressList.forEach(address => { //eslint-disable-line 84 + orderAddress.length && _.forEach(addressList, address => { //eslint-disable-line
85 if (address.address_id === orderAddress.address_id) { 85 if (address.address_id === orderAddress.address_id) {
86 mobile = address.mobile; 86 mobile = address.mobile;
  87 + return false;
87 } 88 }
88 }); 89 });
89 90
@@ -143,7 +144,7 @@ exports.orderCompute = (req, res, next) => { @@ -143,7 +144,7 @@ exports.orderCompute = (req, res, next) => {
143 /** 144 /**
144 * 确认结算订单 145 * 确认结算订单
145 */ 146 */
146 -exports.orderSub = (req, res) => { 147 +exports.orderSub = (req, res, next) => {
147 let uid = req.user.uid; 148 let uid = req.user.uid;
148 let addressId = parseInt(crypto.decrypt('', req.body.addressId), 10); 149 let addressId = parseInt(crypto.decrypt('', req.body.addressId), 10);
149 let cartType = req.body.cartType || 'ordinary'; 150 let cartType = req.body.cartType || 'ordinary';
@@ -242,7 +243,7 @@ exports.orderSub = (req, res) => { @@ -242,7 +243,7 @@ exports.orderSub = (req, res) => {
242 } else { 243 } else {
243 return res.json(result); 244 return res.json(result);
244 } 245 }
245 - })(); 246 + })().catch(next);
246 }; 247 };
247 248
248 /** 249 /**
@@ -276,7 +277,7 @@ exports.couponList = (req, res, next) => { @@ -276,7 +277,7 @@ exports.couponList = (req, res, next) => {
276 return cartModel.getCouponList(uid) 277 return cartModel.getCouponList(uid)
277 .then(data => { 278 .then(data => {
278 res.json(data); 279 res.json(data);
279 - }); 280 + }).catch(next);
280 } else { 281 } else {
281 return next(); 282 return next();
282 } 283 }
@@ -299,7 +300,7 @@ exports.couponSearch = (req, res, next) => { @@ -299,7 +300,7 @@ exports.couponSearch = (req, res, next) => {
299 return next(); 300 return next();
300 } 301 }
301 302
302 - })(); 303 + })().catch(next);
303 }; 304 };
304 305
305 /** 306 /**
@@ -346,7 +347,7 @@ exports.selectAddress = (req, res, next) => { @@ -346,7 +347,7 @@ exports.selectAddress = (req, res, next) => {
346 /** 347 /**
347 * 发票信息 348 * 发票信息
348 */ 349 */
349 -exports.invoiceInfo = (req, res) => { 350 +exports.invoiceInfo = (req, res, next) => {
350 let uid = req.user.uid; 351 let uid = req.user.uid;
351 let cookieData = req.cookies['order-info']; 352 let cookieData = req.cookies['order-info'];
352 let orderInfo = JSON.parse(cookieData); 353 let orderInfo = JSON.parse(cookieData);
@@ -366,7 +367,7 @@ exports.invoiceInfo = (req, res) => { @@ -366,7 +367,7 @@ exports.invoiceInfo = (req, res) => {
366 module: 'cart', 367 module: 'cart',
367 page: 'select-invoice' 368 page: 'select-invoice'
368 })); 369 }));
369 - })(); 370 + })().catch(next);
370 }; 371 };
371 372
372 /** 373 /**
@@ -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-09 10:50:07 6 + * @Last Modified time: 2017-02-16 17:52:03
7 */ 7 */
8 8
9 'use strict'; 9 'use strict';
@@ -24,7 +24,7 @@ const common = require('../helpers/pay/common'); @@ -24,7 +24,7 @@ const common = require('../helpers/pay/common');
24 * @param res 24 * @param res
25 * @param next 25 * @param next
26 */ 26 */
27 -const payCenter = (req, res) => { 27 +const payCenter = (req, res, next) => {
28 let orderCode = req.query.order_code; 28 let orderCode = req.query.order_code;
29 let uid = req.user.uid; 29 let uid = req.user.uid;
30 let sessionKey = req.session.TOKEN; 30 let sessionKey = req.session.TOKEN;
@@ -87,7 +87,7 @@ const payCenter = (req, res) => { @@ -87,7 +87,7 @@ const payCenter = (req, res) => {
87 }; 87 };
88 88
89 res.render('pay/pay-center', responseData); 89 res.render('pay/pay-center', responseData);
90 - })(); 90 + })().catch(next);
91 }; 91 };
92 92
93 /** 93 /**
@@ -143,8 +143,8 @@ const pay = (req, res, next) => { @@ -143,8 +143,8 @@ const pay = (req, res, next) => {
143 } else { 143 } else {
144 return res.redirect('/'); 144 return res.redirect('/');
145 } 145 }
146 - }).catch(next);  
147 - })(); 146 + });
  147 + })().catch(next);
148 }; 148 };
149 149
150 // 货到付款 150 // 货到付款
@@ -75,10 +75,12 @@ exports.cartPay = (uid, cartType, orderInfo, limitProductCode, sku, skn, buyNumb @@ -75,10 +75,12 @@ exports.cartPay = (uid, cartType, orderInfo, limitProductCode, sku, skn, buyNumb
75 } 75 }
76 76
77 // 区分套餐量贩和普通商品 77 // 区分套餐量贩和普通商品
78 - let cartPayAPI = shoppingAPI.cartPayAPI(uid, cartType, 0, skuList); 78 + let cartPayAPI;
79 79
80 if (activityInfo) { 80 if (activityInfo) {
81 cartPayAPI = shoppingAPI.cartPayAPI(uid, cartType, 0, skuList, activityInfo); 81 cartPayAPI = shoppingAPI.cartPayAPI(uid, cartType, 0, skuList, activityInfo);
  82 + } else {
  83 + cartPayAPI = shoppingAPI.cartPayAPI(uid, cartType, 0, skuList);
82 } 84 }
83 85
84 return Promise.all([ 86 return Promise.all([
@@ -16,6 +16,7 @@ const processInvoiceData = (orderInfo, mobile, addresslist) => { @@ -16,6 +16,7 @@ const processInvoiceData = (orderInfo, mobile, addresslist) => {
16 _.forEach(addresslist, addressValue => { 16 _.forEach(addresslist, addressValue => {
17 if (addressValue.address_id === crypto.encryption('', orderInfo.addressId)) { 17 if (addressValue.address_id === crypto.encryption('', orderInfo.addressId)) {
18 mobile = addressValue.mobile; 18 mobile = addressValue.mobile;
  19 + return false;
19 } 20 }
20 }); 21 });
21 } 22 }
@@ -94,15 +94,15 @@ @@ -94,15 +94,15 @@
94 <a href="{{#if isLimit}}javascript:void(0);{{else}}/cart/index/new/selectCoupon{{/if}}"> 94 <a href="{{#if isLimit}}javascript:void(0);{{else}}/cart/index/new/selectCoupon{{/if}}">
95 <span class="title">优惠券</span> 95 <span class="title">优惠券</span>
96 {{# coupon}} 96 {{# coupon}}
97 - <span class="coupon-count">  
98 - {{count}}张可用  
99 - </span>  
100 {{#if couponName}} 97 {{#if couponName}}
101 <span class="used coupon-use" data-name="{{couponName}}"> 98 <span class="used coupon-use" data-name="{{couponName}}">
102 {{couponName}} 99 {{couponName}}
103 <i class="iconfont">&#xe614;</i> 100 <i class="iconfont">&#xe614;</i>
104 </span> 101 </span>
105 {{^}} 102 {{^}}
  103 + <span class="coupon-count">
  104 + {{count}}张可用
  105 + </span>
106 <span class="not-used coupon-use"> 106 <span class="not-used coupon-use">
107 {{#if isLimit}}该商品不可使用优惠券{{else}}未使用{{/if}} 107 {{#if isLimit}}该商品不可使用优惠券{{else}}未使用{{/if}}
108 <i class="iconfont">&#xe614;</i> 108 <i class="iconfont">&#xe614;</i>
@@ -320,7 +320,7 @@ @@ -320,7 +320,7 @@
320 320
321 .row .color { 321 .row .color {
322 display: inline-block; 322 display: inline-block;
323 - max-width: 5rem; 323 + max-width: 4rem;
324 text-overflow: ellipsis; 324 text-overflow: ellipsis;
325 overflow: hidden; 325 overflow: hidden;
326 white-space: nowrap; 326 white-space: nowrap;