Authored by 郭成尧

orderComputeAPI-param-modified

... ... @@ -43,14 +43,16 @@ exports.cartPay = (uid, cartType, orderInfo, limitProductCode, sku, skn, buyNumb
// cookie保存的数据
if (orderInfo && !_.isEmpty(orderInfo)) {
orderInfo.paymentType = orderInfo.paymentType ? orderInfo.paymentType : '';
orderComputeAPI = shoppingAPI.orderComputeAPI(
uid,
cartType,
orderInfo.deliveryId,
orderInfo.paymentType,
orderInfo.couponCode,
orderInfo.yohoCoin, skuList, activityInfo
);
orderComputeAPI = shoppingAPI.orderComputeAPI({
uid: uid,
cart_type: cartType,
delivery_way: orderInfo.deliveryId,
payment_type: orderInfo.paymentType,
coupon_code: orderInfo.couponCode,
use_yoho_coin: orderInfo.yohoCoin,
product_sku_list: skuList,
activityInfo: activityInfo
});
}
// 区分套餐量贩和普通商品
... ... @@ -111,8 +113,16 @@ exports.cartPay = (uid, cartType, orderInfo, limitProductCode, sku, skn, buyNumb
* @return array 接口返回的数据
*/
exports.orderCompute = (uid, cartType, deliveryWay, paymentType, couponCode, yohoCoin, skuList, activityInfo) => {
return shoppingAPI.orderComputeAPI(uid, cartType, deliveryWay, paymentType,
couponCode, yohoCoin, skuList, activityInfo).then(result => {
return shoppingAPI.orderComputeAPI({
uid: uid,
cart_type: cartType,
delivery_way: deliveryWay,
payment_type: paymentType,
coupon_code: couponCode,
use_yoho_coin: yohoCoin,
product_sku_list: skuList,
activityInfo: activityInfo
}).then(result => {
if (result && result.data) {
result.data.use_yoho_coin = paymentProcess.transPrice(result.data.use_yoho_coin);
result.data.yohoCoinCompute = paymentProcess.yohoCoinCompute(result.data);
... ... @@ -330,15 +340,15 @@ exports.jitDetailData = (uid, cartType, skuList, orderCode, sessionKey,
if (deliveryId) {
// 购物车选择改变字段,重新运算订单数据
return shoppingAPI.orderComputeAPI(
uid,
cartType,
deliveryId,
paymentType,
couponCode,
yohoCoin,
skuList
).then(result => {
return shoppingAPI.orderComputeAPI({
uid: uid,
cart_type: cartType,
delivery_way: deliveryId,
payment_type: paymentType,
coupon_code: couponCode,
use_yoho_coin: yohoCoin,
product_sku_list: skuList
}).then(result => {
return paymentProcess.transformJit(_.get(result, 'data.package_list', []));
});
} else {
... ...
... ... @@ -56,38 +56,34 @@ exports.cartPayAPI = (uid, cartType, isUseYohoCoin, skuList, activityInfo) => {
* 2. 除非同时调用app.Shopping.payment 与该接口,用改接口的data值替换app.Shopping.payment相关值,
* 显示调用utils/payment-process.js@tranformPayment(他会帮你调yohoCoinCompute)处理payment的data;
*/
exports.orderComputeAPI = (uid, cartType, deliveWay, paymentType, couponCode, yohoCoin, skuList, activityInfo) => {
if (!activityInfo) {
activityInfo = null;
}
let param = {
method: activityInfo ? 'app.Shopping.easyCompute' : 'app.Shopping.compute',
cart_type: cartType,
delivery_way: deliveWay,
payment_type: paymentType,
uid: uid
exports.orderComputeAPI = (params) => {
let finalParams = {
method: params.activityInfo ? 'app.Shopping.easyCompute' : 'app.Shopping.compute',
cart_type: params.cart_type,
delivery_way: params.delivery_way,
payment_type: params.payment_type,
uid: params.uid
};
if (couponCode) {
param.coupon_code = couponCode;
if (params.coupon_code) {
finalParams.coupon_code = params.coupon_code;
}
if (yohoCoin) {
param.use_yoho_coin = yohoCoin;
if (params.use_yoho_coin) {
finalParams.use_yoho_coin = params.use_yoho_coin;
}
if (!_.isEmpty(skuList) && !activityInfo) {
param.product_sku_list = JSON.stringify(skuList);
if (!_.isEmpty(params.product_sku_list) && !params.activityInfo) {
finalParams.product_sku_list = JSON.stringify(params.product_sku_list);
}
// 购买套餐商品需要的数据
if (activityInfo) {
param.activity_id = activityInfo.activity_id;
param.product_sku_list = JSON.stringify(activityInfo.product_sku_list);
if (params.activityInfo) {
finalParams.activity_id = params.activityInfo.activity_id;
finalParams.product_sku_list = JSON.stringify(params.activityInfo.product_sku_list);
}
return api.get('', param, {code: 200});
return api.get('', finalParams, {code: 200});
};
/**
... ...