...
|
...
|
@@ -143,45 +143,6 @@ const addToFav = (uid, skuList /* , hasPromotion*/) =>{ |
|
|
return api.get('', param);
|
|
|
};
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取购物车商品详情数据
|
|
|
*
|
|
|
* @param int $uid 用户ID
|
|
|
* @param int $skn 商品skn
|
|
|
* @return array 接口返回的数据
|
|
|
*/
|
|
|
const cartProductData = (uid, skn) => {
|
|
|
|
|
|
let param = {
|
|
|
method: 'app.product.data',
|
|
|
product_skn: skn,
|
|
|
showcomment: 'N',
|
|
|
uid: uid
|
|
|
};
|
|
|
|
|
|
return api.get('', param);
|
|
|
};
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取加价购商品详情数据
|
|
|
*
|
|
|
* @param int $skn 商品skn
|
|
|
* @param int $promotionId 加价购商品促销ID
|
|
|
* @return array 接口返回的数据
|
|
|
*/
|
|
|
const giftProductData = (skn, promotionId) => {
|
|
|
|
|
|
let param = {
|
|
|
method: 'app.product.gift',
|
|
|
product_skn: skn,
|
|
|
promotion_id: promotionId
|
|
|
};
|
|
|
|
|
|
return api.get('', param);
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 增减购物车商品数量
|
|
|
*
|
...
|
...
|
@@ -221,160 +182,6 @@ const modifyProductNum = (uid, sku, increaseNum, decreaseNum, shoppingKey) => { |
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 修改购物车商品数据
|
|
|
*
|
|
|
* @param int $uid 用户ID
|
|
|
* @param string $swapData 商品数据
|
|
|
* @param string $shoppingKey 未登录用户唯一识别码
|
|
|
* @return array 接口返回的数据
|
|
|
*/
|
|
|
const modifyCartProduct = (uid, swapData, shoppingKey) => {
|
|
|
|
|
|
let param = {
|
|
|
method: 'app.Shopping.swap',
|
|
|
swap_data: swapData
|
|
|
};
|
|
|
|
|
|
if (uid) {
|
|
|
param.uid = uid;
|
|
|
}
|
|
|
if (shoppingKey) {
|
|
|
param.shopping_key = shoppingKey;
|
|
|
}
|
|
|
|
|
|
return api.get('', param);
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 购物车结算
|
|
|
*
|
|
|
* @param int $uid 用户ID
|
|
|
* @param string $cartType 购物车类型,ordinary表示普通, advance表示预售
|
|
|
* @param int $isUseYohoCoin 是否使用有货币,默认0不使用, 1使用
|
|
|
* @return array 接口返回的数据
|
|
|
*/
|
|
|
const cartPay = (uid, cartType, isUseYohoCoin) => {
|
|
|
|
|
|
let param = {
|
|
|
method: 'app.Shopping.payment',
|
|
|
cart_type: cartType,
|
|
|
yoho_coin_mode: isUseYohoCoin || 0,
|
|
|
uid: uid
|
|
|
};
|
|
|
|
|
|
if (_.indexOf(['ordinary', 'advance'], cartType) === -1) {
|
|
|
return {
|
|
|
code: 400,
|
|
|
message: '购物车参数类型有误!',
|
|
|
data: {}
|
|
|
};
|
|
|
}
|
|
|
|
|
|
return api.get('', param);
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 购物车结算--支付方式和配送方式选择
|
|
|
*
|
|
|
* @param int $uid 用户ID
|
|
|
* @param string $cartType 购物车类型,ordinary表示普通, advance表示预售
|
|
|
* @param int $deliveryWay 配送方式,1表示普通快递,2表示顺丰速运
|
|
|
* @param int $paymentType 支付方式,1表示在线支付,2表示货到付款
|
|
|
* @param string $couponCode 优惠券码
|
|
|
* @param string $promotionCode 优惠码
|
|
|
* @param mixed $yohoCoin 使用的有货币数量
|
|
|
* @param int $redEnvelopes 红包
|
|
|
* @return array 接口返回的数据
|
|
|
*/
|
|
|
const orderCompute = (uid, cartType, deliveryWay, paymentType, couponCode, promotionCode, yohoCoin, redEnvelopes) =>{
|
|
|
|
|
|
let param = {
|
|
|
method: 'app.Shopping.compute',
|
|
|
cart_type: cartType,
|
|
|
delivery_way: deliveryWay,
|
|
|
payment_type: paymentType,
|
|
|
check_yohocoin_amount: 'Y', // 控制是否判断有货币超出订单金额
|
|
|
uid: uid
|
|
|
};
|
|
|
|
|
|
if (_.indexOf(['ordinary', 'advance'], cartType) === -1) {
|
|
|
return {
|
|
|
code: 400,
|
|
|
message: '购物车参数类型有误!',
|
|
|
data: {}
|
|
|
};
|
|
|
}
|
|
|
|
|
|
if (couponCode) {
|
|
|
param.coupon_code = couponCode;
|
|
|
}
|
|
|
if (promotionCode) {
|
|
|
param.promotion_code = promotionCode;
|
|
|
}
|
|
|
if (yohoCoin) {
|
|
|
param.use_yoho_coin = yohoCoin;
|
|
|
}
|
|
|
if (redEnvelopes) {
|
|
|
param.use_red_envelopes = redEnvelopes;
|
|
|
}
|
|
|
|
|
|
return api.get('', param);
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 购物车结算--使用优惠券
|
|
|
*
|
|
|
* @param int $uid 用户ID
|
|
|
* @param string $couponCode 优惠券代码
|
|
|
* @return array 接口返回的数据
|
|
|
*/
|
|
|
const searchCoupon = (uid, couponCode) => {
|
|
|
|
|
|
let param = {
|
|
|
method: 'app.Shopping.useCoupon',
|
|
|
coupon_code: couponCode,
|
|
|
uid: uid
|
|
|
};
|
|
|
|
|
|
return api.get('', param);
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 购物车结算--获取优惠券列表
|
|
|
*
|
|
|
* @param int $uid 用户ID
|
|
|
* @return array 接口返回的数据
|
|
|
*/
|
|
|
const getCouponList = (uid, limit) => {
|
|
|
|
|
|
let param = {
|
|
|
method: 'app.coupons.lists',
|
|
|
type: 'notuse',
|
|
|
page: 1,
|
|
|
limit: limit || 10,
|
|
|
uid: uid
|
|
|
};
|
|
|
|
|
|
return api.get('', param);
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 购物车结算--获取用户可用和不可用的优惠券列表
|
|
|
*
|
|
|
* @param int $uid 用户ID
|
|
|
* @return array 接口返回的数据
|
|
|
*/
|
|
|
const getListCoupon = (uid) => {
|
|
|
|
|
|
let param = {
|
|
|
method: 'app.Shopping.listCoupon',
|
|
|
uid: uid
|
|
|
};
|
|
|
|
|
|
return api.get('', param);
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 购物车数量
|
|
|
*
|
|
|
* @param int $uid 用户ID
|
...
|
...
|
@@ -417,103 +224,11 @@ const togetherProduct = (page) => { |
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 浏览记录数据
|
|
|
*
|
|
|
* @param int $uid 用户ID
|
|
|
* @param int $udid 客户端唯一标识
|
|
|
* @param int $page 第几页,默认为1
|
|
|
* @param int $limit 限制多少条,默认100
|
|
|
* @return array 接口返回的数据
|
|
|
*/
|
|
|
const browseRecord = (uid, udid, page, limit) => {
|
|
|
|
|
|
let param = {
|
|
|
method: 'app.browse.product',
|
|
|
uid: uid,
|
|
|
udid: udid,
|
|
|
page: page || 1,
|
|
|
limit: limit || 10
|
|
|
};
|
|
|
|
|
|
return api.get('', param);
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 通过搜索查询商品信息
|
|
|
*
|
|
|
* 备注:因默认的搜索方法会有过滤, 浏览记录不需要过滤
|
|
|
*
|
|
|
* @param string $query 查询的条件
|
|
|
* @param int $limit 查询的限制数
|
|
|
* @return array
|
|
|
*/
|
|
|
const browseRecordFromSearch = (query, limit) => {
|
|
|
|
|
|
let param = {
|
|
|
method: 'web.search.search',
|
|
|
order: 'shelve_time:desc',
|
|
|
page: 1,
|
|
|
viewNum: limit || 10,
|
|
|
query: query
|
|
|
};
|
|
|
|
|
|
return api.get('', param);
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 选择支付,校验时间间隔,插入数据
|
|
|
* @param string $uid
|
|
|
* @param string $orderCode
|
|
|
* @param int $payment 14:银联手机支付 15:支付宝手机 18:支付宝wap(wap) 19:微信支付 22:微信wap(wap) 26:QQ钱包手机支付
|
|
|
* @return type
|
|
|
*/
|
|
|
const savePrePayInfo = (uid, orderCode, payment) => {
|
|
|
|
|
|
let param = {
|
|
|
method: 'app.order.savePrePayInfo',
|
|
|
uid: uid,
|
|
|
orderCode: orderCode,
|
|
|
payment: payment
|
|
|
};
|
|
|
|
|
|
return api.get('', param);
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 电子票添加和查询
|
|
|
* @param int $uid 用户ID
|
|
|
* @param type int $productSku 产品sku
|
|
|
* @param type int $buyNumber 购买数量,范围1-4
|
|
|
* @param type int $yohoCoin 有货币
|
|
|
* @return type []
|
|
|
* 判断商品列表是否收藏情况
|
|
|
* @param uid
|
|
|
* @param pidList
|
|
|
* @returns {Promise.<T>}
|
|
|
*/
|
|
|
const addTicket = (uid, productSku, buyNumber, yohoCoin) => {
|
|
|
|
|
|
let param = {
|
|
|
method: 'app.shopping.ticket',
|
|
|
uid: Number(uid),
|
|
|
product_sku: Number(productSku),
|
|
|
buy_number: Number(buyNumber)
|
|
|
};
|
|
|
|
|
|
// 有货币转换成元,1有货币等于一分钱
|
|
|
if (yohoCoin && yohoCoin > 0) {
|
|
|
param.use_yoho_coin = yohoCoin / 100;
|
|
|
}
|
|
|
|
|
|
return api.get('', param).then(ret => {
|
|
|
// 展览票不显示区域,上面要求的。@高扬、@徐洪云,2016/7/6
|
|
|
if (ret && ret.data && ret.data.goods_list) {
|
|
|
_.forEach(() => {
|
|
|
// it.size_name = it.product_skn * 1 === EXHIBITION_TICKET ? '' : it.size_name;
|
|
|
// ret.data.goods_list[key] = it;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
return ret;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
const checkUserIsFavProductList = (uid, pidList) => {
|
|
|
|
|
|
pidList = _.isArray(pidList) ? pidList : [];
|
...
|
...
|
@@ -649,21 +364,9 @@ module.exports = { |
|
|
selectGoods,
|
|
|
removeFromCart,
|
|
|
addToFav,
|
|
|
cartProductData,
|
|
|
giftProductData,
|
|
|
modifyProductNum,
|
|
|
modifyCartProduct,
|
|
|
cartPay,
|
|
|
orderCompute,
|
|
|
searchCoupon,
|
|
|
getCouponList,
|
|
|
getListCoupon,
|
|
|
cartCount,
|
|
|
togetherProduct,
|
|
|
browseRecord,
|
|
|
browseRecordFromSearch,
|
|
|
savePrePayInfo,
|
|
|
addTicket,
|
|
|
checkUserIsFavProductList,
|
|
|
newPreference,
|
|
|
modifyProduct,
|
...
|
...
|
|