orderDetail.js 2.06 KB
'use strict';


const api = global.yoho.API;
const _ = require('lodash');

const orderDetail = (params) => {
    let finalResult = {};

    return api.get('', _.assign({
        method: 'app.SpaceOrders.detail'
    }, params), {code: 200}).then((result) => {
        if (params.order_code && params.uid && params.sessionKey) {
                if (result.data) {
                    Object.assign(finalResult, {
                        virtual_type: result.data.virtual_type,
                        phoneNum: result.data.mobile,
                        orderStatus: result.data.status_str,
                        orderNum: result.data.order_code,
                        orderTime: result.data.create_time,
                        isPay: result.data.payment_status === 'Y',
                        relation: result.data.relate_order_code === 'Y' ? 'true' : 'false',
                        name: result.data.user_name,

                        isVirtual: false,
                        mobile: '15999999999',
                        address: result.data.address,
                        logisticsUrl: '#',
                        logisticsCompany: '顺丰',
                        logisticsNum: '111111',
                        yohoCoin: result.data.yoho_give_coin,

                        invoice: [{
                            title: '有货',
                            contentValue: '有货',
                            pdfUrl: '#'
                        }, {
                            title: '有货',
                            contentValue: '有货',
                            pdfUrl: '#'
                        }],
                        orderBalance: [{
                            promotion: '商品总金额',
                            account: '100.00'
                        }, {
                            promotion: '运费',
                            account: '10.00'
                        }],
                        price: result.data.amount
                    });
                }
        }

        return finalResult;
    });
};

module.exports = {
    orderDetail
};