Authored by 郭成尧

ordersub-params-modified

... ... @@ -227,11 +227,19 @@ exports.orderSub = (req, res, next) => {
return co(function* () {
let result;
// 接口需要的其他参数
let otherParams = {
isPrintPrice: isPrintPrice,
unionKey: unionInfo.unionKey, // 友盟数据
let params = {
uid: uid,
address_id: addressId,
delivery_time: deliveryTimeId,
delivery_way: deliveryId,
invoices: invoices,
payment_id: paymentTypeId,
payment_type: paymentType,
remark: msg,
coupon_code: couponCode,
use_yoho_coin: yohoCoin,
is_print_price: isPrintPrice,
qhy_union: unionInfo.unionKey, // 友盟数据
userAgent: unionInfo.userAgent,
isWechat: req.yoho.isWechat,
ip: req.yoho.clientIp,
... ... @@ -242,13 +250,16 @@ exports.orderSub = (req, res, next) => {
if (req.body.cartType === 'bundle') {
let activityInfo = JSON.parse(req.cookies['activity-info']);
result = yield cartModel.orderSub(uid, addressId, 'bundle', deliveryTimeId,
deliveryId, invoices, paymentTypeId, paymentType, msg, couponCode,
yohoCoin, null, times, activityInfo, otherParams);
result = yield cartModel.orderSub(_.assign(params, {
cart_type: 'bundle',
times: times,
activityInfo: activityInfo
}));
} else {
result = yield cartModel.orderSub(uid, addressId, cartType, deliveryTimeId,
deliveryId, invoices, paymentTypeId, paymentType, msg, couponCode,
yohoCoin, skuList, null, null, otherParams);
result = yield cartModel.orderSub(_.assign(params, {
cart_type: cartType,
product_sku_list: skuList
}));
}
// 提交成功清除Cookie
... ...
... ... @@ -172,40 +172,36 @@ exports.ticketsOrderCompute = (uid, productSku, buyNumber, yohoCoin) => {
* @param otherParams 其他参数
* @return array 接口返回的数据
*/
exports.orderSub = (uid, addressId, cartType, deliveryTime,
deliveryWay, invoices, paymentId, paymentType, remark,
couponCode, yohoCoin, skuList, times, activityInfo, otherParams) => {
if (!otherParams.unionKey) {
otherParams.unionKey = '';
exports.orderSub = (params) => {
if (!params.qhy_union) {
params.qhy_union = '';
}
if (!otherParams.userAgent) {
otherParams.userAgent = null;
if (!params.userAgent) {
params.userAgent = null;
}
if (!times) {
times = 1;
if (!params.times) {
params.times = 1;
}
if (!activityInfo) {
activityInfo = null;
if (!params.activityInfo) {
params.activityInfo = null;
}
if (!addressId) {
if (!params.address_id) {
return Promise.resolve({code: 401, message: '配送地址不能为空'});
}
if (!deliveryTime) {
if (!params.delivery_time) {
return Promise.resolve({code: 402, message: '请选择配送时间'});
}
if (!deliveryWay) {
if (!params.delivery_way) {
return Promise.resolve({code: 403, message: '请选择配送方式'});
}
return shoppingAPI.orderSub(uid, addressId, cartType, deliveryTime,
deliveryWay, invoices, paymentId, paymentType,
remark, couponCode, yohoCoin, skuList, times, activityInfo, otherParams).then(orderSubRes => {
return shoppingAPI.orderSub(params).then(orderSubRes => {
let finalResult = {};
if (orderSubRes && orderSubRes.data && orderSubRes.data.is_hint === 'Y') {
... ...
... ... @@ -143,92 +143,86 @@ exports.checkTickets = (uid, productSku, buyNumber, useYohoCoin, yohoCoinMode) =
* @param @param otherParams 其他参数
* @return array 接口返回的数据
*/
exports.orderSub = (uid, addressId, cartType, deliveryTime,
deliveryWay, invoices, paymentId, paymentType, remark, couponCode,
yohoCoin, skuList, times, activityInfo, otherParams) => {
if (!activityInfo) {
activityInfo = null;
}
let params = {
method: activityInfo ? 'app.Shopping.easySubmit' : 'app.Shopping.submit',
address_id: addressId,
cart_type: cartType,
delivery_time: deliveryTime,
delivery_way: deliveryWay,
payment_id: paymentId,
payment_type: paymentType,
remark: remark,
uid: uid,
udid: otherParams.udid,
is_print_price: otherParams.isPrintPrice
exports.orderSub = (params) => {
let finalParams = {
method: params.activityInfo ? 'app.Shopping.easySubmit' : 'app.Shopping.submit',
address_id: params.address_id,
cart_type: params.cart_type,
delivery_time: params.delivery_time,
delivery_way: params.delivery_way,
payment_id: params.payment_id,
payment_type: params.payment_type,
remark: params.remark,
uid: params.uid,
udid: params.udid,
is_print_price: params.is_print_price
};
/* tar add 161130 结算优化 */
if (times === 2 || times === '2') {
params.is_continue_buy = 'Y';
if (params.times === 2 || params.times === '2') {
finalParams.is_continue_buy = 'Y';
} else {
params.is_continue_buy = 'N';
finalParams.is_continue_buy = 'N';
}
// 发票内容写死明细
if (invoices.invoices_type_id) {
params.invoice_content = 12;
if (params.invoices.invoices_type_id) {
finalParams.invoice_content = 12;
}
// 发票类型 纸质 1 ,电子 2
if (invoices.invoices_type) {
params.invoices_type = invoices.invoices_type;
if (params.invoices.invoices_type) {
finalParams.invoices_type = params.invoices.invoices_type;
}
// 收票人手机号码
if (invoices.receiverMobile) {
params.receiverMobile = invoices.receiverMobile;
if (params.invoices.receiverMobile) {
finalParams.receiverMobile = params.invoices.receiverMobile;
}
// 发票抬头
if (invoices.invoices_title) {
params.invoices_title = invoices.invoices_title;
if (params.invoices.invoices_title) {
finalParams.invoices_title = params.invoices.invoices_title;
}
// 购买方纳税人识别号,需要开具电子发票且发票抬头为单位信息时为必填项
if (invoices.buyerTaxNumber) {
params.buyerTaxNumber = invoices.buyerTaxNumber;
if (params.invoices.buyerTaxNumber) {
finalParams.buyerTaxNumber = params.invoices.buyerTaxNumber;
}
if (couponCode) {
params.coupon_code = couponCode;
if (params.coupon_code) {
finalParams.coupon_code = params.coupon_code;
}
if (yohoCoin) {
params.use_yoho_coin = yohoCoin;
if (params.use_yoho_coin) {
finalParams.use_yoho_coin = params.use_yoho_coin;
}
// 购买限购商品时需要传递product_sku_list参数
if (skuList && !activityInfo) {
params.product_sku_list = JSON.stringify(skuList);
if (params.product_sku_list && !params.activityInfo) {
finalParams.product_sku_list = JSON.stringify(params.product_sku_list);
}
// 购买套餐商品需要的数据
if (activityInfo) {
params.activity_id = activityInfo.activity_id;
params.product_sku_list = JSON.stringify(activityInfo.product_sku_list); // TODO 检查 JSON 是否正常
if (params.activityInfo) {
finalParams.activity_id = params.activityInfo.activity_id;
finalParams.product_sku_list = JSON.stringify(params.activityInfo.product_sku_list); // TODO 检查 JSON 是否正常
}
// 友盟有关信息的传递
if (otherParams.unionKey) {
params.qhy_union = otherParams.unionKey;
if (params.qhy_union) {
finalParams.qhy_union = params.qhy_union;
}
// 是否是微信商城
if (otherParams.isWechat) {
params.client_type = 'wechat';
if (params.isWechat) {
finalParams.client_type = 'wechat';
}
return api.post('', params, {
return api.post('', finalParams, {
headers: {
'X-Forwarded-For': otherParams.ip || '',
'User-Agent': otherParams.userAgent
'X-Forwarded-For': params.ip || '',
'User-Agent': params.userAgent
}
});
};
... ...