//#import $owl_mall_orderlog:services/modelService.jsx
//#import $owl_order_refund_log:services/modelService.jsx

var OrderLogUtil = (function () {
    var f = {
        addOrderLog: function (logType, order_id, order_code, before_state, after_state, userId, userName, remark, ip, user_agent) {
            try {
                var jLog = {};
                jLog.logType = logType;
                jLog.order_id = order_id;
                jLog.order_code = order_code;
                jLog.before_state = before_state;
                jLog.after_state = after_state;
                jLog.uid = userId;
                jLog.uname = userName;
                jLog.remark = remark;
                jLog.ip = ip;
                jLog.ua = user_agent;

                owl_mall_orderlogService.add(jLog);
            } catch (e) {
                $.log("owlService...OrderLogUtil.jsx...error=" + e);
            }
        },
        addRefundLog: function (refundOrderId, orderId, userId, execTime, remark, operatorUserId, operatorUserName) {
            try {
                var jLog = {};
                jLog.refund_order_id = refundOrderId;
                jLog.order_id = orderId;
                jLog.user_id = userId;
                jLog.state = "n";
                jLog.execTime = execTime;
                jLog.operatorUserId = operatorUserId;
                jLog.operatorUserName = operatorUserName;
                jLog.owl_createUserId = operatorUserId;
                jLog.remark = remark;

                return owl_order_refund_logService.add(jLog);
            } catch (e) {
                $.log("owlService...OrderLogUtil.jsx...error=" + e);
                return null;
            }
        },
        getRefundLogList: function (refundOrderId) {
            var searchArgs = {
                refund_order_id: refundOrderId
            }
            var searchResult = owl_order_refund_logService.search(null, searchArgs, null, 0, 10, [{"owl_createTime": {order: "desc"}}]);
            if (searchResult.state === 'ok') {
                return searchResult.list;
            }
            return [];
        }
    };
    return f;

})();
