BuyNowController.js
3.06 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
/*
* @Author: Targaryen
* @Date: 2017-06-21 10:15:38
* @Last Modified by: Targaryen
* @Last Modified time: 2017-06-21 16:20:42
*/
const co = require('bluebird').coroutine;
const headerModel = require('../../../doraemon/models/header');
const BuyNowModel = require('../models/BuyNowModel');
const utils = '../../../utils';
const paymentProcess = require(`${utils}/payment-process`);
class BuyNowController {
/**
* 确认订单页面
* @param {*} req
* @param {*} res
* @param {*} next
*/
orderEnsure(req, res, next) {
co(function * () {
let result = yield req.ctx(BuyNowModel).payment({
uid: req.user.uid,
product_sku: req.query.product_sku || '2026740'
});
let headerData = headerModel.setNav({
navTitle: '确认订单',
navBtn: false
});
return res.render('order-ensure', {
pageHeader: headerData,
module: 'buynow',
page: 'order-ensure',
title: '确认订单',
orderEnsure: paymentProcess.tranformPayment(result.data)
});
})().catch(next);
}
/**
* 参数更改,重新运算结算数据
* @param {*} req
* @param {*} res
* @param {*} next
*/
orderCompute(req, res, next) {
co(function * () {
let result = yield req.ctx(BuyNowModel).compute({
uid: req.user.uid,
cart_type: req.body.cart_type,
delivery_way: req.body.delivery_way,
payment_type: req.body.payment_type,
product_sku_list: req.body.product_sku_list,
coupon_code: req.body.coupon_code,
use_yoho_coin: req.body.use_yoho_coin,
});
return res.json(result);
})().catch(next);
}
/**
* 提交订单
* @param {*} req
* @param {*} res
* @param {*} next
*/
orderSub(req, res, next) {
let qhy_union = ''; // TODO
co(function * () {
let result = yield req.ctx(BuyNowModel).submit({
uid: req.user.uid,
cart_type: req.body.cart_type,
address_id: req.body.address_id,
delivery_time: req.body.delivery_time,
delivery_way: req.body.delivery_way,
use_yoho_coin: req.body.use_yoho_coin,
use_red_envelopes: req.body.use_red_envelopes,
payment_id: req.body.payment_id,
payment_type: req.body.payment_type,
product_sku_list: req.body.product_sku_list,
is_print_price: req.body.is_print_price,
qhy_union: qhy_union,
invoices_title: req.body.invoices_title,
invoices_type_id: req.body.invoices_type_id,
remark: req.body.remark,
activity_id: req.body.activity_id
});
return res.json(result);
})().catch(next);
}
}
module.exports = new BuyNowController();