Showing
1 changed file
with
25 additions
and
1 deletions
@@ -12,6 +12,20 @@ const crypto = global.yoho.crypto; | @@ -12,6 +12,20 @@ const crypto = global.yoho.crypto; | ||
12 | 12 | ||
13 | const easypayApi = require('./easypay-api'); | 13 | const easypayApi = require('./easypay-api'); |
14 | 14 | ||
15 | +const handelViewPrice = list => { | ||
16 | + if (list) { | ||
17 | + _.forEach(list, val => { | ||
18 | + if (val.promotion === '商品金额') { | ||
19 | + val.promotion = '商品总价'; | ||
20 | + val.promotion_amount = `+ ${val.promotion_amount}`; | ||
21 | + } else { | ||
22 | + val.promotion_amount = _.replace(val.promotion_amount, '+', '+ '); | ||
23 | + val.promotion_amount = _.replace(val.promotion_amount, '-', '- '); | ||
24 | + } | ||
25 | + }); | ||
26 | + } | ||
27 | +}; | ||
28 | + | ||
15 | const _handelPaymentInfo = (d) => { | 29 | const _handelPaymentInfo = (d) => { |
16 | let resData = {}; | 30 | let resData = {}; |
17 | 31 | ||
@@ -66,6 +80,10 @@ const _handelPaymentInfo = (d) => { | @@ -66,6 +80,10 @@ const _handelPaymentInfo = (d) => { | ||
66 | contractMe: false | 80 | contractMe: false |
67 | }; | 81 | }; |
68 | 82 | ||
83 | + if (d.shopping_cart_data && d.shopping_cart_data.promotion_formula_list) { | ||
84 | + handelViewPrice(d.shopping_cart_data.promotion_formula_list); | ||
85 | + } | ||
86 | + | ||
69 | Object.assign(resData, { | 87 | Object.assign(resData, { |
70 | paymentWay: d.payment_way, | 88 | paymentWay: d.payment_way, |
71 | deliveryTime: d.delivery_time, | 89 | deliveryTime: d.delivery_time, |
@@ -119,7 +137,13 @@ const getOrderComputeData = (uid, cartType, params) => { | @@ -119,7 +137,13 @@ const getOrderComputeData = (uid, cartType, params) => { | ||
119 | 137 | ||
120 | return easypayApi.getEasypayComputeAsync(uid, cartType, params.paymentType, params.deliveryWay, params).then(result => { // eslint-disable-line | 138 | return easypayApi.getEasypayComputeAsync(uid, cartType, params.paymentType, params.deliveryWay, params).then(result => { // eslint-disable-line |
121 | if (result.code === 200) { | 139 | if (result.code === 200) { |
122 | - result.data.last_order_amount = _.round(result.data.last_order_amount, 2); | 140 | + if (_.has(result, 'data.last_order_amount')) { |
141 | + result.data.last_order_amount = _.round(result.data.last_order_amount, 2); | ||
142 | + } | ||
143 | + | ||
144 | + if (_.has(result, 'data.promotion_formula_list')) { | ||
145 | + handelViewPrice(result.data.promotion_formula_list); | ||
146 | + } | ||
123 | } | 147 | } |
124 | return result; | 148 | return result; |
125 | }); | 149 | }); |
-
Please register or login to post a comment