installment.js
4.01 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
/**
* 分期付款
* @author: wsl<shuiling.wang@yoho.cn>
* @date: 2016/08/01
*/
'use strict';
const headerModel = require('../../../doraemon/models/header');
const installmentModel = require('../models/installment');
const _ = require('lodash');
const helpers = global.yoho.helpers;
const index = (req, res) => {
let query = req.query.query || '';
let uid = req.user.uid || 3236556;
Promise.all([installmentModel.getStauts(uid), installmentModel.getSearchIntallment()]).then((result) => {
let openStatus = result[0];
if (openStatus === 0) {
return {
bannerTop: {
data: [
{
url: '',
src: '//img11.static.yhbimg.com/yhb-img01/2016/07/29/11/0112d076e4fa0c53635ed93b118ee3f74e.jpg?imageView2/2/w/640/h/240/q/70' // eslint-disable-line
}
]
},
notOpen: true,
installmentOnly: {
title: '分期专享',
goods: result[1]
}
};
} else if (openStatus === 2) {
if (query === 'usable') {
return installmentModel.getQueryCreditInfo(uid).then((data) => {
if (data.status === 2) {
data.replayStatus = '逾期';
} else if (data.status === 3) {
data.replayStatus = '不可用';
}
return _.assign({
isUnable: true,
installmentOnly: {
title: '分期专享',
goods: result[1]
}
}, data);
});
} else {
return installmentModel.getQueryAmtInfo(uid).then((data) => {
return _.assign({
isRepay: true
}, data);
});
}
}
}).then((result) => {
result.pageHeader = _.assign({
installmentPage: true
}, headerModel.setNav({
navTitle: '有货分期',
navBtn: false
}));
res.render('installment/open-index', _.assign({
module: 'home',
page: 'installment',
title: '有货分期'
}, result));
});
};
const review = (req, res) => {
let uid = req.user.uid || 20000032;
let params = {};
installmentModel.getStauts(uid).then((status) => {
if (status === 1) {
return {
review: {
url: helpers.urlFormat('//m.yohobuy.com/product/new')
}
};
} else if (status === 2) {
return installmentModel.getSearchIntallment().then((goods) => {
return {
success: {
price: '5000',
installmentOnly: {
title: '分期专享',
goods: goods
}
}
};
});
} else if (status === 3) {
return {
error: {
url: helpers.urlFormat('//m.yohobuy.com/product/new')
}
};
}
}).then((params) => {
res.render('installment/open-result', _.assign({
module: 'home',
page: 'installment',
title: '有货分期',
pageHeader: headerModel.setNav({
navTitle: '有货分期',
navBtn: false
})
}, params));
});
};
const startingService = (req, res, next) => {
res.render('installment/starting-service', {
module: 'home',
page: 'installment.starting-service',
navTitle: '开通有货分期',
navBtn: false
});
console.log(next);
};
module.exports = {
index,
review,
startingService
};