im.js 762 Bytes
'use strict';

const _ = require('lodash');

/**
 *  im 接口数据的 处理
 */

/**
 *  function: 处理 订单返回的数据
 */
exports.handleOrderList = data => {
    if (_.isEmpty(data)) {
        return;
    }

    data.forEach(order => {
        order.goods = order.ordersGoodsBoList.map(good => {
            return {
                id: good.productSku,
                name: good.productName,
                thumb: good.imgUrl,
                color: good.colorName,
                size: good.sizeName,
                count: good.buyNumber,
                price: good.lastPrice
            };
        });
        order.count = order.ordersGoodsBoList.reduce((sum, good) => {
            return sum + good.buyNumber;
        }, 0);
    });
};