122 lines
3.7 KiB
JavaScript
122 lines
3.7 KiB
JavaScript
import { OakException } from 'oak-domain/lib/types';
|
|
import makeDepedentException from './DependentExceptions';
|
|
/**
|
|
* 退款时级联创建的opers的price总和小于本次退款金额-订单未结算金额
|
|
*/
|
|
export class refundOpersNotEnough extends 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,
|
|
};
|
|
}
|
|
}
|
|
/**
|
|
* 退款时级联创建的opers的price总和大于订单已结算金额
|
|
*/
|
|
export class refundOpersExceed extends 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,
|
|
};
|
|
}
|
|
}
|
|
/**
|
|
* 退款时settlePlan金额超出order可计划结算金额
|
|
*/
|
|
export class settlePlanExceed extends 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,
|
|
};
|
|
}
|
|
}
|
|
export class UploadShipException extends 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,
|
|
};
|
|
}
|
|
}
|
|
export class ExternalPayUtilException extends 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,
|
|
};
|
|
}
|
|
}
|
|
export class RefundExceedMax extends OakException {
|
|
constructor(message, _module, params) {
|
|
super(message || 'error::refund.create.exceedMax', _module || 'oak-pay-business', params);
|
|
}
|
|
}
|
|
export class PayUnRefundable extends OakException {
|
|
constructor(message, _module, params) {
|
|
super(message || 'error::refund.create.payUnrefundable', _module || 'oak-pay-business', params);
|
|
}
|
|
}
|
|
export class StartPayFailure extends OakException {
|
|
constructor(message, _module, params) {
|
|
super(message, _module || 'oak-pay-business', params);
|
|
}
|
|
}
|
|
export function makeException(msg) {
|
|
const data = typeof msg === 'string' ? JSON.parse(msg) : msg;
|
|
let exception = makeDepedentException(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;
|
|
}
|