Authored by 郝肖肖

校验订单号是否合法

... ... @@ -13,7 +13,7 @@ const cleanHtml = require(`${global.utils}/cleanHtml`);
const camelCase = global.yoho.camelCase;
const helpers = global.yoho.helpers;
const _ = require('lodash');
const integerTest = /^[0-9]*$/;
/**
* 支付页
... ... @@ -25,12 +25,22 @@ const online = (req, res, next) => {
let orderCode = req.query.code;
let uid = req.user.uid;
if (!integerTest.test(orderCode)) {
//不合法订单号
return next();
}
PayData.getPayInfo(uid, orderCode).then(result => {
let order = result.order;
let promotion = order.promotionFormulas;
let coin = 0;
let amount = _.toNumber(order.paymentAmount);
if (!order.orderCode) {
//不合法订单号
return next();
}
_.forEach(promotion, p => {
if (p.promotion === 'YOHO币') {
coin = parseInt(parseFloat(p.promotionAmount.substring(2, p.promotionAmount.length)) * 100, 10);
... ... @@ -80,6 +90,11 @@ const toPay = (req, res, next) => {
let uid = req.user.uid;
let user = req.user;
if (!integerTest.test(orderCode)) {
//不合法订单号
return next();
}
method = parseInt(method, 10);
OrderData.orderDetail(uid, orderCode).then(result => {
... ... @@ -109,6 +124,11 @@ const weixinQr = (req, res, next) => {
let url = req.query.url;
let uid = req.user.uid;
if (!integerTest.test(code)) {
//不合法订单号
return next();
}
OrderData.orderDetail(uid, code).then(result => {
if (result && result.data) {
return camelCase(result.data);
... ...
... ... @@ -8,12 +8,14 @@
const api = global.yoho.API;
//获取支付宝等平台支付方式列表
const getPayProvider = () => {
return api.get('', {
method: 'web.SpaceOrders.getPaymentList'
});
};
//获取单个支付方式相关详细信息
const getPaymentInfo = (id) => {
return api.get('', {
method: 'web.SpaceOrders.getPaymentById',
... ... @@ -21,6 +23,7 @@ const getPaymentInfo = (id) => {
});
};
/*获取上次使用的支付方式*/
const getBankByOrder = (code) => {
return api.get('', {
method: 'web.SpaceOrders.getOrderPayBank',
... ... @@ -28,6 +31,7 @@ const getBankByOrder = (code) => {
});
};
/*记录支付方式*/
const setOrderPayBank = (code, payment, bankCode) => {
return api.get('', {
method: 'web.SpaceOrders.addOrderPayBank',
... ... @@ -37,6 +41,7 @@ const setOrderPayBank = (code, payment, bankCode) => {
});
};
/*更改支付方式*/
const updateOrderPayBank = (code, payment, bankCode) => {
return api.get('', {
method: 'web.SpaceOrders.modifyOrderPayBank',
... ... @@ -46,6 +51,7 @@ const updateOrderPayBank = (code, payment, bankCode) => {
});
};
/*发送支付确认*/
const sendPayConfirm = (code, payment, uid) => {
return api.get('', {
method: 'app.SpaceOrders.payConfirm',
... ... @@ -55,6 +61,7 @@ const sendPayConfirm = (code, payment, uid) => {
});
};
/*选择支付,校验时间间隔,插入数据,为用户取消订单做准备<用户支付取消订单,10分钟间隔>。*/
const savePrePayInfo = (code, payment, uid) => {
return api.get('', {
method: 'app.order.savePrePayInfo',
... ...
... ... @@ -7,7 +7,7 @@ var $ = require('yoho-jquery');
var $orderDetail = $('.order-detail'),
$orderDetailCtrl = $('#order-detail-ctrl');
var Dialog = require('../plugins/dialog').Dialog;
var Dialog = require('../plugins/dialog');
var tpl = '<div class="pay-page-tips">' +
'<h3>请您在新打开的页面完成付款</h3>' +
... ... @@ -18,7 +18,7 @@ var tpl = '<div class="pay-page-tips">' +
'</div>' +
'</div>';
var infoDaialog = new Dialog({
var infoDaialog = new Dialog.Dialog({
className: 'pay-info-dialog',
content: tpl,
keep: true
... ... @@ -78,8 +78,9 @@ $('#go-pay-btn').click(function() {
}).then(function(data) {
if (data.code === 200) {
window.open(data.data.href);
showDialog();
} else {
new Dialog.Alert(data.message).show();
}
});
});
... ...