Authored by 郝肖肖

支付 判断订单 是否到期

... ... @@ -207,7 +207,17 @@ const callback = (req, res, next) => {
});
}
}).catch(next);
};
// 支付确认
const sendPayConfirm = (req, res, next) => {
let code = req.body.code;
let payment = req.body.payment;
let uid = req.user.uid;
PayData.sendPayConfirm(code, payment, uid).then(result => {
res.json(result);
}).catch(next);
};
... ... @@ -216,5 +226,6 @@ module.exports = {
callback,
toPay,
weixinQr,
weixinPayState
weixinPayState,
sendPayConfirm
};
... ...
... ... @@ -18,7 +18,7 @@ const common = {
if (diff > 0) {
return Math.floor(diff / 1000 / 60);
} else {
return defaultValue;
return 0;
}
} else {
... ...
... ... @@ -13,6 +13,7 @@ const Alipay = require('./pay/alipay');
const Alibank = require('./pay/alibank');
const Wechat = require('./pay/wechat');
const Promise = require('bluebird');
const common = require('./pay/common');
const co = Promise.coroutine;
const logger = global.yoho.logger;
... ... @@ -31,6 +32,21 @@ const Payment = {
return result;
}
if (!order.orderCode) {
result.message = '没有找到该订单';
return result;
}
if (order.isCancel && order.isCancel === 'Y') {
result.message = '该订单已经取消';
return result;
}
if (order.payExpire && common.getPayExpireMin(order.payExpire) <= 0) {
result.message = '当前订单不可支付';// 该订单已超过2个小时
return result;
}
let method = paymentPars[0] * 1;
if (method === PayData.payments.wechat) {
... ...
... ... @@ -12,7 +12,7 @@ const api = global.yoho.API;
const getPayProvider = () => {
return api.get('', {
method: 'web.SpaceOrders.getPaymentList'
});
}, { cache: true });
};
// 获取单个支付方式相关详细信息
... ... @@ -20,7 +20,7 @@ const getPaymentInfo = (id) => {
return api.get('', {
method: 'web.SpaceOrders.getPaymentById',
id: id
});
}, { cache: true });
};
/* 获取上次使用的支付方式*/
... ...
... ... @@ -35,6 +35,7 @@ router.get('/pay/online', auth, pay.online);
router.get('/pay/online/weixin', auth, pay.weixinQr);
router.get('/pay/online/weixin/state', auth, pay.weixinPayState);
router.post('/pay/online/go', auth, pay.toPay);
router.post('/pay/online/sendPayConfirm', auth, pay.sendPayConfirm);
// 支付回调
router.get('/pay/callback/:type', auth, pay.callback);
... ...
... ... @@ -19,7 +19,7 @@ var tpl = '<div class="pay-page-tips">' +
'<h3>请您在新打开的页面完成付款</h3>' +
'<p>付款完成前请不要关闭此窗口</p>' +
'<p>完成付款后请根据您的情况点击下面的按钮</p>' +
'<div><a href="/me/order"><span class="btn">已完成付款</span></a>' +
'<div><a href="javascript:void(0);" class="pay-over"><span class="btn">已完成付款</span></a>' +
'<span class="btn white close-btn">更换支付方式</span>' +
'</div>' +
'</div>';
... ... @@ -104,3 +104,20 @@ $goPayBtn.click(function() {
}
});
});
// 发送支付确认
$('.pay-info-dialog').on('click', '.pay-over', function() {
var payment = $('.pay-type-icon.active').data('id');
var order = $goPayBtn.data('order');
$.ajax({
type: 'POST',
url: '/shopping/pay/online/sendPayConfirm',
data: {
code: order,
payment: payment
}
}).then(function() {
location.href = '/me/order';
});
});
... ...