refund.js
3.85 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/**
* 退换货
* @type {Object}
*/
'use strict';
const refundModel = require('../models/refund');
const notLoginCode = 400;
const notLoginTip = '抱歉,您暂未登录!';
const testUid = 8039837; // 测试uid
const isBLK = 1;
const refund = {
refund(req, res) {
res.render('refund');
},
order(req, res, next) {
const uid = req.user.uid || 8050882;
const orderCode = req.query.orderCode;
if (!orderCode) {
return next();
}
refundModel.getOrderData(uid, orderCode).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) {
const applyid = req.query.applyid;
refundModel.getExpressCompany().then(result => {
res.render('logistics', {
module: 'me',
page: 'logistics',
applyid: applyid,
company_list: result ? JSON.stringify(result.data) : ''
});
}).catch(next);
},
saveLogistics(req, res, next) {
const uid = req.user.uid;
const applyid = req.body.applyid;
const expressCompany = req.body.expressCompany;
const expressId = req.body.expressId;
const expressNumber = req.body.expressNumber;
refundModel.setexpress(applyid, uid, expressCompany, expressId, expressNumber).then(data => {
return res.json(data);
}).catch(next);
},
refundStatus(req, res) {
const applyId = req.params.applyId;
res.render('status', {
module: 'me',
page: 'status',
applyId: applyId,
type: 'refund'
});
},
exchangeStatus(req, res) {
const applyId = req.params.applyId;
res.render('status', {
module: 'me',
page: 'status',
applyId: applyId,
type: 'exchange'
});
},
statusDetail(req, res, next) {
const uid = req.user.uid;
const applyid = req.query.applyid;
const type = req.query.type;
if (type === 'refund') {
refundModel.getRefundDetail(applyid, uid).then(result => {
return res.json(result);
}).catch(next);
} else {
refundModel.getChangeDetail(applyid, uid).then(result => {
return res.json(result);
}).catch(next);
}
},
refundOrders(req, res) {
res.render('refund-order', {
module: 'me',
page: 'return'
});
},
/**
* 获取退换货订单
* @param req
* @param res
* @returns {*|{read, write}}
*/
getRefundOrders(req, res) {
let uid = req.query.id;
let page = req.query.page;
let limit = req.query.limit;
uid = testUid;
if (!uid && req.xhr) {
return res.json({
code: notLoginCode,
message: notLoginTip
});
}
let param = {
uid: uid,
page: page,
limit: limit,
app_type: isBLK
};
refundModel.getRefundOrders(param).then(result => {
return res.json(result);
});
},
/**
* 取消申请
* @param req
* @param res
*/
cancelApply(req, res) {
let uid = req.user.uid;
let id = req.body.id;
uid = testUid;
if (!uid && req.xhr) {
return res.json({
code: notLoginCode,
message: notLoginTip
});
}
refundModel.cancelRefundApply(uid, id).then(result => {
return res.json(result);
});
}
};
module.exports = refund;