Authored by 毕凯

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

... ... @@ -13,7 +13,6 @@ const orderModel = require('../models/order');
const shoppingModel = require('../models/shopping');
const utils = '../../../utils';
const paymentProcess = require(`${utils}/payment-process`);
const crypto = global.yoho.crypto;
const logger = global.yoho.logger;
const helpers = global.yoho.helpers;
... ... @@ -193,7 +192,7 @@ class BuyNowController {
buy_number: req.body.buy_number,
coupon_code: req.body.coupon_code,
gift_card_code: req.body.gift_card_code,
address_id: parseInt(crypto.decrypt('', req.body.address_id), 10) || 0,
address_id: req.body.address_id,
delivery_time: req.body.delivery_time,
delivery_way: req.body.delivery_way,
use_yoho_coin: req.body.use_yoho_coin,
... ...
... ... @@ -9,7 +9,6 @@ const addressModel = require('../models/address');
const orderModel = require('../models/order');
const buyNowModel = require('../models/buy-now-model');
const shoppingModel = require('../models/shopping');
const crypto = global.yoho.crypto;
const paymentProcess = require(global.utils + '/payment-process');
const logger = global.yoho.logger;
... ... @@ -199,7 +198,7 @@ exports.orderCompute = (req, res, next) => {
exports.orderSub = (req, res, next) => {
let uid = req.user.uid;
let udid = req.cookies.udid || 'yoho';
let addressId = parseInt(crypto.decrypt('', req.body.addressId), 10);
let addressId = req.body.addressId;
let cartType = req.body.cartType || 'ordinary';
let deliveryTimeId = req.body.deliveryTimeId || 1;
let deliveryId = req.body.deliveryId || 1;
... ...
... ... @@ -220,7 +220,7 @@ exports.submit = (req, res, next) => {
if (!addressId) {
return res.json({code: 400, message: '请选择地址'});
} else {
addressId = parseInt(crypto.decrypt(null, req.body.addressId), 10);
addressId = req.body.addressId;
}
if ([uid, sku, activityId, addressId, deliveryTime,
... ...
'use strict';
// doc: http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/个人中心/地址管理.md';
const crypto = global.yoho.crypto;
class AddressModel extends global.yoho.BaseModel {
constructor(ctx) {
... ... @@ -23,13 +22,6 @@ class AddressModel extends global.yoho.BaseModel {
cache: false
}
}).then(result => {
if (result.code === 200) {
// 加密address_id
result.data.forEach(address => {
address.address_id = encodeURIComponent(crypto.encryption(null, address.address_id));
});
}
return result;
}, () => {
return {code: 500, data: [], message: '地址获取失败'};
... ...
'use strict';
const _ = require('lodash');
const crypto = global.yoho.crypto;
class orderModel extends global.yoho.BaseModel {
constructor(ctx) {
... ... @@ -11,8 +10,7 @@ class orderModel extends global.yoho.BaseModel {
let invoices_title = false;
let invoices_title_personal = false;
let invoices_type = '2';
let addressId = orderInfo.addressId &&
parseInt(crypto.encryption('', orderInfo.addressId), 10) || 0;
let addressId = orderInfo.addressId;
// 用户手机号处理
if (orderInfo.receiverMobile && orderInfo.isModifyTel) {
... ...
... ... @@ -147,7 +147,7 @@ exports.saveAddress = (req, res, next) => {
area_code: req.body.area_code,
consignee: req.body.consignee,
email: req.body.email,
id: decodeURIComponent(req.body.id),
id: req.body.id,
mobile: req.body.mobile,
zip_code: req.body.zip_code
}).then(result => {
... ... @@ -163,7 +163,7 @@ exports.saveAddress = (req, res, next) => {
*/
exports.delAddress = (req, res, next) => {
req.ctx(addressModel).delAddress({
id: decodeURIComponent(req.body.id),
id: req.body.id,
uid: req.user.uid
}).then(result => {
res.json(result);
... ... @@ -241,7 +241,7 @@ exports.locationList = (req, res, next) => {
exports.chooseAddress = (req, res, next) => {
let uid = req.user.uid;
let orderCode = req.query.orderCode;
let addressId = decodeURIComponent(req.query.addressId);
let addressId = req.query.addressId;
if (!addressId || !orderCode) {
return res.json({
... ...
... ... @@ -9,7 +9,6 @@
const api = global.yoho.API;
const _ = require('lodash');
const camelCase = global.yoho.camelCase;
const crypto = global.yoho.crypto;
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
... ... @@ -55,7 +54,7 @@ module.exports = class extends global.yoho.BaseModel {
return this.get({
data: {
method: params.id ? 'app.address.update' : 'app.address.add',
id: params.id ? _.parseInt(params.id) : null,
id: params.id,
address: params.address,
area_code: params.area_code,
consignee: params.consignee,
... ... @@ -76,8 +75,8 @@ module.exports = class extends global.yoho.BaseModel {
return this.get({
data: {
method: 'app.address.setdefault',
uid: params.id,
id: _.parseInt(params.id)
uid: params.uid,
id: params.id
}
});
}
... ... @@ -91,7 +90,7 @@ module.exports = class extends global.yoho.BaseModel {
return this.get({
data: {
method: 'app.address.del',
id: _.parseInt(params.id),
id: params.id,
uid: params.uid
}
});
... ... @@ -115,11 +114,7 @@ module.exports = class extends global.yoho.BaseModel {
if (selfAddress.data) {
/* 加密地址 ID */
_.forEach(selfAddress.data, (value, key) => {
selfAddress.data[key].address_id =
encodeURIComponent(crypto.encryption(null, selfAddress.data[key].address_id));
_.forEach(selfAddress.data, (value) => {
if (value.area.length > 11) {
value.showArea = value.area.substr(0, 5) + '...' + value.area.substr(-5);
} else {
... ... @@ -160,10 +155,6 @@ module.exports = class extends global.yoho.BaseModel {
* @param params
*/
saveAddress(params) {
if (params.id) {
params.id = _.parseInt(crypto.decrypt(null, decodeURIComponent(params.id)));
}
return this._saveAddressData(params).then(result => {
return result;
});
... ... @@ -174,9 +165,6 @@ module.exports = class extends global.yoho.BaseModel {
* @param params
*/
setDefaultAddress(params) {
if (params.id) {
params.id = _.parseInt(crypto.encryption(null, params.id));
}
return this._setDefaultAddress(params).then(result => {
return result;
});
... ... @@ -187,9 +175,6 @@ module.exports = class extends global.yoho.BaseModel {
* @param params
*/
delAddress(params) {
if (params.id) {
params.id = _.parseInt(crypto.decrypt(null, params.id));
}
return this._delAddressData(params).then(result => {
return result;
});
... ... @@ -234,7 +219,7 @@ module.exports = class extends global.yoho.BaseModel {
method: 'app.SpaceOrders.updateDeliveryAddress',
uid: uid,
order_code: orderCode,
address_id: _.parseInt(crypto.decrypt(null, addressId))
address_id: addressId
}
}).then((result) => {
return result;
... ...
... ... @@ -3,7 +3,6 @@
* DOC: http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/订单/exchange.md
*/
const api = global.yoho.API;
const crypto = global.yoho.crypto;
const _ = require('lodash');
const exchange = {
... ... @@ -37,10 +36,6 @@ const exchange = {
method: 'app.change.submit'
});
if (data.address_id) {
data.address_id = crypto.decrypt(null, decodeURIComponent(data.address_id));
}
if (!data.zip_code) {
delete data.zip_code;
}
... ...
... ... @@ -101,12 +101,9 @@ function tranformPayment(data, orderInfo, cartType, skuList, orderComputeData) {
result.name = cookieAddress ? cookieAddress.consignee : addressData.consignee;
result.phoneNum = cookieAddress ? cookieAddress.mobile : addressData.mobile;
result.addressId = cookieAddress ?
parseInt(crypto.decrypt(null, cookieAddress.address_id), 10) : addressData.address_id;
result.addressId = addressData.address_id;
result.addressInfo = cookieAddress ?
cookieAddress.address_info : [addressData.area, addressData.address].join(' ');
result.addressId = crypto.encryption(null, result.addressId + '');
isSunfengSupport = isSupport === 'N';
}
... ...