orders-api.js 903 Bytes
var $ = require('yoho-jquery');
var __cacheReason;


require('../../common/promise');

exports.getExpress = function(orderId, type, time) {
    return $.get('/home/orders/express', {
        orderId: orderId,
        payType: type,
        time: time
    });
};

exports.refund = function(orderId, reasonId, reason) {
    return $.get('/home/orders/refund', {
        orderId: orderId,
        reasonId: reasonId,
        reason: reason
    });
};

exports.refundReason = function() {
    return (function() {
        if (__cacheReason) {
            return $.resolve(__cacheReason);
        }

        return $.get('/home/orders/refundreason').then(function(result) {
            if (result.code !== 200) {
                return $.reject();
            }

            return (__cacheReason = result);
        });
    }()).then(function(result) {
        return {refundReason: result.data};
    });
};