orderDetail.js
1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/**
* 个人中心 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;
let orderCode = req.query.order_code;
orderDetailModel.orderDetailData(uid, orderCode).then(result => {
res.render('orderDetail', {
module: 'home',
page: 'order-detail',
pageHeader: headerModel.setNav({
navTitle: '订单详情',
navBtn: false,
orderDetail: true,
serviceUrl: 'http://chat8.live800.com/live800/chatClient/chatbox.jsp?companyID=620092&configID=149091&jid=8732423409&info=',
}),
title: '订单详情',
pageFooter: true,
orderDetail: result
});
}).catch(next);
};
// 删除订单
const delOrder = (req, res, next) => {
let orderCode = req.query.id;
let uid = req.user.uid;
orderDetailModel.delOrder(orderCode, uid).then((result) => {
res.json(result);
}).catch(next);
};
// 再次购买
const readdData = (req, res, next) => {
let orderCode = req.query.orderCode;
let uid = req.user.uid;
orderDetailModel.readdData(orderCode, uid).then((result) => {
res.json(result);
}).catch(next);
};
// 取消订单
const cancelOrder = (req, res, next) => {
let orderCode = req.query.id;
let uid = req.user.uid;
let reasonId = req.query.reasonId || 1;
let gender = req.query.gender || '1,3';
let channel = req.query.channel || 1;
let reason = req.query.reason;
orderDetailModel.cancelOrder(orderCode, uid, reasonId, gender, channel, reason).then((result) => {
res.json(result);
}).catch(next);
};
module.exports = {
orderDetailData,
delOrder,
readdData,
cancelOrder
};