Authored by 周少峰

Merge branch 'hotfix/submit'

... ... @@ -66,10 +66,10 @@ const submit = (req, res, next) => {
let uid = req.user.uid;
let remoteIp = req.ip;
if (!req.body.addressId) {
if (!req.body.addressId || !req.body.paymentType || !req.body.deliveryWay) {
res.send({
code: 500,
message: '配送地址不能为空'
message: '订单参数不完整'
});
return;
}
... ...
... ... @@ -6,7 +6,7 @@
'use strict';
const _ = require('lodash');
const pinyin = require('pinyin');
const pinyin = require('pinyin-converter');
const crypto = global.yoho.crypto;
... ...
... ... @@ -29,7 +29,7 @@ module.exports = (limiter, policy) => {
const key = `pc:limiter:${limiter.remoteIp}`;
let isNew = false;
let isNew = true;
res.on('render', function() {
let route = req.route ? req.route.path : '';
... ... @@ -53,9 +53,8 @@ module.exports = (limiter, policy) => {
return cache.getAsync(key).then((result) => {
logger.debug('qps limiter: ' + key + '@' + result + ' max: ' + MAX_QPS);
if (result && _.isNumber(result)) {
isNew = false;
if (result === -1) {
return Promise.resolve(true);
}
... ... @@ -72,7 +71,6 @@ module.exports = (limiter, policy) => {
}
} else {
cache.setAsync(key, 1, 60); // 设置key,1m失效
isNew = true;
return Promise.resolve(true);
}
});
... ...
{
"name": "yohobuy-node",
"version": "5.4.13",
"version": "5.4.14",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ... @@ -56,7 +56,7 @@
"passport-sina": "^0.1.0",
"passport-strategy": "1.x.x",
"passport-weixin": "^0.1.0",
"pinyin": "^2.8.0",
"pinyin-converter": "^2.8.1",
"request-ip": "^1.2.2",
"request-promise": "^3.0.0",
"serve-favicon": "^2.3.0",
... ...

608 Bytes | W: | H:

42.6 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
... ... @@ -127,6 +127,29 @@ function compute(coin, cb) {
});
}
function validateOrderInfo(info) {
var errTip = '';
if (!errTip && !info.addressId) {
errTip = '请填写配送地址';
}
if (!errTip && !info.paymentType) {
errTip = '请选择支付方式';
}
if (!errTip && !info.deliveryWay) {
errTip = '请选择配送方式';
}
if (errTip) {
new dialog.Alert(errTip).show();
return false;
}
return true;
}
// 支付方式
payWay = {
$allType: $('.pay-wrap > p'),
... ... @@ -167,7 +190,7 @@ payWay = {
$this.addClass('checked');
// 更新订单支付数据
that.updateOrder($this.data());
that.updateOrder(pt);
// 重新计算订单价格
compute();
... ... @@ -230,11 +253,11 @@ payWay = {
return;
}
if (info.id) {
if (info.hasOwnProperty('id')) {
order.paymentId = info.id;
}
if (info.type) {
if (info.hasOwnProperty('type')) {
order.paymentType = info.type;
}
}
... ... @@ -692,6 +715,11 @@ $('#order-submit').click(function() {
$.extend(order, invoiceInfo);
}
// 订单参数校验
if (!validateOrderInfo(order)) {
return;
}
$.ajax({
type: 'POST',
url: '/cart/ensure/submit',
... ...