Authored by 郝肖肖

Merge branch 'feature/orderShare' into release/5.8

@@ -120,10 +120,6 @@ const getCartDelList = (req, res, addsStr, delSkuId) => { @@ -120,10 +120,6 @@ const getCartDelList = (req, res, addsStr, delSkuId) => {
120 const formatCartGoods = (cartGoods, isAdvanceCart, inValid, isOffShelves, analysis) => { 120 const formatCartGoods = (cartGoods, isAdvanceCart, inValid, isOffShelves, analysis) => {
121 121
122 return _.map(cartGoods, (it) => { 122 return _.map(cartGoods, (it) => {
123 - it.last_vip_price = transPrice(it.last_vip_price);  
124 - it.sales_price = transPrice(it.sales_price);  
125 - it.last_price = transPrice(it.last_price);  
126 -  
127 let goods = { 123 let goods = {
128 id: it.product_sku, 124 id: it.product_sku,
129 skn: it.product_skn, 125 skn: it.product_skn,
@@ -134,7 +130,7 @@ const formatCartGoods = (cartGoods, isAdvanceCart, inValid, isOffShelves, analys @@ -134,7 +130,7 @@ const formatCartGoods = (cartGoods, isAdvanceCart, inValid, isOffShelves, analys
134 imgCover: it.goods_images ? helpers.image(it.goods_images, 64, 88) : '', 130 imgCover: it.goods_images ? helpers.image(it.goods_images, 64, 88) : '',
135 productColor: it.factory_goods_name, 131 productColor: it.factory_goods_name,
136 productSize: it.size_name, 132 productSize: it.size_name,
137 - productPrice: it.sales_price, 133 + productPrice: transPrice(it.sales_price),
138 productNum: Number(it.buy_number), 134 productNum: Number(it.buy_number),
139 storageNum: Number(it.storage_number), 135 storageNum: Number(it.storage_number),
140 isSoldOut: parseInt(it.storage_number, 10) === 0 || parseInt(it.off_shelves, 10) === 1, // 已售罄 136 isSoldOut: parseInt(it.storage_number, 10) === 0 || parseInt(it.off_shelves, 10) === 1, // 已售罄
@@ -149,8 +145,8 @@ const formatCartGoods = (cartGoods, isAdvanceCart, inValid, isOffShelves, analys @@ -149,8 +145,8 @@ const formatCartGoods = (cartGoods, isAdvanceCart, inValid, isOffShelves, analys
149 145
150 // 划线的价格 146 // 划线的价格
151 if (it.last_vip_price < it.sales_price) { 147 if (it.last_vip_price < it.sales_price) {
152 - goods.productPrice = it.last_vip_price;  
153 - goods.linePrice = it.sales_price; // 划线的价格 148 + goods.productPrice = transPrice(it.last_vip_price);
  149 + goods.linePrice = transPrice(it.sales_price); // 划线的价格
154 } 150 }
155 151
156 if (it.min_buy_number) { 152 if (it.min_buy_number) {
@@ -182,16 +178,16 @@ const formatCartGoods = (cartGoods, isAdvanceCart, inValid, isOffShelves, analys @@ -182,16 +178,16 @@ const formatCartGoods = (cartGoods, isAdvanceCart, inValid, isOffShelves, analys
182 goods.inValid = true; 178 goods.inValid = true;
183 } else if (it.goods_type === 'gift') { // gift=>是否赠品 && it.isAdvanceBuy 179 } else if (it.goods_type === 'gift') { // gift=>是否赠品 && it.isAdvanceBuy
184 goods.isGift = true; 180 goods.isGift = true;
185 - goods.productPrice = it.last_price;  
186 - goods.linePrice = it.sales_price; // 划线的价格 181 + goods.productPrice = transPrice(it.last_price);
  182 + goods.linePrice = transPrice(it.sales_price); // 划线的价格
187 goods.productSubtotal = it.subtotal ? transPrice(it.subtotal) : goods.productPrice; 183 goods.productSubtotal = it.subtotal ? transPrice(it.subtotal) : goods.productPrice;
188 } else if (it.goods_type === 'price_gift') { // price_gift=>是否加价购 184 } else if (it.goods_type === 'price_gift') { // price_gift=>是否加价购
189 goods.isPriceGift = true; 185 goods.isPriceGift = true;
190 - goods.productPrice = it.last_price;  
191 - goods.linePrice = it.sales_price; // 划线的价格 186 + goods.productPrice = transPrice(it.last_price);
  187 + goods.linePrice = transPrice(it.sales_price); // 划线的价格
192 goods.productSubtotal = it.subtotal ? transPrice(it.subtotal) : goods.productPrice; 188 goods.productSubtotal = it.subtotal ? transPrice(it.subtotal) : goods.productPrice;
193 } else if (it.real_price === 0) { // 免单 189 } else if (it.real_price === 0) { // 免单
194 - goods.productPrice = it.sales_price; 190 + goods.productPrice = transPrice(it.sales_price);
195 goods.xForOne = true; 191 goods.xForOne = true;
196 192
197 // 分析用: 商品ID列表 193 // 分析用: 商品ID列表
@@ -10,6 +10,16 @@ const pager = require('./pager').handlePagerData; @@ -10,6 +10,16 @@ const pager = require('./pager').handlePagerData;
10 const orderApi = require('./orders-api'); 10 const orderApi = require('./orders-api');
11 const ChannelConfig = require('./channel-config'); 11 const ChannelConfig = require('./channel-config');
12 12
  13 +/**
  14 + * 转换价格
  15 + *
  16 + * @param float|string $price 价格
  17 + * @return float|string 转换之后的价格
  18 + */
  19 +const transPrice = (price) => {
  20 + return price ? (price * 1).toFixed(2) : '0.00';
  21 +};
  22 +
13 const ORDER_TYPE = { 23 const ORDER_TYPE = {
14 all: 1, // 全部 24 all: 1, // 全部
15 waitingForPay: 2, // 待付款 25 waitingForPay: 2, // 待付款
@@ -365,28 +375,26 @@ const getOrders = (uid, page, limit, type, isPage)=> { @@ -365,28 +375,26 @@ const getOrders = (uid, page, limit, type, isPage)=> {
365 newOrder.goods = _.get(order, 'order_goods', []).map((good) => { 375 newOrder.goods = _.get(order, 'order_goods', []).map((good) => {
366 let newGood = {}; 376 let newGood = {};
367 377
368 - good.real_pay_price = good.real_pay_price && Number(good.real_pay_price).toFixed(2) || '';  
369 - good.sales_price = good.sales_price && Number(good.sales_price).toFixed(2) || '';  
370 newGood.href = helpers.getUrlBySkc(good.product_skn); 378 newGood.href = helpers.getUrlBySkc(good.product_skn);
371 newGood.thumb = helpers.image(good.goods_image, 100, 100); 379 newGood.thumb = helpers.image(good.goods_image, 100, 100);
372 newGood.name = good.product_name; 380 newGood.name = good.product_name;
373 newGood.color = good.factory_color_name; 381 newGood.color = good.factory_color_name;
374 newGood.size = good.size_name; 382 newGood.size = good.size_name;
375 383
376 - newGood.price = good.sales_price;// 默认显示销售价 384 + newGood.price = transPrice(good.sales_price);// 默认显示销售价
377 newGood.isVipPrice = good.discount_tag === 'V'; 385 newGood.isVipPrice = good.discount_tag === 'V';
378 newGood.isStuPrice = good.discount_tag === 'S'; 386 newGood.isStuPrice = good.discount_tag === 'S';
379 387
380 // 划线的价格 388 // 划线的价格
381 if (good.real_pay_price < good.sales_price) { 389 if (good.real_pay_price < good.sales_price) {
382 - newGood.price = good.real_pay_price;// 显示分摊价  
383 - newGood.linePrice = good.sales_price; // 划线的价格 390 + newGood.price = transPrice(good.real_pay_price);// 显示分摊价
  391 + newGood.linePrice = transPrice(good.sales_price); // 划线的价格
384 } 392 }
385 393
386 // 赠品、加价购 394 // 赠品、加价购
387 if (good.goods_type === 'gift' || good.goods_type === 'price_gift') { 395 if (good.goods_type === 'gift' || good.goods_type === 'price_gift') {
388 - newGood.price = good.real_pay_price;// 显示分摊价  
389 - newGood.linePrice = good.sales_price; // 划线的价格 396 + newGood.price = transPrice(good.real_pay_price);// 显示分摊价
  397 + newGood.linePrice = transPrice(good.sales_price); // 划线的价格
390 } 398 }
391 399
392 let buyNum = _.parseInt(good.buy_number); 400 let buyNum = _.parseInt(good.buy_number);
@@ -776,16 +784,13 @@ const _getOrderDetail = co(function * (uid, orderId) { @@ -776,16 +784,13 @@ const _getOrderDetail = co(function * (uid, orderId) {
776 // 商品信息 784 // 商品信息
777 if (orderDetail.order_goods) { 785 if (orderDetail.order_goods) {
778 detail.goods = _.get(orderDetail, 'order_goods', []).map((good) => { 786 detail.goods = _.get(orderDetail, 'order_goods', []).map((good) => {
779 - good.real_pay_price = good.real_pay_price && Number(good.real_pay_price).toFixed(2) || '';  
780 - good.sales_price = good.sales_price && Number(good.sales_price).toFixed(2) || '';  
781 -  
782 let newGood = { 787 let newGood = {
783 url: helpers.getUrlBySkc(good.product_skn), 788 url: helpers.getUrlBySkc(good.product_skn),
784 img: helpers.image(good.goods_image, 60, 60), 789 img: helpers.image(good.goods_image, 60, 60),
785 name: good.product_name, 790 name: good.product_name,
786 color: good.factory_color_name, 791 color: good.factory_color_name,
787 size: good.size_name, 792 size: good.size_name,
788 - price: good.sales_price, // 默认显示销售价 793 + price: transPrice(good.sales_price), // 默认显示销售价
789 isVipPrice: good.discount_tag === 'V', 794 isVipPrice: good.discount_tag === 'V',
790 isStuPrice: good.discount_tag === 'S', 795 isStuPrice: good.discount_tag === 'S',
791 coin: good.yoho_give_coin, 796 coin: good.yoho_give_coin,
@@ -797,14 +802,14 @@ const _getOrderDetail = co(function * (uid, orderId) { @@ -797,14 +802,14 @@ const _getOrderDetail = co(function * (uid, orderId) {
797 802
798 // 划线的价格 803 // 划线的价格
799 if (good.real_pay_price < good.sales_price) { 804 if (good.real_pay_price < good.sales_price) {
800 - newGood.price = good.real_pay_price;// 显示分摊价  
801 - newGood.linePrice = good.sales_price; // 划线的价格 805 + newGood.price = transPrice(good.real_pay_price);// 显示分摊价
  806 + newGood.linePrice = transPrice(good.sales_price); // 划线的价格
802 } 807 }
803 808
804 // 赠品、加价购 809 // 赠品、加价购
805 if (good.goods_type === 'gift' || good.goods_type === 'price_gift') { 810 if (good.goods_type === 'gift' || good.goods_type === 'price_gift') {
806 - newGood.price = good.real_pay_price;// 显示分摊价  
807 - newGood.linePrice = good.sales_price; // 划线的价格 811 + newGood.price = transPrice(good.real_pay_price);// 显示分摊价
  812 + newGood.linePrice = transPrice(good.sales_price); // 划线的价格
808 } 813 }
809 814
810 return newGood; 815 return newGood;
@@ -39,6 +39,16 @@ const getProductUrlBySkc = (skn) => { @@ -39,6 +39,16 @@ const getProductUrlBySkc = (skn) => {
39 return helpers.getUrlBySkc(skn); 39 return helpers.getUrlBySkc(skn);
40 }; 40 };
41 41
  42 +/**
  43 + * 转换价格
  44 + *
  45 + * @param float|string $price 价格
  46 + * @return float|string 转换之后的价格
  47 + */
  48 +const transPrice = (price) => {
  49 + return price ? (price * 1).toFixed(2) : '0.00';
  50 +};
  51 +
42 const setDetailGoods = (list) => { 52 const setDetailGoods = (list) => {
43 let resData = []; 53 let resData = [];
44 let goods; 54 let goods;
@@ -52,15 +62,15 @@ const setDetailGoods = (list) => { @@ -52,15 +62,15 @@ const setDetailGoods = (list) => {
52 color: value.color_name, 62 color: value.color_name,
53 size: value.size_name, 63 size: value.size_name,
54 yoho_coin_cut_num: value.yoho_coin_cut_num, 64 yoho_coin_cut_num: value.yoho_coin_cut_num,
55 - real_pay_price: value.real_pay_price,  
56 - price: value.sales_price, 65 + real_pay_price: transPrice(value.real_pay_price),
  66 + price: transPrice(value.sales_price),
57 goods_type: value.goods_type, 67 goods_type: value.goods_type,
58 reason: value.reason_name 68 reason: value.reason_name
59 }; 69 };
60 70
61 if (value.real_pay_price < value.sales_price) { 71 if (value.real_pay_price < value.sales_price) {
62 - goods.price = value.real_pay_price;// 显示分摊价  
63 - goods.linePrice = value.sales_price; // 划线的价格 72 + goods.price = transPrice(value.real_pay_price);// 显示分摊价
  73 + goods.linePrice = transPrice(value.sales_price); // 划线的价格
64 } 74 }
65 75
66 resData.push(goods); 76 resData.push(goods);
@@ -202,7 +212,7 @@ const getOrderRefund = (orderCode, uid) => { @@ -202,7 +212,7 @@ const getOrderRefund = (orderCode, uid) => {
202 color: value.factory_color_name, 212 color: value.factory_color_name,
203 size: value.size_name, 213 size: value.size_name,
204 lastPrice: value.last_price, 214 lastPrice: value.last_price,
205 - price: value.real_pay_price, 215 + price: transPrice(value.real_pay_price),
206 skn: value.product_skn, 216 skn: value.product_skn,
207 skc: value.product_skc, 217 skc: value.product_skc,
208 sku: value.product_sku, 218 sku: value.product_sku,