easypay.js
1.5 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
/**
* 立即购买controller
* @author: yyq<yanqing.yang@yoho.cn>
* @date: 2016/9/23
*/
'use strict';
const easypay = require('../models/easypay');
const headerModel = require('../../../doraemon/models/simple-header');
const stepper = [
{ name: '填写订单', focus: true },
{ name: '付款,完成购买' }
];
const index = (req, res, next) => {
let uid = req.user.uid;
let params = req.query;
req.ctx(easypay).getEasypayOrderData(params, uid).then(result => {
let header = headerModel.setSimpleHeaderData() || {};
result.stepper = stepper;
// 限定发售&套餐不支持优惠券
result.notUseCoupon = true;
res.render('order-ensure', {
title: '填写订单 | ' + (res.locals.title || ''),
page: 'ensure',
content: result,
simpleHeader: header,
pageClass: 'order-easypay-page'
});
}).catch(next);
};
const compute = (req, res, next) => {
let uid = req.user.uid;
let params = req.body;
req.ctx(easypay).getOrderComputeData(uid, 'ordinary', params).then(result => {
res.json(result);
}).catch(next);
};
const submit = (req, res, next) => {
let remoteIp = req.ip;
let uid = req.user.uid;
let params = req.body;
if (!uid) {
return next();
}
req.ctx(easypay).easypayOrderSubmit(uid, 'ordinary', params, remoteIp).then(result => {
res.json(result);
}).catch(next);
};
module.exports = {
index,
compute,
submit
};