...
|
...
|
@@ -24,11 +24,13 @@ const payCenter = (req, res, next) => { |
|
|
let uid = req.user.uid;
|
|
|
let sessionKey = req.session.TOKEN;
|
|
|
|
|
|
if (!orderCode || !uid || !sessionKey) {
|
|
|
if (!orderCode || !uid) {
|
|
|
res.redirect('/');
|
|
|
}
|
|
|
|
|
|
if (sessionKey) {
|
|
|
sessionKey = sessionKey.substr(0, sessionKey.length - 8);
|
|
|
}
|
|
|
|
|
|
let headerData = headerModel.setNav({
|
|
|
navTitle: '支付中心'
|
...
|
...
|
@@ -59,12 +61,12 @@ const payCenter = (req, res, next) => { |
|
|
* @param req
|
|
|
* @param res
|
|
|
*/
|
|
|
const goAlipay = (req, res) => {
|
|
|
const goAlipay = (req, res, next) => {
|
|
|
let orderCode = req.query.order_code;
|
|
|
let user = req.user;
|
|
|
let uid = req.user.uid;
|
|
|
let sessionKey = req.session.TOKEN;
|
|
|
let paymentType = req.query.payment_type;
|
|
|
let payment = req.query.payment;
|
|
|
|
|
|
if (!orderCode || !uid || !sessionKey) {
|
|
|
res.redirect('/');
|
...
|
...
|
@@ -77,14 +79,14 @@ const goAlipay = (req, res) => { |
|
|
sessionKey: sessionKey
|
|
|
});
|
|
|
|
|
|
if (!orderDetail) {
|
|
|
if (!orderDetail || !orderDetail.data) {
|
|
|
return res.json({
|
|
|
code: 400,
|
|
|
msg: '没有找到该订单!'
|
|
|
});
|
|
|
}
|
|
|
|
|
|
if (orderDetail.is_cancel === 'Y') {
|
|
|
if (orderDetail.data.is_cancel === 'Y') {
|
|
|
let url = helpers.urlFormat('/home/orders/detail', { order_code: orderCode });
|
|
|
|
|
|
return res.json({
|
...
|
...
|
@@ -93,36 +95,13 @@ const goAlipay = (req, res) => { |
|
|
}).redirect(url);
|
|
|
}
|
|
|
|
|
|
/* TODO 要不搞点儿日志? */
|
|
|
yield payModel.savePrePayInfo({
|
|
|
uid: uid,
|
|
|
orderCode: orderCode,
|
|
|
payment: paymentType
|
|
|
});
|
|
|
|
|
|
let payRequestPars = Payment.pay(user, orderDetail, paymentType, req.protocol);
|
|
|
|
|
|
if (!payRequestPars) {
|
|
|
return res.json({
|
|
|
code: 400,
|
|
|
msg: '支付系统繁忙,请稍后再试'
|
|
|
});
|
|
|
}
|
|
|
|
|
|
let paymentRecod = yield payModel.updateOrderPayment({
|
|
|
orderCode: orderCode,
|
|
|
payment: paymentType,
|
|
|
uid: uid
|
|
|
});
|
|
|
|
|
|
if (!paymentRecod) {
|
|
|
return res.json({
|
|
|
code: 400,
|
|
|
msg: '系统繁忙,请稍后再试'
|
|
|
});
|
|
|
Payment.pay(user, orderDetail.data, payment, req.protocol).then(result => {
|
|
|
if (result && result.data && result.data.href) {
|
|
|
res.redirect(result.data.href);
|
|
|
} else {
|
|
|
res.redirect('/');
|
|
|
}
|
|
|
|
|
|
return res.redirect(payRequestPars.pay_url + payRequestPars.pars);
|
|
|
}).catch(next);
|
|
|
})();
|
|
|
};
|
|
|
|
...
|
...
|
|