returns-api.js 5.4 KB
 /**
 * 退换货API
 * @author: yyq<yanqing.yang@yoho.cn>
 * @date: 2016/7/19
 */
'use strict';

const api = global.yoho.API;

/**
 * 获取快递公司列表API
 * @function getExpressCompanyAsync
 * @return { Object } 快递公司列表
 */
const getExpressCompanyAsync = () => {
    return api.get('', {
        method: 'app.express.getExpressCompany'
    }, {code: 200});
};

/**
 * 获取订单信息API
 * @function getOrderInfoAsync
 * @param { number } orderCode 订单编号
 * @param { number } uid 用户uid
 * @param { string } sessionKey session
 * @return { Object } 订单信息
 */
const getOrderInfoAsync = (orderCode, uid, sessionKey) => {
    return api.get('', {
        method: 'app.SpaceOrders.info',
        order_code: orderCode,
        uid: uid,
        session_key: sessionKey
    }, {code: 200});
};

/**
 * 获取订单退货信息API
 * @function getRefundGoodsAsync
 * @param { number } orderCode 订单编号
 * @param { number } uid 用户uid
 * @return { Object } 订单退货信息
 */
const getRefundGoodsAsync = (orderCode, uid) => {
    return api.get('', {
        method: 'app.refund.goodsList',
        order_code: orderCode,
        uid: uid
    }, {code: 200});
};

/**
 * 获取退货详情信息API
 * @function getRefundDetailAsync
 * @param { number } applyId 退货申请id
 * @param { number } uid 用户uid
 * @return { Object } 退货详情信息
 */
const getRefundDetailAsync = (applyId, uid) => {
    return api.get('', {
        method: 'app.refund.detail',
        id: applyId,
        uid: uid
    }, {code: 200});
};

/**
 * 退货申请提交API
 * @function refundSubmitAsync
 * @param { number } orderCode 订单编号
 * @param { number } uid 用户uid
 * @param { Object } goods 退货商品信息
 * @param { Object } payment 退款信息
 * @return { Object } 退货申请结果
 */
const refundSubmitAsync = (orderCode, uid, goods, payment) => {
    return api.get('', {
        method: 'app.refund.submit',
        order_code: orderCode,
        uid: uid,
        goods: JSON.stringify(goods),
        payment: JSON.stringify(payment)
    }, {code: 200});
};

/**
 * 获取换货商品信息API
 * @function getChangeGoodsListAsync
 * @param { number } orderCode 订单编号
 * @param { number } uid 用户uid
 * @return { Object } 换货商品信息
 */
const getChangeGoodsListAsync = (orderCode, uid) => {
    return api.get('', {
        method: 'app.change.goodsList',
        order_code: orderCode,
        uid: uid
    });
};

/**
 * 获取商品信息API
 * @function getProductInfoAsync
 * @param { number } productId 商品id
 * @param { number } productSkn 商品skn
 * @return { Object } 商品信息
 */
const getProductInfoAsync = (productId, productSkn) => {
    return api.get('', {
        method: 'app.product.data',
        product_id: productId,
        product_skn: productSkn
    });
};

/**
 * 获取换货详情API
 * @function getExchangeDetail
 * @param { number } id 收藏id
 * @param { number } uid 用户uid
 * @return { Object } 换货详情
 */
const getExchangeDetail = (id, uid) => {
    return api.get('', {
        method: 'app.change.detail',
        id: id,
        uid: uid
    });
};

/**
 * 换货申请提交API
 * @function changeSubmitAsync
 * @param { number } data 换货信息
 * @param { number } uid 用户uid
 * @return { Object } 换货申请结果
 */
const changeSubmitAsync = (data, uid) => {
    const requestData = Object.assign(data, {
        method: 'app.change.submit',
        uid: uid,
        goods: JSON.stringify(data.goods)
    });

    return api.get('', requestData);
};

/**
 * 设置寄回快递信息API
 * @function setExpressNumberAsync
 * @param { number } uid 用户uid
 * @param { number } param 寄回快递信息
 * @param { boolean } isChange 是否换货 true--换货 false--退货
 * @return { Object } 设置快递结果
 */
const setExpressNumberAsync = (uid, param, isChange) => {
    return api.post('', {
        method: isChange ? 'app.change.setexpress' : 'app.refund.setexpress',
        uid: uid,
        id: param.id,
        express_id: param.companyId,
        express_number: param.number,
        express_company: param.companyName
    });
};

/**
 * 取消退换货API
 * @function cancelReturnAsync
 * @param { number } id 收藏id
 * @param { number } uid 用户uid
 * @param { boolean } isChange 是否换货 true--换货 false--退货
 * @return { Object } 取消结果
 */
const cancelReturnAsync = (id, uid, isChange) => {
    return api.post('', {
        method: isChange ? 'app.change.cancel' : 'app.refund.cancel',
        id: id,
        uid: uid
    });
};

/**
 * 获取退货银行列表API
 * @function getRefundBank
 * @return { Object } 银行列表信息
 */
const getRefundBank = () => {
    return api.get('', {
        method: 'app.refund.refundBank'
    });
};


/**
 * 获取换货类型API
 * @param { number } uid 用户uid
 * @param { number } areaCode 地区码
 * @return { Object } 换货类型
 */
const getChangeTypeAsync = (uid, areaCode) => {
    return api.get('', {
        method: 'app.change.getDelivery',
        uid: uid,
        area_code: areaCode
    }, {
        code: 200
    });
};

module.exports = {
    getExpressCompanyAsync,
    getOrderInfoAsync,
    getRefundGoodsAsync,
    getChangeGoodsListAsync,
    getProductInfoAsync,
    getRefundDetailAsync,
    refundSubmitAsync,
    getExchangeDetail,
    changeSubmitAsync,
    setExpressNumberAsync,
    cancelReturnAsync,
    getRefundBank,
    getChangeTypeAsync
};