orderDetail.js 1.69 KB
/**
 * 个人中心 controller
 * @author: chengyao.guo<chengyao.guo@yoho.cn>
 * @date: 2016/08/10
 */

'use strict';

const headerModel = require('../../../doraemon/models/header'); // 头部model
const orderDetailModel = require('../models/orderDetail');

const orderDetailData = (req, res, next) => {
    let uid = req.user.uid || 8039759;
    let orderCode = req.query.order_code || 1618346759;

    orderDetailModel.orderDetailData(uid, orderCode).then(result => {

        res.render('orderDetail', {
            module: 'home',
            page: 'order-detail',
            pageHeader: headerModel.setNav({
                navTitle: '订单详情'
            }),
            title: '订单详情',
            pageFooter: true,
            orderDetail: result
        });
    }).catch(next);

};

// 删除订单
const delOrder = (req, res, next) => {
    let orderCode = req.query.order_code || 1612441404;
    let uid = req.user.uid || 8039759;

    orderDetailModel.delOrder(orderCode, uid).then((result) => {
        res.json(result);
    }).catch(next);
};

// 再次购买
const readdData = (req, res, next) => {
    let orderCode = req.query.order_code || 1606343171;
    let uid = req.user.uid || 8039759;

    orderDetailModel.readdData(orderCode, uid).then((result) => {
        res.json(result);
    }).catch(next);
};

// 取消订单
const cancelOrder = (req, res, next) => {
    let orderCode = req.query.order_code || 1606343171;
    let uid = req.user.uid || 8039759;
    let reasonId = 1;

    orderDetailModel.cancelOrder(orderCode, uid, reasonId).then((result) => {
        res.json(result);
    }).catch(next);
};

module.exports = {
    orderDetailData,
    delOrder,
    readdData,
    cancelOrder
};