Blame view

apps/home/controllers/orderDetail.js 1.91 KB
lijing authored
1 2 3 4 5 6 7 8 9 10 11
/**
 * 个人中心 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');
zhangxiaoru authored
12
const orderDetailData = (req, res, next) => {
zhangxiaoru authored
13 14
    let uid = req.user.uid;
    let orderCode = req.query.order_code;
zhangxiaoru authored
15
zhangxiaoru authored
16
    orderDetailModel.orderDetailData(uid, orderCode).then(result => {
17
        result.serviceUrl = 'http://chat8.live800.com/live800/chatClient/chatbox.jsp?companyID=620092&configID=149091&jid=8732423409&info=';
zhangxiaoru authored
18 19 20 21
        res.render('orderDetail', {
            module: 'home',
            page: 'order-detail',
            pageHeader: headerModel.setNav({
zzzzzzz authored
22
                navTitle: '订单详情',
23
                navBtn: false
zhangxiaoru authored
24 25 26 27 28
            }),
            title: '订单详情',
            pageFooter: true,
            orderDetail: result
        });
lijing authored
29 30 31
    }).catch(next);

};
lijing authored
32
zhangxiaoru authored
33
// 删除订单
zhangxiaoru authored
34
const delOrder = (req, res, next) => {
zzzzzzz authored
35
    let orderCode = req.query.id;
zhangxiaoru authored
36
    let uid = req.user.uid;
zhangxiaoru authored
37 38 39 40

    orderDetailModel.delOrder(orderCode, uid).then((result) => {
        res.json(result);
    }).catch(next);
zhangxiaoru authored
41
};
zhangxiaoru authored
42
zhangxiaoru authored
43
// 再次购买
zhangxiaoru authored
44
const readdData = (req, res, next) => {
zhangxiaoru authored
45
    let orderCode = req.query.orderCode;
zhangxiaoru authored
46
    let uid = req.user.uid;
zhangxiaoru authored
47 48 49 50

    orderDetailModel.readdData(orderCode, uid).then((result) => {
        res.json(result);
    }).catch(next);
zhangxiaoru authored
51
};
zhangxiaoru authored
52
zhangxiaoru authored
53
// 取消订单
zhangxiaoru authored
54
const cancelOrder = (req, res, next) => {
zhangxiaoru authored
55
    let orderCode = req.query.id;
zhangxiaoru authored
56
    let uid = req.user.uid;
zhangxiaoru authored
57 58 59 60
    let reasonId = req.query.reasonId || 1;
    let gender = req.query.gender || '1,3';
    let channel = req.query.channel || 1;
    let reason = req.query.reason;
zhangxiaoru authored
61
zhangxiaoru authored
62
    orderDetailModel.cancelOrder(orderCode, uid, reasonId, gender, channel, reason).then((result) => {
zhangxiaoru authored
63 64
        res.json(result);
    }).catch(next);
zhangxiaoru authored
65
};
zhangxiaoru authored
66
lijing authored
67
module.exports = {
zhangxiaoru authored
68
    orderDetailData,
zhangxiaoru authored
69 70 71
    delOrder,
    readdData,
    cancelOrder
lijing authored
72
};