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

const api = global.yoho.API;

/**
 * 获取订单退货信息
 */
const getRefundGoodsAsync = (orderCode, uid) => {
    return api.get('', {
        method: 'app.refund.goodsList',
        order_code: orderCode,
        uid: uid
    }, {code: 200});
};

/**
 * 获取退货详情
 */
const getRefundDetailAsync = (id, uid) => {
    return api.get('', {
        method: 'app.refund.detail',
        id: id,
        uid: uid
    }, {code: 200});
};

/**
 * 获取换货详情
 */
const getChangeDetailAsync = (id, uid) => {
    return api.get('', {
        method: 'app.change.detail',
        id: id,
        uid: uid
    }, {code: 200});
};

/**
 * 获取订单换货信息
 */
const getExchangeGoodsAsync = (orderCode, uid) => {
    return api.get('', {
        method: 'app.change.goodsList',
        order_code: orderCode,
        uid: uid
    }, {code: 200});
};

/**
 * 获取商品信息
 */
const getProductDataAsync = (skn) => {
    return api.get('', {
        method: 'app.product.data',
        product_skn: skn
    }, {code: 200});
};

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

/**
 * 取消退货申请
 * @param $id
 * @param $uid
 * @return mixed
 */
const cancelRefundAsync = (id, uid) =>{

    let options = {
        method: 'app.refund.cancel',
        id: id,
        uid: uid
    };

    return api.post('', options);
};

/**
 * 取消换货申请
 * @param $id
 * @param $uid
 * @return mixed
 */
const cancelChangeAsync = (id, uid) =>{

    let options = {
        method: 'app.change.cancel',
        id: id,
        uid: uid
    };

    return api.post('', options);
};

/**
 * 设置快递
 * @param $id
 * @param $expressId
 * @param $expressNumber
 * @param $uid
 * @param $expressCompany
 * @param $isChange
 * @return mixed
 */
const setExpressNumberAsync = (id, expressId, expressNumber, uid, expressCompany, isChange) =>{

    let options = {
        method: isChange ? 'app.change.setexpress' : 'app.refund.setexpress',
        id: id,
        express_id: expressId,
        express_number: expressNumber,
        uid: uid,
        express_company: expressCompany
    };

    return api.post('', options);
};

/**
 * save退货申请
 * @param $orderCode
 * @param $uid
 * @param $goods
 * @param $payment
 * @return mixed
 */
const refundSubmit = (orderCode, uid, goods, payment) =>{

    let options = {
        method: 'app.refund.submit',
        order_code: orderCode,
        uid: uid,
        goods: goods,
        payment: payment
    };

    return api.post('', options);
};

/**
 * save换货申请
 * @param $orderCode
 * @param $goods
 * @param $consigneeName
 * @param $areaCode
 * @param $address
 * @param $mobile
 * @param $zipCode
 * @param $deliveryType
 * @param $uid
 * @return mixed
 */
const exchangeSubmit = (orderCode, goods, consigneeName, areaCode, address, mobile, zipCode, deliveryType, uid) =>{

    let options = {
        method: 'app.change.submit',
        order_code: orderCode,
        uid: uid,
        goods: goods,
        consignee_name: consigneeName,
        area_code: areaCode,
        address: address,
        mobile: mobile,
        zip_code: zipCode,
        delivery_tpye: deliveryType
    };

    return api.post('', options);
};

/**
 * 获取换货方式
 * @param $uid
 * @param $areaCode
 * @param $gender
 * @param $yhChannel
 * @return mixed
 */
const getDeliveryAsync = (areaCode, uid, gender, channel) => {

    let options = {
        method: 'app.change.getDelivery',
        uid: uid,
        area_code: areaCode,
        gender: gender,
        yh_channel: channel
    };

    return api.post('', options);
};


/**
 * 发送站内信
 * @param int $uid
 * @param string $title
 * @param int $content
 * @param int $type
 * @param string $verify_key
 * @param int $send_uid
 * @param string $call_back
 * @return array
 */
const sendMessage = (uid, title, content, type, verifyKey, sendUid) =>{

    let options = {
        method: 'web.inbox.setSingleMessage',
        uid: uid,
        send_uid: sendUid || 0,
        verify_key: verifyKey || '',
        content: content,
        title: title,
        type: type || 1
    };

    return api.post('', options);
};

module.exports = {
    getRefundGoodsAsync,
    refundSubmit,
    exchangeSubmit,
    sendMessage,
    getRefundDetailAsync,
    getExchangeGoodsAsync,
    getChangeDetailAsync,
    getProductDataAsync,
    getExpressCompanyAsync,
    cancelRefundAsync,
    cancelChangeAsync,
    getDeliveryAsync,
    setExpressNumberAsync
};