Authored by 郭成尧

merge-conflict-solved

@@ -2,7 +2,6 @@ @@ -2,7 +2,6 @@
2 * @Author: Targaryen 2 * @Author: Targaryen
3 * @Date: 2017-06-21 10:15:38 3 * @Date: 2017-06-21 10:15:38
4 * @Last Modified by: Targaryen 4 * @Last Modified by: Targaryen
5 - * @Last Modified time: 2017-06-26 16:21:29  
6 */ 5 */
7 const _ = require('lodash'); 6 const _ = require('lodash');
8 const co = require('bluebird').coroutine; 7 const co = require('bluebird').coroutine;
@@ -16,6 +15,7 @@ const paymentProcess = require(`${utils}/payment-process`); @@ -16,6 +15,7 @@ const paymentProcess = require(`${utils}/payment-process`);
16 const crypto = global.yoho.crypto; 15 const crypto = global.yoho.crypto;
17 const logger = global.yoho.logger; 16 const logger = global.yoho.logger;
18 const helpers = global.yoho.helpers; 17 const helpers = global.yoho.helpers;
  18 +const camelCase = global.yoho.camelCase;
19 19
20 // cookie 参数 20 // cookie 参数
21 const actCkOpthn = { 21 const actCkOpthn = {
@@ -53,13 +53,18 @@ class BuyNowController { @@ -53,13 +53,18 @@ class BuyNowController {
53 product_sku: product_sku, 53 product_sku: product_sku,
54 sku_type: req.query.sku_type, 54 sku_type: req.query.sku_type,
55 buy_number: buy_number, 55 buy_number: buy_number,
  56 + yoho_coin_mode: parseInt(orderInfo.use_yoho_coin, 10) > 0 ? 1 : 0
56 }); 57 });
57 let computeData = yield req.ctx(BuyNowModel).compute({ 58 let computeData = yield req.ctx(BuyNowModel).compute({
58 uid: req.user.uid, 59 uid: req.user.uid,
59 product_sku: product_sku, 60 product_sku: product_sku,
60 sku_type: req.query.sku_type, 61 sku_type: req.query.sku_type,
61 buy_number: buy_number, 62 buy_number: buy_number,
62 - use_yoho_coin: parseInt(orderInfo.use_yoho_coin, 10) 63 + payment_type: orderInfo.payment_type,
  64 + delivery_way: orderInfo.delivery_way,
  65 + use_yoho_coin: parseInt(orderInfo.use_yoho_coin, 10),
  66 + coupon_code: orderInfo.coupon_code,
  67 + promotion_code: orderInfo.promotion_code
63 }); 68 });
64 let validCouponCount = yield req.ctx(BuyNowModel).countUsableCoupon({ 69 let validCouponCount = yield req.ctx(BuyNowModel).countUsableCoupon({
65 uid: req.user.uid, 70 uid: req.user.uid,
@@ -71,6 +76,25 @@ class BuyNowController { @@ -71,6 +76,25 @@ class BuyNowController {
71 navTitle: '确认订单', 76 navTitle: '确认订单',
72 navBtn: false 77 navBtn: false
73 }); 78 });
  79 + let orderEnsure = _.assign(
  80 + paymentProcess.tranformPayment(result.data, orderInfo, null, null, computeData.data),
  81 + {
  82 + coupon: paymentProcess.coupon(
  83 + _.get(validCouponCount, 'data.count', 0),
  84 + orderInfo,
  85 + computeData.data
  86 + ),
  87 + selectAddressUrl: helpers.urlFormat('/cart/index/buynow/selectAddress', {
  88 + product_sku: product_sku,
  89 + buy_number: buy_number
  90 + }),
  91 + selectCouponUrl: helpers.urlFormat('/cart/index/buynow/selectCoupon', {
  92 + product_sku: product_sku,
  93 + buy_number: buy_number
  94 + }),
  95 + isOrdinaryCart: true
  96 + }
  97 + );
74 98
75 return res.render('buynow/order-ensure', { 99 return res.render('buynow/order-ensure', {
76 pageHeader: headerData, 100 pageHeader: headerData,
@@ -80,17 +104,7 @@ class BuyNowController { @@ -80,17 +104,7 @@ class BuyNowController {
80 width750: true, 104 width750: true,
81 localCss: true, 105 localCss: true,
82 product_sku: product_sku, 106 product_sku: product_sku,
83 - orderEnsure: _.assign(  
84 - paymentProcess.tranformPayment(result.data, orderInfo, null, null, computeData.data),  
85 - {  
86 - coupon: paymentProcess.coupon(_.get(validCouponCount, 'data.count', 0), orderInfo, computeData),  
87 - selectAddressUrl: helpers.urlFormat('/cart/index/buynow/selectAddress', {  
88 - product_sku: product_sku,  
89 - buy_number: buy_number  
90 - }),  
91 - isOrdinaryCart: true  
92 - }  
93 - ) 107 + orderEnsure: orderEnsure
94 }); 108 });
95 109
96 })().catch(next); 110 })().catch(next);
@@ -283,7 +297,9 @@ class BuyNowController { @@ -283,7 +297,9 @@ class BuyNowController {
283 buy_number: req.query.buy_number 297 buy_number: req.query.buy_number
284 }); 298 });
285 299
286 - res.json(result); 300 + let finalResult = _.get(result, 'data', {});
  301 +
  302 + res.json(camelCase(finalResult));
287 })().catch(next); 303 })().catch(next);
288 } 304 }
289 305
@@ -91,7 +91,7 @@ @@ -91,7 +91,7 @@
91 <ul class="sale-invoice"> 91 <ul class="sale-invoice">
92 {{#if isOrdinaryCart}} 92 {{#if isOrdinaryCart}}
93 <li class="coupon"> 93 <li class="coupon">
94 - <a href="{{#if isLimit}}javascript:void(0);{{else}}/cart/index/buynow/selectCoupon?product_sku={{@root.product_sku}}{{/if}}"> 94 + <a href="{{selectCouponUrl}}">
95 <span class="title">优惠券/优惠券码</span> 95 <span class="title">优惠券/优惠券码</span>
96 {{# coupon}} 96 {{# coupon}}
97 {{#if couponName}} 97 {{#if couponName}}
@@ -2,7 +2,6 @@ @@ -2,7 +2,6 @@
2 * @Author: Targaryen 2 * @Author: Targaryen
3 * @Date: 2017-06-21 10:30:21 3 * @Date: 2017-06-21 10:30:21
4 * @Last Modified by: Targaryen 4 * @Last Modified by: Targaryen
5 - * @Last Modified time: 2017-06-26 18:01:45  
6 */ 5 */
7 require('buynow/order-ensure.page.css'); 6 require('buynow/order-ensure.page.css');
8 const $ = require('yoho-jquery'); 7 const $ = require('yoho-jquery');
@@ -118,12 +117,6 @@ if ($couponUse.data('name') !== orderInfo('couponName')) { @@ -118,12 +117,6 @@ if ($couponUse.data('name') !== orderInfo('couponName')) {
118 orderInfo('couponName', null); 117 orderInfo('couponName', null);
119 } 118 }
120 119
121 -// 来自购物车的链接默认不使用优惠券  
122 -if (document.referrer && document.referrer.indexOf('/cart/index/index') !== -1) {  
123 - orderInfo('coupon_code', null);  
124 - orderInfo('couponName', null);  
125 -}  
126 -  
127 isLimitGood() && (function() { 120 isLimitGood() && (function() {
128 let a = []; 121 let a = [];
129 122
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 * @Author: Targaryen 2 * @Author: Targaryen
3 * @Date: 2017-06-23 11:43:44 3 * @Date: 2017-06-23 11:43:44
4 * @Last Modified by: Targaryen 4 * @Last Modified by: Targaryen
5 - * @Last Modified time: 2017-06-23 17:43:50 5 + * @Last Modified time: 2017-06-27 14:58:41
6 */ 6 */
7 require('cart/select-coupon.page.css'); 7 require('cart/select-coupon.page.css');
8 const qs = require('yoho-qs'); 8 const qs = require('yoho-qs');
@@ -115,8 +115,8 @@ function getCouponHandle(allCoupons) { @@ -115,8 +115,8 @@ function getCouponHandle(allCoupons) {
115 coupons; 115 coupons;
116 116
117 // 把可用和不可用的优惠券分离出来 117 // 把可用和不可用的优惠券分离出来
118 - notAvailableCoupons = allCoupons.notAvailableCoupons;  
119 - coupons = allCoupons.coupons; 118 + notAvailableCoupons = allCoupons.unusableCoupons;
  119 + coupons = allCoupons.usableCoupons;
120 120
121 // 没有优惠券 121 // 没有优惠券
122 if (!(notAvailableCoupons.length || coupons.length)) { 122 if (!(notAvailableCoupons.length || coupons.length)) {
@@ -128,10 +128,12 @@ function getCouponHandle(allCoupons) { @@ -128,10 +128,12 @@ function getCouponHandle(allCoupons) {
128 128
129 $.each(coupons, function(i, coupon) { 129 $.each(coupons, function(i, coupon) {
130 coupon.couponValue = Math.floor(coupon.couponValue); 130 coupon.couponValue = Math.floor(coupon.couponValue);
  131 + coupon.couponDetailInfomation = coupon.couponName;
131 }); 132 });
132 133
133 $.each(notAvailableCoupons, function(i, coupon) { 134 $.each(notAvailableCoupons, function(i, coupon) {
134 coupon.couponValue = Math.floor(coupon.couponValue); 135 coupon.couponValue = Math.floor(coupon.couponValue);
  136 + coupon.couponDetailInfomation = coupon.couponName;
135 }); 137 });
136 138
137 // 渲染可用的优惠券 139 // 渲染可用的优惠券