...
|
...
|
@@ -11,28 +11,28 @@ const api = global.yoho.API; |
|
|
* @param string $skuList 购买限购商品时需要传递的参数
|
|
|
* @return see doc
|
|
|
*/
|
|
|
exports.cartPayAPI = (uid, cartType, isUseYohoCoin, skuList, activityInfo) => {
|
|
|
if (!activityInfo) {
|
|
|
activityInfo = null;
|
|
|
exports.cartPayAPI = (params) => {
|
|
|
if (!params.activityInfo) {
|
|
|
params.activityInfo = null;
|
|
|
}
|
|
|
|
|
|
let param = {
|
|
|
method: activityInfo ? 'app.Shopping.easyPayment' : 'app.Shopping.payment',
|
|
|
method: params.activityInfo ? 'app.Shopping.easyPayment' : 'app.Shopping.payment',
|
|
|
enable_red_envelopes: 0, // h5不返回红包
|
|
|
cart_type: cartType,
|
|
|
yoho_coin_mode: isUseYohoCoin,
|
|
|
uid: uid
|
|
|
cart_type: params.cart_type,
|
|
|
yoho_coin_mode: params.yoho_coin_mode,
|
|
|
uid: params.uid
|
|
|
};
|
|
|
|
|
|
// 购买限购商品时需要传递product_sku_list参数
|
|
|
if (!_.isEmpty(skuList)) {
|
|
|
param.product_sku_list = JSON.stringify(skuList);
|
|
|
if (!_.isEmpty(params.product_sku_list)) {
|
|
|
param.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) {
|
|
|
param.activity_id = params.activityInfo.activity_id;
|
|
|
param.product_sku_list = JSON.stringify(params.activityInfo.product_sku_list);
|
|
|
}
|
|
|
|
|
|
return api.get('', param, {cache: false});
|
...
|
...
|
@@ -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});
|
|
|
};
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -147,97 +143,91 @@ 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;
|
|
|
}
|
|
|
|
|
|
// 发票类型:个人 1, 企业 2
|
|
|
if (invoices.invoice_payable_type) {
|
|
|
params.invoice_payable_type = invoices.invoice_payable_type;
|
|
|
if (params.invoices.invoice_payable_type) {
|
|
|
finalParams.invoice_payable_type = params.invoices.invoice_payable_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
|
|
|
}
|
|
|
});
|
|
|
};
|
...
|
...
|
|