...
|
...
|
@@ -5,85 +5,185 @@ |
|
|
*/
|
|
|
'use strict';
|
|
|
|
|
|
const api = global.yoho.API;
|
|
|
module.exports = class extends global.yoho.BaseModel {
|
|
|
constructor(ctx) {
|
|
|
super(ctx);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取用户信息API
|
|
|
* @param uid [number] uid
|
|
|
*/
|
|
|
const getUserProfileAsync = (uid) => api.get('', {
|
|
|
method: 'app.passport.profile',
|
|
|
uid: uid
|
|
|
});
|
|
|
/**
|
|
|
* 获取用户信息API
|
|
|
* @param uid [number] uid
|
|
|
*/
|
|
|
getUserProfileAsync(uid) {
|
|
|
let options = {
|
|
|
method: 'app.passport.profile',
|
|
|
uid: uid
|
|
|
};
|
|
|
|
|
|
return this.get({data: options});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 购物车结算API
|
|
|
* @param uid [number] uid
|
|
|
* @param cartType [string] 购物车类型,ordinary表示普通, advance表示预售
|
|
|
* @param yohoCoinMode [number] 是否使用yoho币,1使用,0不使用
|
|
|
*/
|
|
|
const getOrderPaymentAsync = (uid, cartType, yohoCoinMode) => api.get('', {
|
|
|
method: 'app.Shopping.payment',
|
|
|
cart_type: cartType,
|
|
|
yoho_coin_mode: yohoCoinMode,
|
|
|
uid: uid
|
|
|
});
|
|
|
/**
|
|
|
* 购物车结算API
|
|
|
* @param uid [number] uid
|
|
|
* @param cartType [string] 购物车类型,ordinary表示普通, advance表示预售
|
|
|
* @param yohoCoinMode [number] 是否使用yoho币,1使用,0不使用
|
|
|
*/
|
|
|
getOrderPaymentAsync(uid, cartType, yohoCoinMode) {
|
|
|
let options = {
|
|
|
method: 'app.Shopping.payment',
|
|
|
cart_type: cartType,
|
|
|
yoho_coin_mode: yohoCoinMode,
|
|
|
uid: uid
|
|
|
};
|
|
|
|
|
|
return this.get({data: options});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取用户优惠券信息API
|
|
|
* @param uid [number] uid
|
|
|
*/
|
|
|
const getUesrCouponAsync = (uid) => api.get('', {
|
|
|
method: 'app.Shopping.listCoupon',
|
|
|
uid: uid,
|
|
|
is_group_frees: 'Y'
|
|
|
});
|
|
|
/**
|
|
|
* 获取用户优惠券信息API
|
|
|
* @param uid [number] uid
|
|
|
*/
|
|
|
getUesrCouponAsync(uid) {
|
|
|
let options = {
|
|
|
method: 'app.Shopping.listCoupon',
|
|
|
uid: uid,
|
|
|
is_group_frees: 'Y'
|
|
|
};
|
|
|
|
|
|
return this.get({data: options});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 优惠码兑换优惠券API
|
|
|
* @param uid [number] uid
|
|
|
* @param code [number] code
|
|
|
*/
|
|
|
const getCouponByCodeAsync = (uid, code) => api.get('', {
|
|
|
method: 'app.Shopping.useCoupon',
|
|
|
uid: uid,
|
|
|
coupon_code: code
|
|
|
});
|
|
|
/**
|
|
|
* 优惠码兑换优惠券API
|
|
|
* @param uid [number] uid
|
|
|
* @param code [number] code
|
|
|
*/
|
|
|
getCouponByCodeAsync(uid, code) {
|
|
|
let options = {
|
|
|
method: 'app.Shopping.useCoupon',
|
|
|
uid: uid,
|
|
|
coupon_code: code
|
|
|
};
|
|
|
|
|
|
return this.get({data: options});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 订单计算API
|
|
|
* @param uid [number] uid
|
|
|
* @param cartType [string] 购物车类型,ordinary表示普通, advance表示预售
|
|
|
* @param paymentType [number] 支付方式,1表示在线支付,2表示货到付款
|
|
|
* @param deliveryWay [number] 配送方式,1表示普通快递,2表示顺丰速运
|
|
|
* @param coin [number] 使用的有货币
|
|
|
* @param useRedEnvelops [number] 红包
|
|
|
* @param couponCode [string] 优惠券码
|
|
|
* @param promotionCode [string] 优惠码
|
|
|
*/
|
|
|
const getOrderComputeAsync = (uid, cartType, paymentType, deliveryWay, other) => {
|
|
|
let param = {
|
|
|
method: 'app.Shopping.compute',
|
|
|
uid: uid,
|
|
|
cart_type: cartType,
|
|
|
payment_type: paymentType,
|
|
|
delivery_way: deliveryWay
|
|
|
};
|
|
|
|
|
|
// 其他可选参数
|
|
|
if (other) {
|
|
|
/**
|
|
|
* 订单计算API
|
|
|
* @param uid [number] uid
|
|
|
* @param cartType [string] 购物车类型,ordinary表示普通, advance表示预售
|
|
|
* @param paymentType [number] 支付方式,1表示在线支付,2表示货到付款
|
|
|
* @param deliveryWay [number] 配送方式,1表示普通快递,2表示顺丰速运
|
|
|
* @param coin [number] 使用的有货币
|
|
|
* @param useRedEnvelops [number] 红包
|
|
|
* @param couponCode [string] 优惠券码
|
|
|
* @param promotionCode [string] 优惠码
|
|
|
*/
|
|
|
getOrderComputeAsync(uid, cartType, paymentType, deliveryWay, other) {
|
|
|
let param = {
|
|
|
method: 'app.Shopping.compute',
|
|
|
uid: uid,
|
|
|
cart_type: cartType,
|
|
|
payment_type: paymentType,
|
|
|
delivery_way: deliveryWay
|
|
|
};
|
|
|
|
|
|
// 其他可选参数
|
|
|
if (other) {
|
|
|
if (other.coin) {
|
|
|
Object.assign(param, {
|
|
|
use_yoho_coin: other.coin
|
|
|
});
|
|
|
}
|
|
|
|
|
|
if (other.redEnvelopes) {
|
|
|
Object.assign(param, {
|
|
|
use_red_envelopes: other.redEnvelopes
|
|
|
});
|
|
|
}
|
|
|
|
|
|
if (other.couponCode) {
|
|
|
Object.assign(param, {
|
|
|
coupon_code: other.couponCode
|
|
|
});
|
|
|
} else if (other.promotionCode) {
|
|
|
Object.assign(param, {
|
|
|
promotion_code: other.promotionCode
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return this.get({data: param});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 订单提交API
|
|
|
* @param uid [number] uid
|
|
|
* @param cartType [String] 购物车类型,ordinary表示普通, advance表示预售
|
|
|
* @param addressId [String] 地址
|
|
|
* @param deliveryTime [number] 寄送时间类型
|
|
|
* @param deliveryWay [number] 配送方式,1表示普通快递,2表示顺丰速运
|
|
|
* @param invoicesType [number] 发票类型
|
|
|
* @param invoicesTitle [string] 发票抬头
|
|
|
* @param invoicesContent [int] 发票类型
|
|
|
* @param receiverMobile [string] 发票收人电话
|
|
|
* @param coin [number] 使用的有货币金额
|
|
|
* @param redEnvelopes [number] 使用的红包
|
|
|
* @param paymentId [number] 支付id
|
|
|
* @param paymentType [number] 支付类型
|
|
|
* @param remark [string] 备注
|
|
|
* @param couponCode [string] 优惠券码
|
|
|
* @param printPrice [string] 是否打印价格
|
|
|
*/
|
|
|
orderSubmitAsync(uid, cartType, addressId, deliveryTime, deliveryWay, paymentType, paymentId, printPrice, other, remoteIp) { // eslint-disable-line
|
|
|
let param = {
|
|
|
method: 'app.Shopping.submit',
|
|
|
uid: uid,
|
|
|
cart_type: cartType,
|
|
|
address_id: addressId,
|
|
|
delivery_time: deliveryTime,
|
|
|
delivery_way: deliveryWay,
|
|
|
payment_type: paymentType,
|
|
|
payment_id: paymentId,
|
|
|
is_print_price: printPrice,
|
|
|
is_continue_buy: other.continueBuy ? 'Y' : 'N'
|
|
|
};
|
|
|
|
|
|
// 发票
|
|
|
if (other.invoicesType) {
|
|
|
Object.assign(param, {
|
|
|
invoices_type: other.invoicesType,
|
|
|
invoices_title: other.invoicesTitle,
|
|
|
invoice_content: other.invoicesContent,
|
|
|
receiverMobile: other.receiverMobile,
|
|
|
buyerTaxNumber: other.taxNumber,
|
|
|
invoice_payable_type: other.taxNumber ? 2 : 1
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 有货币
|
|
|
if (other.coin) {
|
|
|
Object.assign(param, {
|
|
|
use_yoho_coin: other.coin
|
|
|
use_yoho_coin: other.coin / 100 // 有货币稀释
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 红包
|
|
|
if (other.redEnvelopes) {
|
|
|
Object.assign(param, {
|
|
|
use_red_envelopes: other.redEnvelopes
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 备注
|
|
|
if (other.remark) {
|
|
|
Object.assign(param, {
|
|
|
remark: other.remark
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 优惠券码
|
|
|
if (other.couponCode) {
|
|
|
Object.assign(param, {
|
|
|
coupon_code: other.couponCode
|
...
|
...
|
@@ -93,120 +193,32 @@ const getOrderComputeAsync = (uid, cartType, paymentType, deliveryWay, other) => |
|
|
promotion_code: other.promotionCode
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return api.get('', param);
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 订单提交API
|
|
|
* @param uid [number] uid
|
|
|
* @param cartType [String] 购物车类型,ordinary表示普通, advance表示预售
|
|
|
* @param addressId [String] 地址
|
|
|
* @param deliveryTime [number] 寄送时间类型
|
|
|
* @param deliveryWay [number] 配送方式,1表示普通快递,2表示顺丰速运
|
|
|
* @param invoicesType [number] 发票类型
|
|
|
* @param invoicesTitle [string] 发票抬头
|
|
|
* @param invoicesContent [int] 发票类型
|
|
|
* @param receiverMobile [string] 发票收人电话
|
|
|
* @param coin [number] 使用的有货币金额
|
|
|
* @param redEnvelopes [number] 使用的红包
|
|
|
* @param paymentId [number] 支付id
|
|
|
* @param paymentType [number] 支付类型
|
|
|
* @param remark [string] 备注
|
|
|
* @param couponCode [string] 优惠券码
|
|
|
* @param printPrice [string] 是否打印价格
|
|
|
*/
|
|
|
const orderSubmitAsync = (uid, cartType, addressId, deliveryTime, deliveryWay, paymentType, paymentId, printPrice, other, remoteIp) => { // eslint-disable-line
|
|
|
let param = {
|
|
|
method: 'app.Shopping.submit',
|
|
|
uid: uid,
|
|
|
cart_type: cartType,
|
|
|
address_id: addressId,
|
|
|
delivery_time: deliveryTime,
|
|
|
delivery_way: deliveryWay,
|
|
|
payment_type: paymentType,
|
|
|
payment_id: paymentId,
|
|
|
is_print_price: printPrice,
|
|
|
is_continue_buy: other.continueBuy ? 'Y' : 'N'
|
|
|
};
|
|
|
|
|
|
// 发票
|
|
|
if (other.invoicesType) {
|
|
|
Object.assign(param, {
|
|
|
invoices_type: other.invoicesType,
|
|
|
invoices_title: other.invoicesTitle,
|
|
|
invoice_content: other.invoicesContent,
|
|
|
receiverMobile: other.receiverMobile,
|
|
|
buyerTaxNumber: other.taxNumber,
|
|
|
invoice_payable_type: other.taxNumber ? 2 : 1
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 有货币
|
|
|
if (other.coin) {
|
|
|
Object.assign(param, {
|
|
|
use_yoho_coin: other.coin / 100 // 有货币稀释
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 红包
|
|
|
if (other.redEnvelopes) {
|
|
|
Object.assign(param, {
|
|
|
use_red_envelopes: other.redEnvelopes
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 备注
|
|
|
if (other.remark) {
|
|
|
Object.assign(param, {
|
|
|
remark: other.remark
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 优惠券码
|
|
|
if (other.couponCode) {
|
|
|
Object.assign(param, {
|
|
|
coupon_code: other.couponCode
|
|
|
});
|
|
|
} else if (other.promotionCode) {
|
|
|
Object.assign(param, {
|
|
|
promotion_code: other.promotionCode
|
|
|
});
|
|
|
}
|
|
|
if (other.continueBuy) {
|
|
|
Object.assign(param, {
|
|
|
is_continue_buy: 'Y'
|
|
|
});
|
|
|
}
|
|
|
|
|
|
if (other.continueBuy) {
|
|
|
Object.assign(param, {
|
|
|
is_continue_buy: 'Y'
|
|
|
});
|
|
|
}
|
|
|
if (other.udid) {
|
|
|
Object.assign(param, {
|
|
|
udid: other.udid
|
|
|
});
|
|
|
}
|
|
|
|
|
|
if (other.udid) {
|
|
|
Object.assign(param, {
|
|
|
udid: other.udid
|
|
|
});
|
|
|
}
|
|
|
// 友盟有关信息的传递
|
|
|
if (other.qhyUnion) {
|
|
|
Object.assign(param, {
|
|
|
qhy_union: other.qhyUnion
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 友盟有关信息的传递
|
|
|
if (other.qhyUnion) {
|
|
|
Object.assign(param, {
|
|
|
qhy_union: other.qhyUnion
|
|
|
});
|
|
|
return this.get({data: param, param: {
|
|
|
headers: {
|
|
|
'X-Forwarded-For': remoteIp || '',
|
|
|
'User-Agent': other.userAgent || ''
|
|
|
}
|
|
|
}});
|
|
|
}
|
|
|
|
|
|
return api.get('', param, {
|
|
|
headers: {
|
|
|
'X-Forwarded-For': remoteIp || '',
|
|
|
'User-Agent': other.userAgent || ''
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
|
|
|
module.exports = {
|
|
|
getUserProfileAsync,
|
|
|
getOrderPaymentAsync,
|
|
|
getUesrCouponAsync,
|
|
|
getCouponByCodeAsync,
|
|
|
getOrderComputeAsync,
|
|
|
orderSubmitAsync
|
|
|
}; |
...
|
...
|
|