refund.js 2.53 KB
/**
 * 退换货 Model
 * @type {Object}
 */

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

    getOrderData(uid, orderId) {
        return this.get({
            data: {
                method: 'app.refund.goodsList',
                uid: uid,
                order_code: orderId
            },
            param: {
                cache: true,
                code: 200
            }
        });
    }

    submitRefundData(uid, params) {
        return this.post({
            data: Object.assign({
                method: 'app.refund.submit',
                uid: uid,
            }, params)
        });
    }

    getExpressCompany() {
        return this.get({
            data: {
                method: 'app.express.getExpressCompany'
            },
            param: {
                code: 200
            }
        });
    }

    setexpress(applyid, uid, data) {
        const method = data.type === 'refund' ? 'app.refund.setexpress' : 'app.change.setexpress';

        return this.get({
            data: {
                method: method,
                id: applyid,
                uid: uid,
                express_company: data.expressCompany,
                express_number: data.expressNumber,
                express_id: data.expressId
            }
        });
    }

    getChangeDetail(id, uid) {
        return this.get({
            data: {
                method: 'app.change.detail',
                id: id,
                uid: uid,
            },
            param: {
                code: 200
            }
        });
    }

    getRefundDetail(id, uid) {
        return this.get({
            data: {
                method: 'app.refund.detail',
                id: id,
                uid: uid,
            },
            param: {
                code: 200
            }
        });
    }

    /**
     * 获取退换货列表
     * @param param
     *          method
     *          uid
     *          page
     *          limit
     *          app_type
     * @returns {Promise.<T>|*}
     */
    getRefundOrders(param) {
        param = Object.assign({
            method: 'app.refund.getList'
        }, param);

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

    /**
     * 取消退货申请
     *
     * @param uid 用户id
     * @param id 退货id
     */
    cancelRefundApply(uid, id) {
        return this.post({
            data: {
                uid: uid,
                id: id,
                method: 'app.refund.cancel'
            }
        });
    }
};