exchange.js
2.46 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
/*
* 换货 controller
*/
'use strict';
const headerModel = require('../../../doraemon/models/header'); // 头部model
const exchangeModel = require('../models/exchange');
const camelCase = global.yoho.camelCase;
const exchange = {
exchange(req, res) {
res.render('refund/exchange', {
module: 'home',
page: 'refund-exchange',
pageHeader: headerModel.setNav({
navTitle: '换货申请',
suggestSub: {
text: '提交'
},
navBtn: false
}),
title: '换货申请',
localCss: true
});
},
// 订单 可换货商品列表
order(req, res, next) {
const uid = req.user.uid; // const udi = 8039837 //test account
const orderCode = req.query.orderCode;
if (!orderCode) {
return next();
}
exchangeModel.getOrderData(uid, orderCode).then(result => {
if (result && result.data) {
result.data.address = camelCase(result.data.address);
}
res.json(result);
}).catch(next);
},
delivery(req, res, next) {
const uid = req.user.uid;
const areaCode = req.query.areaCode;
if (!areaCode) {
return next();
}
exchangeModel.getDelivery(uid, areaCode).then(result => {
res.json(result);
}).catch(next);
},
// 提交 换货
submit(req, res, next) {
const uid = req.user.uid;
exchangeModel.submitExchange(uid, req.body).then(result => {
res.json(result);
}).catch(next);
},
/**
* 取消换货申请
* @param req
* @param res
* @param next
*/
cancelApply(req, res, next) {
const id = req.body.id;
const uid = req.user.uid;
exchangeModel.cancelApply(uid, id).then(result => {
return res.json(result);
}).catch(next);
},
// 商品是否支持上门换货
refreshDelivery(req, res, next) {
const uid = req.user.uid;
const areaCode = req.query.areaCode;
const skns = req.query.skns;
const orderCode = req.query.orderCode;
if (!areaCode || !skns || !orderCode) {
return next();
}
exchangeModel.getrefreshDelivery(uid, areaCode, skns, orderCode).then(result => {
res.json(result);
}).catch(next);
},
};
module.exports = exchange;