Authored by 郝肖肖

Merge branch 'feature/orderShare' into release/5.8

... ... @@ -120,10 +120,6 @@ const getCartDelList = (req, res, addsStr, delSkuId) => {
const formatCartGoods = (cartGoods, isAdvanceCart, inValid, isOffShelves, analysis) => {
return _.map(cartGoods, (it) => {
it.last_vip_price = transPrice(it.last_vip_price);
it.sales_price = transPrice(it.sales_price);
it.last_price = transPrice(it.last_price);
let goods = {
id: it.product_sku,
skn: it.product_skn,
... ... @@ -134,7 +130,7 @@ const formatCartGoods = (cartGoods, isAdvanceCart, inValid, isOffShelves, analys
imgCover: it.goods_images ? helpers.image(it.goods_images, 64, 88) : '',
productColor: it.factory_goods_name,
productSize: it.size_name,
productPrice: it.sales_price,
productPrice: transPrice(it.sales_price),
productNum: Number(it.buy_number),
storageNum: Number(it.storage_number),
isSoldOut: parseInt(it.storage_number, 10) === 0 || parseInt(it.off_shelves, 10) === 1, // 已售罄
... ... @@ -149,8 +145,8 @@ const formatCartGoods = (cartGoods, isAdvanceCart, inValid, isOffShelves, analys
// 划线的价格
if (it.last_vip_price < it.sales_price) {
goods.productPrice = it.last_vip_price;
goods.linePrice = it.sales_price; // 划线的价格
goods.productPrice = transPrice(it.last_vip_price);
goods.linePrice = transPrice(it.sales_price); // 划线的价格
}
if (it.min_buy_number) {
... ... @@ -182,16 +178,16 @@ const formatCartGoods = (cartGoods, isAdvanceCart, inValid, isOffShelves, analys
goods.inValid = true;
} else if (it.goods_type === 'gift') { // gift=>是否赠品 && it.isAdvanceBuy
goods.isGift = true;
goods.productPrice = it.last_price;
goods.linePrice = it.sales_price; // 划线的价格
goods.productPrice = transPrice(it.last_price);
goods.linePrice = transPrice(it.sales_price); // 划线的价格
goods.productSubtotal = it.subtotal ? transPrice(it.subtotal) : goods.productPrice;
} else if (it.goods_type === 'price_gift') { // price_gift=>是否加价购
goods.isPriceGift = true;
goods.productPrice = it.last_price;
goods.linePrice = it.sales_price; // 划线的价格
goods.productPrice = transPrice(it.last_price);
goods.linePrice = transPrice(it.sales_price); // 划线的价格
goods.productSubtotal = it.subtotal ? transPrice(it.subtotal) : goods.productPrice;
} else if (it.real_price === 0) { // 免单
goods.productPrice = it.sales_price;
goods.productPrice = transPrice(it.sales_price);
goods.xForOne = true;
// 分析用: 商品ID列表
... ...
... ... @@ -10,6 +10,16 @@ const pager = require('./pager').handlePagerData;
const orderApi = require('./orders-api');
const ChannelConfig = require('./channel-config');
/**
* 转换价格
*
* @param float|string $price 价格
* @return float|string 转换之后的价格
*/
const transPrice = (price) => {
return price ? (price * 1).toFixed(2) : '0.00';
};
const ORDER_TYPE = {
all: 1, // 全部
waitingForPay: 2, // 待付款
... ... @@ -365,28 +375,26 @@ const getOrders = (uid, page, limit, type, isPage)=> {
newOrder.goods = _.get(order, 'order_goods', []).map((good) => {
let newGood = {};
good.real_pay_price = good.real_pay_price && Number(good.real_pay_price).toFixed(2) || '';
good.sales_price = good.sales_price && Number(good.sales_price).toFixed(2) || '';
newGood.href = helpers.getUrlBySkc(good.product_skn);
newGood.thumb = helpers.image(good.goods_image, 100, 100);
newGood.name = good.product_name;
newGood.color = good.factory_color_name;
newGood.size = good.size_name;
newGood.price = good.sales_price;// 默认显示销售价
newGood.price = transPrice(good.sales_price);// 默认显示销售价
newGood.isVipPrice = good.discount_tag === 'V';
newGood.isStuPrice = good.discount_tag === 'S';
// 划线的价格
if (good.real_pay_price < good.sales_price) {
newGood.price = good.real_pay_price;// 显示分摊价
newGood.linePrice = good.sales_price; // 划线的价格
newGood.price = transPrice(good.real_pay_price);// 显示分摊价
newGood.linePrice = transPrice(good.sales_price); // 划线的价格
}
// 赠品、加价购
if (good.goods_type === 'gift' || good.goods_type === 'price_gift') {
newGood.price = good.real_pay_price;// 显示分摊价
newGood.linePrice = good.sales_price; // 划线的价格
newGood.price = transPrice(good.real_pay_price);// 显示分摊价
newGood.linePrice = transPrice(good.sales_price); // 划线的价格
}
let buyNum = _.parseInt(good.buy_number);
... ... @@ -776,16 +784,13 @@ const _getOrderDetail = co(function * (uid, orderId) {
// 商品信息
if (orderDetail.order_goods) {
detail.goods = _.get(orderDetail, 'order_goods', []).map((good) => {
good.real_pay_price = good.real_pay_price && Number(good.real_pay_price).toFixed(2) || '';
good.sales_price = good.sales_price && Number(good.sales_price).toFixed(2) || '';
let newGood = {
url: helpers.getUrlBySkc(good.product_skn),
img: helpers.image(good.goods_image, 60, 60),
name: good.product_name,
color: good.factory_color_name,
size: good.size_name,
price: good.sales_price, // 默认显示销售价
price: transPrice(good.sales_price), // 默认显示销售价
isVipPrice: good.discount_tag === 'V',
isStuPrice: good.discount_tag === 'S',
coin: good.yoho_give_coin,
... ... @@ -797,14 +802,14 @@ const _getOrderDetail = co(function * (uid, orderId) {
// 划线的价格
if (good.real_pay_price < good.sales_price) {
newGood.price = good.real_pay_price;// 显示分摊价
newGood.linePrice = good.sales_price; // 划线的价格
newGood.price = transPrice(good.real_pay_price);// 显示分摊价
newGood.linePrice = transPrice(good.sales_price); // 划线的价格
}
// 赠品、加价购
if (good.goods_type === 'gift' || good.goods_type === 'price_gift') {
newGood.price = good.real_pay_price;// 显示分摊价
newGood.linePrice = good.sales_price; // 划线的价格
newGood.price = transPrice(good.real_pay_price);// 显示分摊价
newGood.linePrice = transPrice(good.sales_price); // 划线的价格
}
return newGood;
... ...
... ... @@ -39,6 +39,16 @@ const getProductUrlBySkc = (skn) => {
return helpers.getUrlBySkc(skn);
};
/**
* 转换价格
*
* @param float|string $price 价格
* @return float|string 转换之后的价格
*/
const transPrice = (price) => {
return price ? (price * 1).toFixed(2) : '0.00';
};
const setDetailGoods = (list) => {
let resData = [];
let goods;
... ... @@ -52,15 +62,15 @@ const setDetailGoods = (list) => {
color: value.color_name,
size: value.size_name,
yoho_coin_cut_num: value.yoho_coin_cut_num,
real_pay_price: value.real_pay_price,
price: value.sales_price,
real_pay_price: transPrice(value.real_pay_price),
price: transPrice(value.sales_price),
goods_type: value.goods_type,
reason: value.reason_name
};
if (value.real_pay_price < value.sales_price) {
goods.price = value.real_pay_price;// 显示分摊价
goods.linePrice = value.sales_price; // 划线的价格
goods.price = transPrice(value.real_pay_price);// 显示分摊价
goods.linePrice = transPrice(value.sales_price); // 划线的价格
}
resData.push(goods);
... ... @@ -202,7 +212,7 @@ const getOrderRefund = (orderCode, uid) => {
color: value.factory_color_name,
size: value.size_name,
lastPrice: value.last_price,
price: value.real_pay_price,
price: transPrice(value.real_pay_price),
skn: value.product_skn,
skc: value.product_skc,
sku: value.product_sku,
... ...