
var ReturnOrderHelper = (function () {
    var f = {
        getReturnOrderCode: function (returnOrderId) {
            var now = new Date();
            var year = "" + now.getFullYear();
            var month = now.getMonth() + 1;
            var date = now.getDate();

            year = year.substring(2);
            month = month < 10 ? "0" + month : "" + month;
            date = date < 10 ? "0" + date : "" + date;

            var num = returnOrderId.replace("owl_return_order_", "");

            var code = year + month + date + num;

            return code;
        },
        getCloseStateName: function (jReturnOrder) {
            var state = jReturnOrder.close_state;
            if(state == "notyet") {
                return "待审批";
            }
            if(state == "pass") {
                return "审批通过";
            }
            if(state == "returning") {
                return "退货中";
            }
            if(state == "waitrefund") {
                return "待退款";
            }
            if(state == "refunding") {
                return "退款中";
            }
            if(state == "completed") {
                return "已完成";
            }
            if(state == "closed") {
                return "已取消";
            }
            return "";
        },
        addProcessLog: function (jReturnOrder, userId, userName, memo) {
            var process_memos = jReturnOrder.process_memos;
            if (!process_memos) {
                process_memos = [];
                jReturnOrder.process_memos = process_memos;
            }
            process_memos.push({
                time: new Date().getTime(),
                userId: userId,
                userName: userName,
                memo: memo
            });
        }
    }
    return f;
})();

