Authored by 毕凯

Merge remote-tracking branch 'origin/feature/address' into release/6.3

@@ -13,7 +13,6 @@ const orderModel = require('../models/order'); @@ -13,7 +13,6 @@ const orderModel = require('../models/order');
13 const shoppingModel = require('../models/shopping'); 13 const shoppingModel = require('../models/shopping');
14 const utils = '../../../utils'; 14 const utils = '../../../utils';
15 const paymentProcess = require(`${utils}/payment-process`); 15 const paymentProcess = require(`${utils}/payment-process`);
16 -const crypto = global.yoho.crypto;  
17 const logger = global.yoho.logger; 16 const logger = global.yoho.logger;
18 const helpers = global.yoho.helpers; 17 const helpers = global.yoho.helpers;
19 18
@@ -193,7 +192,7 @@ class BuyNowController { @@ -193,7 +192,7 @@ class BuyNowController {
193 buy_number: req.body.buy_number, 192 buy_number: req.body.buy_number,
194 coupon_code: req.body.coupon_code, 193 coupon_code: req.body.coupon_code,
195 gift_card_code: req.body.gift_card_code, 194 gift_card_code: req.body.gift_card_code,
196 - address_id: parseInt(crypto.decrypt('', req.body.address_id), 10) || 0, 195 + address_id: req.body.address_id,
197 delivery_time: req.body.delivery_time, 196 delivery_time: req.body.delivery_time,
198 delivery_way: req.body.delivery_way, 197 delivery_way: req.body.delivery_way,
199 use_yoho_coin: req.body.use_yoho_coin, 198 use_yoho_coin: req.body.use_yoho_coin,
@@ -9,7 +9,6 @@ const addressModel = require('../models/address'); @@ -9,7 +9,6 @@ const addressModel = require('../models/address');
9 const orderModel = require('../models/order'); 9 const orderModel = require('../models/order');
10 const buyNowModel = require('../models/buy-now-model'); 10 const buyNowModel = require('../models/buy-now-model');
11 const shoppingModel = require('../models/shopping'); 11 const shoppingModel = require('../models/shopping');
12 -const crypto = global.yoho.crypto;  
13 const paymentProcess = require(global.utils + '/payment-process'); 12 const paymentProcess = require(global.utils + '/payment-process');
14 const logger = global.yoho.logger; 13 const logger = global.yoho.logger;
15 14
@@ -199,7 +198,7 @@ exports.orderCompute = (req, res, next) => { @@ -199,7 +198,7 @@ exports.orderCompute = (req, res, next) => {
199 exports.orderSub = (req, res, next) => { 198 exports.orderSub = (req, res, next) => {
200 let uid = req.user.uid; 199 let uid = req.user.uid;
201 let udid = req.cookies.udid || 'yoho'; 200 let udid = req.cookies.udid || 'yoho';
202 - let addressId = parseInt(crypto.decrypt('', req.body.addressId), 10); 201 + let addressId = req.body.addressId;
203 let cartType = req.body.cartType || 'ordinary'; 202 let cartType = req.body.cartType || 'ordinary';
204 let deliveryTimeId = req.body.deliveryTimeId || 1; 203 let deliveryTimeId = req.body.deliveryTimeId || 1;
205 let deliveryId = req.body.deliveryId || 1; 204 let deliveryId = req.body.deliveryId || 1;
@@ -220,7 +220,7 @@ exports.submit = (req, res, next) => { @@ -220,7 +220,7 @@ exports.submit = (req, res, next) => {
220 if (!addressId) { 220 if (!addressId) {
221 return res.json({code: 400, message: '请选择地址'}); 221 return res.json({code: 400, message: '请选择地址'});
222 } else { 222 } else {
223 - addressId = parseInt(crypto.decrypt(null, req.body.addressId), 10); 223 + addressId = req.body.addressId;
224 } 224 }
225 225
226 if ([uid, sku, activityId, addressId, deliveryTime, 226 if ([uid, sku, activityId, addressId, deliveryTime,
1 'use strict'; 1 'use strict';
2 2
3 // doc: http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/个人中心/地址管理.md'; 3 // doc: http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/个人中心/地址管理.md';
4 -const crypto = global.yoho.crypto;  
5 4
6 class AddressModel extends global.yoho.BaseModel { 5 class AddressModel extends global.yoho.BaseModel {
7 constructor(ctx) { 6 constructor(ctx) {
@@ -23,13 +22,6 @@ class AddressModel extends global.yoho.BaseModel { @@ -23,13 +22,6 @@ class AddressModel extends global.yoho.BaseModel {
23 cache: false 22 cache: false
24 } 23 }
25 }).then(result => { 24 }).then(result => {
26 - if (result.code === 200) {  
27 - // 加密address_id  
28 - result.data.forEach(address => {  
29 - address.address_id = encodeURIComponent(crypto.encryption(null, address.address_id));  
30 - });  
31 - }  
32 -  
33 return result; 25 return result;
34 }, () => { 26 }, () => {
35 return {code: 500, data: [], message: '地址获取失败'}; 27 return {code: 500, data: [], message: '地址获取失败'};
1 'use strict'; 1 'use strict';
2 const _ = require('lodash'); 2 const _ = require('lodash');
3 -const crypto = global.yoho.crypto;  
4 3
5 class orderModel extends global.yoho.BaseModel { 4 class orderModel extends global.yoho.BaseModel {
6 constructor(ctx) { 5 constructor(ctx) {
@@ -11,8 +10,7 @@ class orderModel extends global.yoho.BaseModel { @@ -11,8 +10,7 @@ class orderModel extends global.yoho.BaseModel {
11 let invoices_title = false; 10 let invoices_title = false;
12 let invoices_title_personal = false; 11 let invoices_title_personal = false;
13 let invoices_type = '2'; 12 let invoices_type = '2';
14 - let addressId = orderInfo.addressId &&  
15 - parseInt(crypto.encryption('', orderInfo.addressId), 10) || 0; 13 + let addressId = orderInfo.addressId;
16 14
17 // 用户手机号处理 15 // 用户手机号处理
18 if (orderInfo.receiverMobile && orderInfo.isModifyTel) { 16 if (orderInfo.receiverMobile && orderInfo.isModifyTel) {
@@ -147,7 +147,7 @@ exports.saveAddress = (req, res, next) => { @@ -147,7 +147,7 @@ exports.saveAddress = (req, res, next) => {
147 area_code: req.body.area_code, 147 area_code: req.body.area_code,
148 consignee: req.body.consignee, 148 consignee: req.body.consignee,
149 email: req.body.email, 149 email: req.body.email,
150 - id: decodeURIComponent(req.body.id), 150 + id: req.body.id,
151 mobile: req.body.mobile, 151 mobile: req.body.mobile,
152 zip_code: req.body.zip_code 152 zip_code: req.body.zip_code
153 }).then(result => { 153 }).then(result => {
@@ -163,7 +163,7 @@ exports.saveAddress = (req, res, next) => { @@ -163,7 +163,7 @@ exports.saveAddress = (req, res, next) => {
163 */ 163 */
164 exports.delAddress = (req, res, next) => { 164 exports.delAddress = (req, res, next) => {
165 req.ctx(addressModel).delAddress({ 165 req.ctx(addressModel).delAddress({
166 - id: decodeURIComponent(req.body.id), 166 + id: req.body.id,
167 uid: req.user.uid 167 uid: req.user.uid
168 }).then(result => { 168 }).then(result => {
169 res.json(result); 169 res.json(result);
@@ -241,7 +241,7 @@ exports.locationList = (req, res, next) => { @@ -241,7 +241,7 @@ exports.locationList = (req, res, next) => {
241 exports.chooseAddress = (req, res, next) => { 241 exports.chooseAddress = (req, res, next) => {
242 let uid = req.user.uid; 242 let uid = req.user.uid;
243 let orderCode = req.query.orderCode; 243 let orderCode = req.query.orderCode;
244 - let addressId = decodeURIComponent(req.query.addressId); 244 + let addressId = req.query.addressId;
245 245
246 if (!addressId || !orderCode) { 246 if (!addressId || !orderCode) {
247 return res.json({ 247 return res.json({
@@ -9,7 +9,6 @@ @@ -9,7 +9,6 @@
9 const api = global.yoho.API; 9 const api = global.yoho.API;
10 const _ = require('lodash'); 10 const _ = require('lodash');
11 const camelCase = global.yoho.camelCase; 11 const camelCase = global.yoho.camelCase;
12 -const crypto = global.yoho.crypto;  
13 12
14 module.exports = class extends global.yoho.BaseModel { 13 module.exports = class extends global.yoho.BaseModel {
15 constructor(ctx) { 14 constructor(ctx) {
@@ -55,7 +54,7 @@ module.exports = class extends global.yoho.BaseModel { @@ -55,7 +54,7 @@ module.exports = class extends global.yoho.BaseModel {
55 return this.get({ 54 return this.get({
56 data: { 55 data: {
57 method: params.id ? 'app.address.update' : 'app.address.add', 56 method: params.id ? 'app.address.update' : 'app.address.add',
58 - id: params.id ? _.parseInt(params.id) : null, 57 + id: params.id,
59 address: params.address, 58 address: params.address,
60 area_code: params.area_code, 59 area_code: params.area_code,
61 consignee: params.consignee, 60 consignee: params.consignee,
@@ -76,8 +75,8 @@ module.exports = class extends global.yoho.BaseModel { @@ -76,8 +75,8 @@ module.exports = class extends global.yoho.BaseModel {
76 return this.get({ 75 return this.get({
77 data: { 76 data: {
78 method: 'app.address.setdefault', 77 method: 'app.address.setdefault',
79 - uid: params.id,  
80 - id: _.parseInt(params.id) 78 + uid: params.uid,
  79 + id: params.id
81 } 80 }
82 }); 81 });
83 } 82 }
@@ -91,7 +90,7 @@ module.exports = class extends global.yoho.BaseModel { @@ -91,7 +90,7 @@ module.exports = class extends global.yoho.BaseModel {
91 return this.get({ 90 return this.get({
92 data: { 91 data: {
93 method: 'app.address.del', 92 method: 'app.address.del',
94 - id: _.parseInt(params.id), 93 + id: params.id,
95 uid: params.uid 94 uid: params.uid
96 } 95 }
97 }); 96 });
@@ -115,11 +114,7 @@ module.exports = class extends global.yoho.BaseModel { @@ -115,11 +114,7 @@ module.exports = class extends global.yoho.BaseModel {
115 114
116 if (selfAddress.data) { 115 if (selfAddress.data) {
117 116
118 - /* 加密地址 ID */  
119 - _.forEach(selfAddress.data, (value, key) => {  
120 - selfAddress.data[key].address_id =  
121 - encodeURIComponent(crypto.encryption(null, selfAddress.data[key].address_id));  
122 - 117 + _.forEach(selfAddress.data, (value) => {
123 if (value.area.length > 11) { 118 if (value.area.length > 11) {
124 value.showArea = value.area.substr(0, 5) + '...' + value.area.substr(-5); 119 value.showArea = value.area.substr(0, 5) + '...' + value.area.substr(-5);
125 } else { 120 } else {
@@ -160,10 +155,6 @@ module.exports = class extends global.yoho.BaseModel { @@ -160,10 +155,6 @@ module.exports = class extends global.yoho.BaseModel {
160 * @param params 155 * @param params
161 */ 156 */
162 saveAddress(params) { 157 saveAddress(params) {
163 - if (params.id) {  
164 - params.id = _.parseInt(crypto.decrypt(null, decodeURIComponent(params.id)));  
165 - }  
166 -  
167 return this._saveAddressData(params).then(result => { 158 return this._saveAddressData(params).then(result => {
168 return result; 159 return result;
169 }); 160 });
@@ -174,9 +165,6 @@ module.exports = class extends global.yoho.BaseModel { @@ -174,9 +165,6 @@ module.exports = class extends global.yoho.BaseModel {
174 * @param params 165 * @param params
175 */ 166 */
176 setDefaultAddress(params) { 167 setDefaultAddress(params) {
177 - if (params.id) {  
178 - params.id = _.parseInt(crypto.encryption(null, params.id));  
179 - }  
180 return this._setDefaultAddress(params).then(result => { 168 return this._setDefaultAddress(params).then(result => {
181 return result; 169 return result;
182 }); 170 });
@@ -187,9 +175,6 @@ module.exports = class extends global.yoho.BaseModel { @@ -187,9 +175,6 @@ module.exports = class extends global.yoho.BaseModel {
187 * @param params 175 * @param params
188 */ 176 */
189 delAddress(params) { 177 delAddress(params) {
190 - if (params.id) {  
191 - params.id = _.parseInt(crypto.decrypt(null, params.id));  
192 - }  
193 return this._delAddressData(params).then(result => { 178 return this._delAddressData(params).then(result => {
194 return result; 179 return result;
195 }); 180 });
@@ -234,7 +219,7 @@ module.exports = class extends global.yoho.BaseModel { @@ -234,7 +219,7 @@ module.exports = class extends global.yoho.BaseModel {
234 method: 'app.SpaceOrders.updateDeliveryAddress', 219 method: 'app.SpaceOrders.updateDeliveryAddress',
235 uid: uid, 220 uid: uid,
236 order_code: orderCode, 221 order_code: orderCode,
237 - address_id: _.parseInt(crypto.decrypt(null, addressId)) 222 + address_id: addressId
238 } 223 }
239 }).then((result) => { 224 }).then((result) => {
240 return result; 225 return result;
@@ -3,7 +3,6 @@ @@ -3,7 +3,6 @@
3 * DOC: http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/订单/exchange.md 3 * DOC: http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/订单/exchange.md
4 */ 4 */
5 const api = global.yoho.API; 5 const api = global.yoho.API;
6 -const crypto = global.yoho.crypto;  
7 const _ = require('lodash'); 6 const _ = require('lodash');
8 7
9 const exchange = { 8 const exchange = {
@@ -37,10 +36,6 @@ const exchange = { @@ -37,10 +36,6 @@ const exchange = {
37 method: 'app.change.submit' 36 method: 'app.change.submit'
38 }); 37 });
39 38
40 - if (data.address_id) {  
41 - data.address_id = crypto.decrypt(null, decodeURIComponent(data.address_id));  
42 - }  
43 -  
44 if (!data.zip_code) { 39 if (!data.zip_code) {
45 delete data.zip_code; 40 delete data.zip_code;
46 } 41 }
@@ -101,12 +101,9 @@ function tranformPayment(data, orderInfo, cartType, skuList, orderComputeData) { @@ -101,12 +101,9 @@ function tranformPayment(data, orderInfo, cartType, skuList, orderComputeData) {
101 101
102 result.name = cookieAddress ? cookieAddress.consignee : addressData.consignee; 102 result.name = cookieAddress ? cookieAddress.consignee : addressData.consignee;
103 result.phoneNum = cookieAddress ? cookieAddress.mobile : addressData.mobile; 103 result.phoneNum = cookieAddress ? cookieAddress.mobile : addressData.mobile;
104 - result.addressId = cookieAddress ?  
105 - parseInt(crypto.decrypt(null, cookieAddress.address_id), 10) : addressData.address_id; 104 + result.addressId = addressData.address_id;
106 result.addressInfo = cookieAddress ? 105 result.addressInfo = cookieAddress ?
107 cookieAddress.address_info : [addressData.area, addressData.address].join(' '); 106 cookieAddress.address_info : [addressData.area, addressData.address].join(' ');
108 -  
109 - result.addressId = crypto.encryption(null, result.addressId + '');  
110 isSunfengSupport = isSupport === 'N'; 107 isSunfengSupport = isSupport === 'N';
111 } 108 }
112 109