settlePlan checker、trigger调整
This commit is contained in:
parent
64464d0b00
commit
db74dec6ac
|
|
@ -12,6 +12,7 @@ import withdrawAccounts from './withdrawAccount';
|
|||
import refundCheckers from './refund';
|
||||
import withdrawTransferCheckers from './withdrawTransfer';
|
||||
import shipCheckers from './ship';
|
||||
import settlePlanCheckers from './settlePlan';
|
||||
|
||||
const checkers = [
|
||||
...refundCheckers,
|
||||
|
|
@ -25,6 +26,7 @@ const checkers = [
|
|||
...wpProductCheckers,
|
||||
...withdrawTransferCheckers,
|
||||
...shipCheckers,
|
||||
...settlePlanCheckers,
|
||||
] as Checker<EntityDict, keyof EntityDict, RuntimeCxt>[];
|
||||
|
||||
export default checkers;
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ const checkers: Checker<EntityDict, 'settlePlan', RuntimeCxt>[] = [
|
|||
entity: 'settlePlan',
|
||||
action: 'create',
|
||||
type: 'logicalData',
|
||||
priority: 1,
|
||||
checker: (operation, context) => {
|
||||
const { data } = operation as EntityDict['settlePlan']['Create'];
|
||||
const checkfn = (settlePlan: EntityDict['settlePlan']['CreateOperationData']) => {
|
||||
|
|
@ -51,6 +52,16 @@ const checkers: Checker<EntityDict, 'settlePlan', RuntimeCxt>[] = [
|
|||
settlements!.forEach(
|
||||
(settlement) => amount += settlement.price
|
||||
);
|
||||
if (settlePlan.settlement$plan && settlePlan.settlement$plan.length > 0) {
|
||||
for (const settlementOper of settlePlan.settlement$plan) {
|
||||
const settlementData = settlementOper.data;
|
||||
if (settlementData instanceof Array) {
|
||||
settlementData.forEach((s) => amount += s.price ?? 0);
|
||||
} else {
|
||||
amount += settlementData?.price ?? 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
assert(amount === settlePlan.price!, '结算计划金额需等于关联的结算明细金额总和');
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ const triggers: Trigger<EntityDict, 'settlePlan', BRC>[] = [
|
|||
action: 'create',
|
||||
when: 'before',
|
||||
asRoot: true,
|
||||
priority: 99,
|
||||
fn: async ({ operation }, context, option) => {
|
||||
const { data } = operation;
|
||||
let count = 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue