Authored by 郭成尧

buynow-ctx

... ... @@ -3,7 +3,6 @@
* @Date: 2017-06-21 10:15:45
* @Last Modified by: Targaryen
*/
const api = global.yoho.API;
class BuyNowModel extends global.yoho.BaseModel {
constructor(ctx) {
... ... @@ -15,13 +14,18 @@ class BuyNowModel extends global.yoho.BaseModel {
* @param {*} params
*/
countUsableCoupon(params) {
return api.post('', {
method: 'app.Buynow.countUsableCoupon',
uid: params.uid,
product_sku: params.product_sku,
sku_type: params.sku_type || 'I',
buy_number: params.buy_number
}, {cache: false});
return this.post({
data: {
method: 'app.Buynow.countUsableCoupon',
uid: params.uid,
product_sku: params.product_sku,
sku_type: params.sku_type || 'I',
buy_number: params.buy_number
},
param: {
cache: false
}
});
}
/**
... ... @@ -29,15 +33,18 @@ class BuyNowModel extends global.yoho.BaseModel {
* @param {*} params
*/
listCoupon(params) {
return api.post('', {
method: 'app.Buynow.listCoupon',
uid: params.uid,
product_sku: params.product_sku,
sku_type: params.sku_type || 'I',
buy_number: params.buy_number,
is_group_frees: params.is_group_frees,
delivery_way: params.delivery_way
}, {cache: false});
return this.post({
data: {
method: 'app.Buynow.listCoupon',
uid: params.uid,
product_sku: params.product_sku,
sku_type: params.sku_type || 'I',
buy_number: params.buy_number,
is_group_frees: params.is_group_frees,
delivery_way: params.delivery_way
},
param: {cache: false}
});
}
/**
... ... @@ -46,19 +53,24 @@ class BuyNowModel extends global.yoho.BaseModel {
*/
payment(params) {
let finalParams = {
method: 'app.Buynow.payment',
uid: params.uid,
product_sku: params.product_sku,
sku_type: params.sku_type || 'I',
buy_number: params.buy_number,
yoho_coin_mode: params.yoho_coin_mode || 0, // 是否使用有货币
yoho_bill_term: 0, // H5 不支持分期
is_support_apple_pay: 'N', // H5 不支持 APPLE PAY
activity_id: params.activity_id || 0,
enable_red_envelopes: 0 // H5 不支持使用红包
data: {
method: 'app.Buynow.payment',
uid: params.uid,
product_sku: params.product_sku,
sku_type: params.sku_type || 'I',
buy_number: params.buy_number,
yoho_coin_mode: params.yoho_coin_mode || 0, // 是否使用有货币
yoho_bill_term: 0, // H5 不支持分期
is_support_apple_pay: 'N', // H5 不支持 APPLE PAY
activity_id: params.activity_id || 0,
enable_red_envelopes: 0 // H5 不支持使用红包
},
param: {
cache: false
}
};
return api.post('', finalParams, { cache: false });
return this.post(finalParams);
}
/**
... ... @@ -95,7 +107,12 @@ class BuyNowModel extends global.yoho.BaseModel {
finalParams.coupon_code = params.coupon_code;
}
return api.post('', finalParams, {cache: false});
return this.post({
data: finalParams,
param: {
cache: false
}
});
}
/**
... ... @@ -182,10 +199,13 @@ class BuyNowModel extends global.yoho.BaseModel {
finalParams.qhy_union = params.qhy_union;
}
return api.post('', finalParams, {
headers: {
'X-Forwarded-For': params.ip || '',
'User-Agent': params.userAgent
return this.post({
data: finalParams,
param: {
headers: {
'X-Forwarded-For': params.ip || '',
'User-Agent': params.userAgent
}
}
});
}
... ... @@ -206,7 +226,10 @@ class BuyNowModel extends global.yoho.BaseModel {
if (params.coupon_code) {
finalParams.coupon_code = params.coupon_code;
}
return api.post('', finalParams, {cache: false});
return this.post({
data: finalParams,
param: {cache: false}
});
}
/**
... ... @@ -226,7 +249,12 @@ class BuyNowModel extends global.yoho.BaseModel {
finalParams.promotion_code = params.promotion_code;
}
return api.post('', finalParams, {cache: false});
return this.post({
data: finalParams,
param: {
cache: false
}
});
}
}
... ...