"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.StartPayFailure = exports.PayUnRefundable = exports.RefundExceedMax = exports.ExternalPayUtilException = exports.UploadShipException = exports.settlePlanExceed = exports.refundOpersExceed = exports.refundOpersNotEnough = void 0; exports.makeException = makeException; const tslib_1 = require("tslib"); const types_1 = require("oak-domain/lib/types"); const DependentExceptions_1 = tslib_1.__importDefault(require("./DependentExceptions")); /** * 退款时级联创建的opers的price总和小于本次退款金额-订单未结算金额 */ class refundOpersNotEnough extends types_1.OakException { price; //opers需增加的金额 显示为负数 constructor(price, message, _module, params) { super(message || 'error::refund.create.opersNotEnough', _module || 'oak-pay-business', params); this.price = price; } getSerialData() { const data = super.getSerialData(); return { ...data, price: this.price, }; } } exports.refundOpersNotEnough = refundOpersNotEnough; /** * 退款时级联创建的opers的price总和大于订单已结算金额 */ class refundOpersExceed extends types_1.OakException { price; //opers需减少的金额 constructor(price, message, _module, params) { super(message || 'error::settlePlan.create.opersExceed', _module || 'oak-pay-business', params); this.price = price; } getSerialData() { const data = super.getSerialData(); return { ...data, price: this.price, }; } } exports.refundOpersExceed = refundOpersExceed; /** * 退款时settlePlan金额超出order可计划结算金额 */ class settlePlanExceed extends types_1.OakException { price; //超出的可结算金额 显示为负数 constructor(price, message, _module, params) { super(message || 'error::settlePlan.exceed', _module || 'oak-pay-business', params); this.price = price; } getSerialData() { const data = super.getSerialData(); return { ...data, price: this.price, }; } } exports.settlePlanExceed = settlePlanExceed; class UploadShipException extends types_1.OakException { reason; constructor(reason, message, _module, params) { super(message || 'error::ship.uploadShipException', _module || 'oak-pay-business', params); this.reason = reason; } getSerialData() { const data = super.getSerialData(); return { ...data, reason: this.reason, }; } } exports.UploadShipException = UploadShipException; class ExternalPayUtilException extends types_1.OakException { reason; constructor(reason, message, _module, params) { super(message || 'error::pay.externalException', _module || 'oak-pay-business', params); this.reason = reason; } getSerialData() { const data = super.getSerialData(); return { ...data, reason: this.reason, }; } } exports.ExternalPayUtilException = ExternalPayUtilException; class RefundExceedMax extends types_1.OakException { constructor(message, _module, params) { super(message || 'error::refund.create.exceedMax', _module || 'oak-pay-business', params); } } exports.RefundExceedMax = RefundExceedMax; class PayUnRefundable extends types_1.OakException { constructor(message, _module, params) { super(message || 'error::refund.create.payUnrefundable', _module || 'oak-pay-business', params); } } exports.PayUnRefundable = PayUnRefundable; class StartPayFailure extends types_1.OakException { constructor(message, _module, params) { super(message, _module || 'oak-pay-business', params); } } exports.StartPayFailure = StartPayFailure; function makeException(msg) { const data = typeof msg === 'string' ? JSON.parse(msg) : msg; let exception = (0, DependentExceptions_1.default)(data); if (exception) { return exception; } const { name, message } = data; switch (name) { case 'ExternalPrePayException': { exception = new ExternalPayUtilException(data.reason, message); break; } case 'RefundExceedMax': { exception = new RefundExceedMax(message); break; } default: { break; } } if (exception) { exception.setOpRecords(data.opRecords); } return exception; }