Authored by jinhu.tung

display sold out goods

... ... @@ -15,7 +15,6 @@ exports.index = (req, res, next) => {
const uid = req.user.uid || null;
cartModel.getCartData(shoppingKey, uid).then((result) => {
console.log(JSON.stringify(result, '', 4));
if (result.code === 200) {
res.display('cart', _.merge({
module: 'shopping',
... ...
... ... @@ -229,8 +229,10 @@ const filterCartData = (result, uid) => {
let invalidGoods = [];
// 库存不足商品
// 售罄商品当作失效商品处理
let soldOutGoods = [];
// 售罄商品当作一般商品处理
// sold_out_goods_list
let advancedSoldOutGoods = [];
let ordinarySoldOutGoods = [];
// 商品总数量
let buyNumber;
... ... @@ -249,7 +251,7 @@ const filterCartData = (result, uid) => {
totalAdvanceMoney = advancedCartData.shopping_cart_data.last_order_amount;
advancedGoods = _.concat(advancedGoods, advancedCartData.goods_list);
invalidGoods = _.concat(invalidGoods, advancedCartData.off_shelves_goods_list);
soldOutGoods = _.concat(soldOutGoods, advancedCartData.sold_out_goods_list);
advancedSoldOutGoods = _.concat(advancedSoldOutGoods, advancedCartData.sold_out_goods_list);
_.forEach(advancedGoods, function(good) {
buyNumber = parseInt(good.buy_number, 10);
... ... @@ -273,7 +275,7 @@ const filterCartData = (result, uid) => {
totalOrdinaryMoney = ordinaryCartData.shopping_cart_data.last_order_amount;
ordinaryGoods = _.concat(ordinaryGoods, ordinaryCartData.goods_list);
invalidGoods = _.concat(invalidGoods, ordinaryCartData.off_shelves_goods_list);
soldOutGoods = _.concat(soldOutGoods, ordinaryCartData.sold_out_goods_list);
ordinarySoldOutGoods = _.concat(ordinarySoldOutGoods, ordinaryCartData.sold_out_goods_list);
_.forEach(ordinaryGoods, function(good) {
buyNumber = parseInt(good.buy_number, 10);
... ... @@ -294,9 +296,11 @@ const filterCartData = (result, uid) => {
return _.merge(resData, {
hasGoods: advancedGoods.length || ordinaryGoods.length || invalidGoods.length,
preSalePros: advancedGoods.length ? _.groupBy(advancedGoods, 'brand_id') : [],
commonPros: ordinaryGoods.length ? _.groupBy(ordinaryGoods, 'brand_id') : [],
invalidPros: _.concat(invalidGoods, soldOutGoods),
preSalePros: (advancedSoldOutGoods.length || advancedGoods.length) ?
_.groupBy(_.concat(advancedGoods, advancedSoldOutGoods), 'brand_id') : [],
commonPros: (ordinarySoldOutGoods.length || ordinaryGoods.length) ?
_.groupBy(_.concat(ordinaryGoods, ordinarySoldOutGoods), 'brand_id') : [],
invalidPros: invalidGoods,
selectedNum: selectedAdvanceNum + selectedOrdinaryNum,
checkAll: totalNum === (selectedAdvanceNum + selectedOrdinaryNum),
totalMoney: totalAdvanceMoney + totalOrdinaryMoney,
... ...