refund.js 1.28 KB
/**
 * 退换货
 * @type {Object}
 */
'use strict';
const refundModel = require('../models/refund');

const refund = {
    refund(req, res) {
        res.render('refund');
    },
    order(req, res, next) {
        const uid = req.user.uid || 8050882;
        const orderId = req.query.orderId;

        if (!orderId) {
            return next();
        }

        refundModel.getOrderData(uid, orderId).then(result => {
            res.json(result);
        }).catch(next);
    },
    submit(req, res, next) {
        const uid = req.user.uid || 8050882;

        refundModel.submitRefundData(uid, req.body).then(result => {
            res.json(result);
        }).catch(next);
    },
    logistics(req, res, next) {
        refundModel.getExpressCompany().then(result => {
            res.render('logistics', {
                module: 'home',
                page: 'logistics',
                company_list: result ? JSON.stringify(result.data) : ''
            });
        }).catch(next);
    },
    saveLogistics(req, res) {
        // todo 调用保存物流信息接口
        // const companyId = req.body.company_id;
        // const companyName = req.body.company_name;
        // const num = req.body.num;
        res.json({
            code: 200
        });
    }
};

module.exports = refund;