Authored by 周少峰

Merge branch 'hotfix/submit'

@@ -66,10 +66,10 @@ const submit = (req, res, next) => { @@ -66,10 +66,10 @@ const submit = (req, res, next) => {
66 let uid = req.user.uid; 66 let uid = req.user.uid;
67 let remoteIp = req.ip; 67 let remoteIp = req.ip;
68 68
69 - if (!req.body.addressId) { 69 + if (!req.body.addressId || !req.body.paymentType || !req.body.deliveryWay) {
70 res.send({ 70 res.send({
71 code: 500, 71 code: 500,
72 - message: '配送地址不能为空' 72 + message: '订单参数不完整'
73 }); 73 });
74 return; 74 return;
75 } 75 }
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 'use strict'; 6 'use strict';
7 7
8 const _ = require('lodash'); 8 const _ = require('lodash');
9 -const pinyin = require('pinyin'); 9 +const pinyin = require('pinyin-converter');
10 10
11 const crypto = global.yoho.crypto; 11 const crypto = global.yoho.crypto;
12 12
@@ -29,7 +29,7 @@ module.exports = (limiter, policy) => { @@ -29,7 +29,7 @@ module.exports = (limiter, policy) => {
29 29
30 const key = `pc:limiter:${limiter.remoteIp}`; 30 const key = `pc:limiter:${limiter.remoteIp}`;
31 31
32 - let isNew = false; 32 + let isNew = true;
33 33
34 res.on('render', function() { 34 res.on('render', function() {
35 let route = req.route ? req.route.path : ''; 35 let route = req.route ? req.route.path : '';
@@ -53,9 +53,8 @@ module.exports = (limiter, policy) => { @@ -53,9 +53,8 @@ module.exports = (limiter, policy) => {
53 53
54 return cache.getAsync(key).then((result) => { 54 return cache.getAsync(key).then((result) => {
55 logger.debug('qps limiter: ' + key + '@' + result + ' max: ' + MAX_QPS); 55 logger.debug('qps limiter: ' + key + '@' + result + ' max: ' + MAX_QPS);
56 -  
57 if (result && _.isNumber(result)) { 56 if (result && _.isNumber(result)) {
58 - 57 + isNew = false;
59 if (result === -1) { 58 if (result === -1) {
60 return Promise.resolve(true); 59 return Promise.resolve(true);
61 } 60 }
@@ -72,7 +71,6 @@ module.exports = (limiter, policy) => { @@ -72,7 +71,6 @@ module.exports = (limiter, policy) => {
72 } 71 }
73 } else { 72 } else {
74 cache.setAsync(key, 1, 60); // 设置key,1m失效 73 cache.setAsync(key, 1, 60); // 设置key,1m失效
75 - isNew = true;  
76 return Promise.resolve(true); 74 return Promise.resolve(true);
77 } 75 }
78 }); 76 });
1 { 1 {
2 "name": "yohobuy-node", 2 "name": "yohobuy-node",
3 - "version": "5.4.13", 3 + "version": "5.4.14",
4 "private": true, 4 "private": true,
5 "description": "A New Yohobuy Project With Express", 5 "description": "A New Yohobuy Project With Express",
6 "repository": { 6 "repository": {
@@ -56,7 +56,7 @@ @@ -56,7 +56,7 @@
56 "passport-sina": "^0.1.0", 56 "passport-sina": "^0.1.0",
57 "passport-strategy": "1.x.x", 57 "passport-strategy": "1.x.x",
58 "passport-weixin": "^0.1.0", 58 "passport-weixin": "^0.1.0",
59 - "pinyin": "^2.8.0", 59 + "pinyin-converter": "^2.8.1",
60 "request-ip": "^1.2.2", 60 "request-ip": "^1.2.2",
61 "request-promise": "^3.0.0", 61 "request-promise": "^3.0.0",
62 "serve-favicon": "^2.3.0", 62 "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) { @@ -127,6 +127,29 @@ function compute(coin, cb) {
127 }); 127 });
128 } 128 }
129 129
  130 +function validateOrderInfo(info) {
  131 + var errTip = '';
  132 +
  133 + if (!errTip && !info.addressId) {
  134 + errTip = '请填写配送地址';
  135 + }
  136 +
  137 + if (!errTip && !info.paymentType) {
  138 + errTip = '请选择支付方式';
  139 + }
  140 +
  141 + if (!errTip && !info.deliveryWay) {
  142 + errTip = '请选择配送方式';
  143 + }
  144 +
  145 + if (errTip) {
  146 + new dialog.Alert(errTip).show();
  147 + return false;
  148 + }
  149 +
  150 + return true;
  151 +}
  152 +
130 // 支付方式 153 // 支付方式
131 payWay = { 154 payWay = {
132 $allType: $('.pay-wrap > p'), 155 $allType: $('.pay-wrap > p'),
@@ -167,7 +190,7 @@ payWay = { @@ -167,7 +190,7 @@ payWay = {
167 $this.addClass('checked'); 190 $this.addClass('checked');
168 191
169 // 更新订单支付数据 192 // 更新订单支付数据
170 - that.updateOrder($this.data()); 193 + that.updateOrder(pt);
171 194
172 // 重新计算订单价格 195 // 重新计算订单价格
173 compute(); 196 compute();
@@ -230,11 +253,11 @@ payWay = { @@ -230,11 +253,11 @@ payWay = {
230 return; 253 return;
231 } 254 }
232 255
233 - if (info.id) { 256 + if (info.hasOwnProperty('id')) {
234 order.paymentId = info.id; 257 order.paymentId = info.id;
235 } 258 }
236 259
237 - if (info.type) { 260 + if (info.hasOwnProperty('type')) {
238 order.paymentType = info.type; 261 order.paymentType = info.type;
239 } 262 }
240 } 263 }
@@ -692,6 +715,11 @@ $('#order-submit').click(function() { @@ -692,6 +715,11 @@ $('#order-submit').click(function() {
692 $.extend(order, invoiceInfo); 715 $.extend(order, invoiceInfo);
693 } 716 }
694 717
  718 + // 订单参数校验
  719 + if (!validateOrderInfo(order)) {
  720 + return;
  721 + }
  722 +
695 $.ajax({ 723 $.ajax({
696 type: 'POST', 724 type: 'POST',
697 url: '/cart/ensure/submit', 725 url: '/cart/ensure/submit',