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

module.exports = class extends global.yoho.BaseModel {
    constructor(ctx) {
        super(ctx);
    }

    /**
     * 获取订单退货信息
     */
    getRefundGoodsAsync(orderCode, uid) {
        let options = {
            method: 'app.refund.goodsList',
            order_code: orderCode,
            uid: uid
        };

        return this.get({data: options, param: {code: 200}});
    }

    /**
     * 获取退货详情
     */
    getRefundDetailAsync(id, uid) {
        let options = {
            method: 'app.refund.detail',
            id: id,
            uid: uid
        };

        return this.get({data: options, param: {code: 200}});
    }

    /**
     * 获取换货详情
     */
    getChangeDetailAsync(id, uid) {
        let options = {
            method: 'app.change.detail',
            id: id,
            uid: uid
        };

        return this.get({data: options, param: {code: 200}});
    }

    /**
     * 获取订单换货信息
     */
    getExchangeGoodsAsync(orderCode, uid) {
        let options = {
            method: 'app.change.goodsList',
            order_code: orderCode,
            uid: uid
        };

        return this.get({data: options, param: {code: 200}});
    }

    /**
     * 获取商品信息
     */
    getProductDataAsync(skn) {
        let options = {
            method: 'app.product.data',
            product_skn: skn
        };

        return this.get({data: options, param: {code: 200}});
    }

    /**
     * 快递公司列表
     */
    getExpressCompanyAsync() {
        let options = {
            method: 'app.express.getExpressCompany'
        };

        return this.get({data: options, param: {code: 200}});
    }

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

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

        return this.post({data: options});
    }

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

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

        return this.post({data: options});
    }

    /**
     * 设置快递
     * @param $id
     * @param $expressId
     * @param $expressNumber
     * @param $uid
     * @param $expressCompany
     * @param $isChange
     * @return mixed
     */
    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 this.post({data: options});
    }

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

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

        return this.post({data: options});
    }

    /**
     * save换货申请
     * @param $orderCode
     * @param $goods
     * @param $consigneeName
     * @param $areaCode
     * @param $address
     * @param $mobile
     * @param $zipCode
     * @param $deliveryType
     * @param $uid
     * @return mixed
     */
    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 this.post({data: options});
    }

    /**
     * 获取换货方式
     * @param $uid
     * @param $areaCode
     * @param $gender
     * @param $yhChannel
     * @return mixed
     */
    getDeliveryAsync(orderCode, areaCode, uid, skns) {
        skns = skns || [];

        let options = {
            method: 'app.change.refreshDelivery',
            uid: uid,
            order_code: orderCode,
            area_code: areaCode,
            skns: JSON.stringify(skns)
        };

        return this.post({data: 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
     */
    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 this.post({data: options});
    }

    /**
     * [退货结算]
     * @param  {[type]} uid       [uid]
     * @param  {[type]} orderCode [订单号]
     * @param  {[type]} goods     [商品详细]
     * @return {[type]}           [{}]
     */
    refundComputeAsync(uid, orderCode, goods) {
        let options = {
            method: 'app.refund.compute',
            order_code: orderCode,
            uid: uid,
            goods: goods
        };

        return this.get({data: options});
    }
};