returns.js
1.87 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
/**
* 退换货controller
* @author: yyq<yanqing.yang@yoho.cn>
* @date: 2016/7/18
*/
'use strict';
const mcHandler = require('../models/menu-crumb-handler');
const returns = require('../models/returns');
const _ = require('lodash');
const index = (req, res, next) => {
const uid = global.yoho.uid || '8050560';
const page = req.query.page;
returns.getUserReturn(uid, page).then(result => {
res.display('index', {
page: 'return-list',
isMe: true,
content: Object.assign({
nav: mcHandler.getMeCrumb('我的退/换货'),
navigation: mcHandler.getSideMenu('我的退/换货'),
banner: 'http://placehold.it/{width}x{height}'
}, result)
});
}).catch(next);
};
const detail = (req, res, next) => {
next();
};
const refund = (req, res, next) => {
let code = parseInt(req.params.orderCode, 10);
req.user.uid = '8050560';
code = '160192757';
if (!req.user.uid || !code) {
return next();
}
returns.getRefundGoodsData(code, req.user.uid).then(result => {
res.display('index', {
page: 'returns-refund',
content: result
});
}).catch(next);
};
const refundApply = (req, res, next) => {
let orderCode = req.body.orderCode,
uid = req.user.uid,
goods = req.body.goods,
payment = req.body.payment;
uid = '8050560';
orderCode = '160192757';
if (!orderCode || _.isEmpty(goods) || _.isEmpty(payment)) {
return res.json({
code: 203,
message: '非法提交'
});
}
returns.saveRefund(orderCode, uid, goods, payment).then(result => {
res.json(result);
}).catch(next);
};
const exchange = (req, res, next) => {
next();
};
module.exports = {
index,
detail,
refund,
refundApply,
exchange
};