修正了一些数据结构,规范支付和退款时对account的计算
This commit is contained in:
parent
206eb3da64
commit
d757f0d572
|
|
@ -3,7 +3,7 @@ export declare function getWithdrawCreateData(params: {
|
|||
accountId: string;
|
||||
price: number;
|
||||
withdrawAccountId?: string;
|
||||
}, context: BRC): Promise<(Partial<Omit<import("../oak-app-domain/Withdraw/Schema").OpSchema, "accountId" | "creatorId">> & {
|
||||
}, context: BRC): Promise<(Partial<Omit<import("../oak-app-domain/Withdraw/Schema").OpSchema, "creatorId" | "accountId">> & {
|
||||
id: string;
|
||||
} & {
|
||||
accountId: string;
|
||||
|
|
@ -12,13 +12,13 @@ export declare function getWithdrawCreateData(params: {
|
|||
creatorId: string;
|
||||
creator?: import("../oak-app-domain/User/Schema").UpdateOperation | undefined;
|
||||
} & {
|
||||
refund$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "withdraw" | "withdrawId">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "withdraw" | "withdrawId">>)[] | undefined;
|
||||
sysAccountOper$withdraw?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/SysAccountOper/Schema").CreateOperationData, "withdraw" | "withdrawId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/SysAccountOper/Schema").CreateOperationData, "withdraw" | "withdrawId">>[] | undefined;
|
||||
withdrawTransfer$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/WithdrawTransfer/Schema").CreateOperationData, "withdraw" | "withdrawId">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/WithdrawTransfer/Schema").CreateOperationData, "withdraw" | "withdrawId">>)[] | undefined;
|
||||
modiEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/ModiEntity/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/ModiEntity/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
|
||||
operEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/OperEntity/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/OperEntity/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
|
||||
accountOper$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/AccountOper/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/AccountOper/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
|
||||
refund$entity?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "entity" | "entityId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "entity" | "entityId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "entity" | "entityId">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "entity" | "entityId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "entity" | "entityId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "entity" | "entityId">>)[] | undefined;
|
||||
}) | (Partial<Omit<import("../oak-app-domain/Withdraw/Schema").OpSchema, "accountId" | "creatorId">> & {
|
||||
}) | (Partial<Omit<import("../oak-app-domain/Withdraw/Schema").OpSchema, "creatorId" | "accountId">> & {
|
||||
id: string;
|
||||
} & {
|
||||
accountId: string;
|
||||
|
|
@ -27,13 +27,13 @@ export declare function getWithdrawCreateData(params: {
|
|||
creator?: undefined;
|
||||
creatorId: string;
|
||||
} & {
|
||||
refund$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "withdraw" | "withdrawId">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "withdraw" | "withdrawId">>)[] | undefined;
|
||||
sysAccountOper$withdraw?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/SysAccountOper/Schema").CreateOperationData, "withdraw" | "withdrawId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/SysAccountOper/Schema").CreateOperationData, "withdraw" | "withdrawId">>[] | undefined;
|
||||
withdrawTransfer$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/WithdrawTransfer/Schema").CreateOperationData, "withdraw" | "withdrawId">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/WithdrawTransfer/Schema").CreateOperationData, "withdraw" | "withdrawId">>)[] | undefined;
|
||||
modiEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/ModiEntity/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/ModiEntity/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
|
||||
operEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/OperEntity/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/OperEntity/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
|
||||
accountOper$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/AccountOper/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/AccountOper/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
|
||||
refund$entity?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "entity" | "entityId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "entity" | "entityId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "entity" | "entityId">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "entity" | "entityId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "entity" | "entityId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "entity" | "entityId">>)[] | undefined;
|
||||
}) | (Partial<Omit<import("../oak-app-domain/Withdraw/Schema").OpSchema, "accountId" | "creatorId">> & {
|
||||
}) | (Partial<Omit<import("../oak-app-domain/Withdraw/Schema").OpSchema, "creatorId" | "accountId">> & {
|
||||
id: string;
|
||||
} & {
|
||||
account?: undefined;
|
||||
|
|
@ -42,13 +42,13 @@ export declare function getWithdrawCreateData(params: {
|
|||
creatorId: string;
|
||||
creator?: import("../oak-app-domain/User/Schema").UpdateOperation | undefined;
|
||||
} & {
|
||||
refund$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "withdraw" | "withdrawId">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "withdraw" | "withdrawId">>)[] | undefined;
|
||||
sysAccountOper$withdraw?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/SysAccountOper/Schema").CreateOperationData, "withdraw" | "withdrawId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/SysAccountOper/Schema").CreateOperationData, "withdraw" | "withdrawId">>[] | undefined;
|
||||
withdrawTransfer$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/WithdrawTransfer/Schema").CreateOperationData, "withdraw" | "withdrawId">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/WithdrawTransfer/Schema").CreateOperationData, "withdraw" | "withdrawId">>)[] | undefined;
|
||||
modiEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/ModiEntity/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/ModiEntity/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
|
||||
operEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/OperEntity/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/OperEntity/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
|
||||
accountOper$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/AccountOper/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/AccountOper/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
|
||||
refund$entity?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "entity" | "entityId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "entity" | "entityId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "entity" | "entityId">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "entity" | "entityId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "entity" | "entityId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "entity" | "entityId">>)[] | undefined;
|
||||
}) | (Partial<Omit<import("../oak-app-domain/Withdraw/Schema").OpSchema, "accountId" | "creatorId">> & {
|
||||
}) | (Partial<Omit<import("../oak-app-domain/Withdraw/Schema").OpSchema, "creatorId" | "accountId">> & {
|
||||
id: string;
|
||||
} & {
|
||||
account?: undefined;
|
||||
|
|
@ -57,10 +57,10 @@ export declare function getWithdrawCreateData(params: {
|
|||
creator?: undefined;
|
||||
creatorId: string;
|
||||
} & {
|
||||
refund$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "withdraw" | "withdrawId">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "withdraw" | "withdrawId">>)[] | undefined;
|
||||
sysAccountOper$withdraw?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/SysAccountOper/Schema").CreateOperationData, "withdraw" | "withdrawId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/SysAccountOper/Schema").CreateOperationData, "withdraw" | "withdrawId">>[] | undefined;
|
||||
withdrawTransfer$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/WithdrawTransfer/Schema").CreateOperationData, "withdraw" | "withdrawId">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/WithdrawTransfer/Schema").CreateOperationData, "withdraw" | "withdrawId">>)[] | undefined;
|
||||
modiEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/ModiEntity/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/ModiEntity/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
|
||||
operEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/OperEntity/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/OperEntity/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
|
||||
accountOper$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/AccountOper/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/AccountOper/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
|
||||
refund$entity?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "entity" | "entityId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "entity" | "entityId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "entity" | "entityId">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "entity" | "entityId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "entity" | "entityId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "entity" | "entityId">>)[] | undefined;
|
||||
})>;
|
||||
|
|
|
|||
|
|
@ -137,14 +137,14 @@ export async function getWithdrawCreateData(params, context) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
data.refund$entity = await Promise.all(refundData.map(async (ele) => ({
|
||||
data.refund$withdraw = await Promise.all(refundData.map(async (ele) => ({
|
||||
id: await generateNewIdAsync(),
|
||||
action: 'create',
|
||||
data: ele,
|
||||
})));
|
||||
}
|
||||
else {
|
||||
data.refund$entity = [];
|
||||
data.refund$withdraw = [];
|
||||
}
|
||||
if (totalPrice > price2) {
|
||||
// 如果还有要退的部分,就从withdrawAccount来进行转账
|
||||
|
|
|
|||
|
|
@ -51,12 +51,14 @@ const checkers = [
|
|||
}
|
||||
break;
|
||||
}
|
||||
case 'refund':
|
||||
case 'withdraw': {
|
||||
if (totalPlus >= 0 || availPlus >= 0 || totalPlus !== availPlus) {
|
||||
throw new OakInputIllegalException('accountOper', ['availPlus'], 'accountOper为withdraw时,其totalPlus和availPlus必须为不相等的负数');
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'refundFailure':
|
||||
case 'withdrawBack': {
|
||||
if (totalPlus <= 0 || availPlus <= 0 || totalPlus !== availPlus) {
|
||||
throw new OakInputIllegalException('accountOper', ['availPlus'], 'accountOper为withdraw时,其totalPlus和availPlus必须为不相等的正数');
|
||||
|
|
@ -87,7 +89,7 @@ const checkers = [
|
|||
}
|
||||
break;
|
||||
}
|
||||
case 'tax': {
|
||||
case 'taxRefund': {
|
||||
if (totalPlus <= 0 || availPlus <= 0 || totalPlus !== availPlus) {
|
||||
throw new OakInputIllegalException('accountOper', ['totalPlus', 'availPlus'], 'accountOper为taxRefund时,其totalPlus/availPlus必须为正且相等');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import assert from 'assert';
|
||||
import { pipeline } from 'oak-domain/lib/utils/executor';
|
||||
const checkers = [
|
||||
{
|
||||
type: 'logical',
|
||||
|
|
@ -10,7 +12,45 @@ const checkers = [
|
|||
}
|
||||
data.paid = 0;
|
||||
data.refunded = 0;
|
||||
return 1;
|
||||
data.settled = false;
|
||||
}
|
||||
},
|
||||
{
|
||||
// 订单结算,将收入分帐到相关的Account中
|
||||
type: 'logical',
|
||||
entity: 'order',
|
||||
action: 'settle',
|
||||
checker: (operation, context) => {
|
||||
const { data, filter } = operation;
|
||||
assert(typeof filter.id === 'string');
|
||||
data.settled = true;
|
||||
return pipeline(() => context.select('order', {
|
||||
data: {
|
||||
id: 1,
|
||||
price: 1,
|
||||
paid: 1,
|
||||
refunded: 1,
|
||||
iState: 1,
|
||||
},
|
||||
filter: {
|
||||
id: filter.id,
|
||||
},
|
||||
}, {}), (orders) => {
|
||||
const [order] = orders;
|
||||
const { price, paid, refunded, iState } = order;
|
||||
assert(['paid', 'partiallyRefunded'].includes(iState));
|
||||
const { accountOper$entity: opers } = data;
|
||||
assert(opers instanceof Array);
|
||||
let amount = 0;
|
||||
opers.forEach(({ action, data }) => {
|
||||
assert(action === 'create');
|
||||
const { type, totalPlus, availPlus, refundablePlus } = data;
|
||||
assert(type === 'earn');
|
||||
assert(totalPlus === availPlus);
|
||||
amount += totalPlus;
|
||||
});
|
||||
assert(amount === paid - refunded);
|
||||
});
|
||||
}
|
||||
}
|
||||
];
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ declare const List: <T extends keyof EntityDict>(props: ReactComponentProps<Enti
|
|||
rowSelection?: any;
|
||||
hideHeader?: boolean | undefined;
|
||||
disableSerialNumber?: boolean | undefined;
|
||||
size?: "small" | "large" | "middle" | undefined;
|
||||
size?: "small" | "middle" | "large" | undefined;
|
||||
scroll?: ({
|
||||
x?: string | number | true | undefined;
|
||||
y?: string | number | undefined;
|
||||
|
|
@ -46,7 +46,7 @@ declare const ListPro: <T extends keyof EntityDict>(props: {
|
|||
tablePagination?: any;
|
||||
rowSelection?: any;
|
||||
disableSerialNumber?: boolean | undefined;
|
||||
size?: "small" | "large" | "middle" | undefined;
|
||||
size?: "small" | "middle" | "large" | undefined;
|
||||
scroll?: any;
|
||||
locale?: any;
|
||||
opWidth?: number | undefined;
|
||||
|
|
@ -58,14 +58,14 @@ declare const Detail: <T extends keyof EntityDict>(props: ReactComponentProps<En
|
|||
data: Partial<EntityDict[T]["Schema"]>;
|
||||
title?: string | undefined;
|
||||
bordered?: boolean | undefined;
|
||||
layout?: "vertical" | "horizontal" | undefined;
|
||||
layout?: "horizontal" | "vertical" | undefined;
|
||||
}>) => React.ReactElement;
|
||||
declare const Upsert: <T extends keyof EntityDict>(props: ReactComponentProps<EntityDict, T, false, {
|
||||
helps: Record<string, string>;
|
||||
entity: T;
|
||||
attributes: OakAbsAttrUpsertDef<EntityDict, T, string | number>[];
|
||||
data: EntityDict[T]["Schema"];
|
||||
layout: "vertical" | "horizontal";
|
||||
layout: "horizontal" | "vertical";
|
||||
mode: "default" | "card";
|
||||
}>) => React.ReactElement;
|
||||
export { FilterPanel, List, ListPro, Detail, Upsert, ReactComponentProps, ColumnProps, RowWithActions, OakExtraActionProps, OakAbsAttrDef, onActionFnDef, };
|
||||
|
|
|
|||
|
|
@ -6,15 +6,16 @@ export default function Render(props) {
|
|||
return (<List itemLayout="horizontal" dataSource={accountOpers} renderItem={(item, index) => {
|
||||
const { $$createAt$$, type, totalPlus, availPlus } = item;
|
||||
const plus = ToYuan(totalPlus || availPlus);
|
||||
const sign = plus > 0 ? '+' : '';
|
||||
const sign = plus > 0 ? '+' : '-';
|
||||
const num = Math.abs(plus);
|
||||
const d = dayjs($$createAt$$);
|
||||
return (<List.Item key={index}>
|
||||
<List.Item.Meta avatar={<Avatar>{t(`accountOper:v.type.${type}`).at(0)}</Avatar>} title={t(`accountOper:v.type.${type}`)} description={d.format('M月D日 HH时mm分')}/>
|
||||
<div style={{
|
||||
fontSize: 'x-large',
|
||||
color: sign ? 'gold' : 'rosybrown'
|
||||
color: sign === '+' ? 'gold' : 'rosybrown'
|
||||
}}>
|
||||
{sign}{ThousandCont(plus, 2)}
|
||||
{sign}{ThousandCont(num, 2)}
|
||||
</div>
|
||||
</List.Item>);
|
||||
}}/>);
|
||||
|
|
|
|||
|
|
@ -12,10 +12,25 @@ export default OakComponent({
|
|||
systemId: 1,
|
||||
price: 1,
|
||||
enabled: 1,
|
||||
taxLossRatio: 1,
|
||||
refundCompensateRatio: 1,
|
||||
refundGapDays: 1,
|
||||
allowWithdrawTransfer: 1,
|
||||
withdrawTransferLossRatio: 1,
|
||||
},
|
||||
properties: {
|
||||
systemId: '',
|
||||
},
|
||||
filters: [
|
||||
{
|
||||
filter() {
|
||||
const { systemId } = this.props;
|
||||
return {
|
||||
systemId,
|
||||
};
|
||||
}
|
||||
}
|
||||
],
|
||||
formData({ data, legalActions }) {
|
||||
return {
|
||||
accounts: data.map((ele) => {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,15 @@
|
|||
import React from 'react';
|
||||
import { EntityDict } from "../../../oak-app-domain";
|
||||
import { RowWithActions, WebComponentProps } from "oak-frontend-base";
|
||||
export declare function OfflineAccount(props: {
|
||||
data: RowWithActions<EntityDict, 'offlineAccount'> & {
|
||||
color: string;
|
||||
};
|
||||
t: (k: string, param?: any) => string;
|
||||
onUpdate?: () => void;
|
||||
onRemove?: () => void;
|
||||
onQrCodeClick?: () => void;
|
||||
}): React.JSX.Element;
|
||||
export default function render(props: WebComponentProps<EntityDict, 'offlineAccount', true, {
|
||||
accounts?: (RowWithActions<EntityDict, 'offlineAccount'> & {
|
||||
color: string;
|
||||
|
|
|
|||
|
|
@ -5,28 +5,33 @@ import Styles from './web.pc.module.less';
|
|||
import Upsert from '../upsert';
|
||||
import { OakAttrNotNullException, OakException } from 'oak-domain/lib/types';
|
||||
import { generateNewIdAsync } from 'oak-domain/lib/utils/uuid';
|
||||
function OfflineAccount(props) {
|
||||
const { account, t, onUpdate, onRemove, onQrCodeClick } = props;
|
||||
const { type, channel, name, qrCode, allowDeposit, allowPay, color, enabled, price } = account;
|
||||
const legalActions = account['#oakLegalActions'];
|
||||
return (<Descriptions style={{ width: 340, height: 435 }} title={t(`offlineAccount:v.type.${type}`)} extra={<>
|
||||
{legalActions.includes('update') && <Button style={{ marginRight: 4 }} size="small" onClick={() => onUpdate()}>
|
||||
import { ToYuan } from 'oak-domain/lib/utils/money';
|
||||
export function OfflineAccount(props) {
|
||||
const { data: account, t, onUpdate, onRemove, onQrCodeClick } = props;
|
||||
const { type, channel, name, qrCode, allowDeposit, allowPay, color, enabled, price, taxLossRatio, refundCompensateRatio, refundGapDays, allowWithdrawTransfer, withdrawTransferLossRatio } = account;
|
||||
return (<Descriptions style={{ width: 380 }} title={t(`offlineAccount:v.type.${type}`)} extra={<>
|
||||
{onUpdate && <Button style={{ marginRight: 4 }} size="small" onClick={() => onUpdate()}>
|
||||
{t('common::action.update')}
|
||||
</Button>}
|
||||
{legalActions.includes('remove') && <Button danger size="small" onClick={() => onRemove()}>
|
||||
{onRemove && <Button danger size="small" onClick={() => onRemove()}>
|
||||
{t('common::action.remove')}
|
||||
</Button>}
|
||||
</>} column={1} bordered size="small" labelStyle={{ width: 98 }}>
|
||||
</>} column={1} bordered size="small" labelStyle={{ width: 198 }}>
|
||||
<Descriptions.Item label={t('offlineAccount:attr.type')}>{t(`offlineAccount:v.type.${type}`)}</Descriptions.Item>
|
||||
{channel && <Descriptions.Item label={t(`offlineAccount::label.channel.${type}`)}>{channel}</Descriptions.Item>}
|
||||
{name && <Descriptions.Item label={t(`offlineAccount::label.name.${type}`)}>{name}</Descriptions.Item>}
|
||||
{qrCode && <Descriptions.Item label={t(`offlineAccount::label.qrCode.${type}`)}>
|
||||
{type === 'bank' ? qrCode : <span className={Styles.qrCode} onClick={onQrCodeClick}><QRCode value={qrCode} size={name ? 80 : 128} color={color}/></span>}
|
||||
</Descriptions.Item>}
|
||||
<Descriptions.Item label={t('offlineAccount:attr.price')}>{price}</Descriptions.Item>
|
||||
<Descriptions.Item label={t('offlineAccount:attr.allowDeposit')}>{t(`common::${allowDeposit}`)}</Descriptions.Item>
|
||||
<Descriptions.Item label={t('offlineAccount:attr.price')}>{ToYuan(price)}{t('common::pay.scale')}</Descriptions.Item>
|
||||
<Descriptions.Item label={t('offlineAccount:attr.allowPay')}>{t(`common::${allowPay}`)}</Descriptions.Item>
|
||||
<Descriptions.Item label={t('offlineAccount:attr.enabled')}>{t(`common::${enabled}`)}</Descriptions.Item>
|
||||
<Descriptions.Item label={t('offlineAccount:attr.taxLossRatio')}>{taxLossRatio}%</Descriptions.Item>
|
||||
<Descriptions.Item label={t('offlineAccount:attr.refundCompensateRatio')}>{refundCompensateRatio}%</Descriptions.Item>
|
||||
<Descriptions.Item label={t('offlineAccount:attr.refundGapDays')}>{refundGapDays}</Descriptions.Item>
|
||||
<Descriptions.Item label={t('offlineAccount:attr.taxLossRatio')}>{taxLossRatio}%</Descriptions.Item>
|
||||
<Descriptions.Item label={t('offlineAccount:attr.allowWithdrawTransfer')}>{t(`common::${allowWithdrawTransfer}`)}</Descriptions.Item>
|
||||
<Descriptions.Item label={t('offlineAccount:attr.withdrawTransferLossRatio')}>{withdrawTransferLossRatio}%</Descriptions.Item>
|
||||
</Descriptions>);
|
||||
}
|
||||
export default function render(props) {
|
||||
|
|
@ -63,7 +68,7 @@ export default function render(props) {
|
|||
{U}
|
||||
<div className={Styles.list}>
|
||||
{accounts.filter(ele => ele.$$createAt$$ > 1).map((ele, idx) => <div className={Styles.item} key={idx}>
|
||||
<OfflineAccount account={ele} t={t} onRemove={() => {
|
||||
<OfflineAccount data={ele} t={t} onRemove={ele['#oakLegalActions']?.includes('remove') ? () => {
|
||||
Modal.confirm({
|
||||
title: t('confirmDelete'),
|
||||
content: t('areYouSure'),
|
||||
|
|
@ -81,7 +86,7 @@ export default function render(props) {
|
|||
}
|
||||
]),
|
||||
});
|
||||
}} onUpdate={() => setUpsertId(ele.id)} onQrCodeClick={() => setShowQrCodeId(ele.id)}/>
|
||||
} : undefined} onUpdate={ele['#oakLegalActions']?.includes('update') ? () => setUpsertId(ele.id) : undefined} onQrCodeClick={() => setShowQrCodeId(ele.id)}/>
|
||||
</div>)}
|
||||
</div>
|
||||
<div className={Styles.btnBar}>
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-start;
|
||||
align-items: stretch;
|
||||
|
||||
.item {
|
||||
border: 0.1px solid silver;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ export default OakComponent({
|
|||
return {
|
||||
operation: operation && operation[0].operation,
|
||||
system: data,
|
||||
canUpdate: !!data?.['#oakLegalActions']?.includes('update'),
|
||||
};
|
||||
},
|
||||
actions: ['update'],
|
||||
});
|
||||
|
|
|
|||
|
|
@ -10,4 +10,5 @@ export default function render(props: WebComponentProps<EntityDict, 'system', fa
|
|||
system: RowWithActions<EntityDict, 'system'>;
|
||||
operation?: EntityDict['system']['Update'];
|
||||
serverUrl?: string;
|
||||
canUpdate?: boolean;
|
||||
}>): React.JSX.Element | null;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ function PayConfig(props) {
|
|||
const withdrawLoss = payConfig?.withdrawLoss;
|
||||
const depositLoss = payConfig?.depositLoss;
|
||||
const updateDepositLoss = (data) => {
|
||||
update({
|
||||
update && update({
|
||||
depositLoss: {
|
||||
...depositLoss,
|
||||
...data,
|
||||
|
|
@ -25,7 +25,7 @@ function PayConfig(props) {
|
|||
});
|
||||
};
|
||||
const updateWithdrawLoss = (data) => {
|
||||
update({
|
||||
update && update({
|
||||
depositLoss: depositLoss || {},
|
||||
withdrawLoss: {
|
||||
conservative: !!(withdrawLoss?.conservative),
|
||||
|
|
@ -40,7 +40,7 @@ function PayConfig(props) {
|
|||
</Popover>}>
|
||||
<Form labelCol={{ span: 8 }} wrapperCol={{ span: 18 }} layout="horizontal" style={{ width: '100%' }}>
|
||||
<Form.Item label={t('payConfig.label.ratio')}>
|
||||
<InputNumber value={depositLoss?.ratio} max={20} min={0.01} addonAfter={"%"} step={0.01} precision={2} onChange={(value) => {
|
||||
<InputNumber value={depositLoss?.ratio} max={20} min={0.01} addonAfter={"%"} step={0.01} precision={2} disabled={!update} onChange={(value) => {
|
||||
const ratio = value;
|
||||
updateDepositLoss({
|
||||
ratio: ratio || 0
|
||||
|
|
@ -48,7 +48,7 @@ function PayConfig(props) {
|
|||
}}/>
|
||||
</Form.Item>
|
||||
<Form.Item label={t('payConfig.label.highest')}>
|
||||
<InputNumber value={depositLoss?.highest} min={0} step={1} onChange={(value) => {
|
||||
<InputNumber value={depositLoss?.highest} min={0} step={1} disabled={!update} onChange={(value) => {
|
||||
const highest = value;
|
||||
updateDepositLoss({
|
||||
highest: highest || undefined
|
||||
|
|
@ -57,7 +57,7 @@ function PayConfig(props) {
|
|||
}}/>
|
||||
</Form.Item>
|
||||
<Form.Item label={t('payConfig.label.lowest')}>
|
||||
<InputNumber value={depositLoss?.lowest} min={0} step={1} onChange={(value) => {
|
||||
<InputNumber value={depositLoss?.lowest} min={0} step={1} disabled={!update} onChange={(value) => {
|
||||
const lowest = value;
|
||||
updateDepositLoss({
|
||||
lowest: lowest || undefined
|
||||
|
|
@ -72,12 +72,12 @@ function PayConfig(props) {
|
|||
</Popover>}>
|
||||
<Form labelCol={{ span: 8 }} wrapperCol={{ span: 18 }} layout="horizontal" style={{ width: '100%' }}>
|
||||
<Form.Item label={t('payConfig.label.conservative')}>
|
||||
<Switch value={withdrawLoss?.conservative} onChange={(conservative) => {
|
||||
<Switch disabled={!update} value={withdrawLoss?.conservative} onChange={(conservative) => {
|
||||
updateWithdrawLoss({ conservative });
|
||||
}}/>
|
||||
</Form.Item>
|
||||
<Form.Item label={t('payConfig.label.ratio')}>
|
||||
<InputNumber disabled={!!withdrawLoss?.conservative} value={withdrawLoss?.ratio} max={20} min={0.01} addonAfter={"%"} step={0.01} precision={2} onChange={(value) => {
|
||||
<InputNumber disabled={!!withdrawLoss?.conservative || !update} value={withdrawLoss?.ratio} max={20} min={0.01} addonAfter={"%"} step={0.01} precision={2} onChange={(value) => {
|
||||
const ratio = value;
|
||||
updateWithdrawLoss({
|
||||
ratio: ratio || 0
|
||||
|
|
@ -85,7 +85,7 @@ function PayConfig(props) {
|
|||
}}/>
|
||||
</Form.Item>
|
||||
<Form.Item label={t('payConfig.label.highest')}>
|
||||
<InputNumber disabled={!!withdrawLoss?.conservative} value={withdrawLoss?.highest} min={0} step={1} onChange={(value) => {
|
||||
<InputNumber disabled={!!withdrawLoss?.conservative || !update} value={withdrawLoss?.highest} min={0} step={1} onChange={(value) => {
|
||||
const highest = value;
|
||||
updateWithdrawLoss({
|
||||
highest: highest || undefined
|
||||
|
|
@ -94,7 +94,7 @@ function PayConfig(props) {
|
|||
}}/>
|
||||
</Form.Item>
|
||||
<Form.Item label={t('payConfig.label.lowest')}>
|
||||
<InputNumber disabled={!!withdrawLoss?.conservative} value={withdrawLoss?.lowest} min={0} step={1} onChange={(value) => {
|
||||
<InputNumber disabled={!!withdrawLoss?.conservative || !update} value={withdrawLoss?.lowest} min={0} step={1} onChange={(value) => {
|
||||
const lowest = value;
|
||||
updateWithdrawLoss({
|
||||
lowest: lowest || undefined
|
||||
|
|
@ -103,7 +103,7 @@ function PayConfig(props) {
|
|||
}}/>
|
||||
</Form.Item>
|
||||
<Form.Item label={t('payConfig.label.trim')}>
|
||||
<Radio.Group disabled={!!withdrawLoss?.conservative} options={[
|
||||
<Radio.Group disabled={!!withdrawLoss?.conservative || !update} options={[
|
||||
{
|
||||
label: t('payConfig.label.jiao'),
|
||||
value: 'jiao',
|
||||
|
|
@ -125,7 +125,7 @@ function PayConfig(props) {
|
|||
</Flex>);
|
||||
}
|
||||
export default function render(props) {
|
||||
const { system, oakFullpath, operation, oakDirty, serverUrl, oakExecutable } = props.data;
|
||||
const { system, oakFullpath, operation, oakDirty, serverUrl, oakExecutable, canUpdate } = props.data;
|
||||
const { t, update, clean, execute } = props.methods;
|
||||
if (system && oakFullpath) {
|
||||
return (<div className={Styles.container}>
|
||||
|
|
@ -136,7 +136,7 @@ export default function render(props) {
|
|||
</div>),
|
||||
key: 'system',
|
||||
children: (<Flex vertical>
|
||||
<PayConfig payConfig={system.payConfig} update={(payConfig) => update({ payConfig })} t={t}/>
|
||||
<PayConfig payConfig={system.payConfig} update={canUpdate ? (payConfig) => update({ payConfig }) : undefined} t={t}/>
|
||||
<Flex gap="middle" justify='end'>
|
||||
<Button type="primary" disabled={oakExecutable !== true} onClick={() => execute()}>
|
||||
{t('common::confirm')}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ export default OakComponent({
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
refreshData() {
|
||||
async refreshData() {
|
||||
const { entities, systemId } = this.props;
|
||||
const schema = this.features.cache.getSchema();
|
||||
uniq(['wpAccount', 'offlineAccount'].concat(entities || [])).forEach((entity) => {
|
||||
|
|
@ -32,6 +32,47 @@ export default OakComponent({
|
|||
}
|
||||
});
|
||||
});
|
||||
(async () => {
|
||||
const result = await this.features.cache.aggregate('account', {
|
||||
data: {
|
||||
'#count-1': {
|
||||
id: 1,
|
||||
},
|
||||
'#sum-1': {
|
||||
total: 1,
|
||||
},
|
||||
'#sum-2': {
|
||||
avail: 1,
|
||||
},
|
||||
},
|
||||
filter: {
|
||||
ofSystemId: systemId,
|
||||
}
|
||||
});
|
||||
const { '#count-1': accountNum, '#sum-1': accountTotalSum, '#sum-2': accountAvailSum } = result[0];
|
||||
this.setState({
|
||||
accountNum,
|
||||
accountTotalSum,
|
||||
accountAvailSum,
|
||||
});
|
||||
})();
|
||||
(async () => {
|
||||
const { data: [account] } = await this.features.cache.refresh('account', {
|
||||
data: {
|
||||
id: 1,
|
||||
total: 1,
|
||||
avail: 1,
|
||||
},
|
||||
filter: {
|
||||
entity: 'system',
|
||||
entityId: systemId,
|
||||
}
|
||||
});
|
||||
this.setState({
|
||||
systemAccountTotal: account.total,
|
||||
systemAccountAvail: account.avail,
|
||||
});
|
||||
})();
|
||||
},
|
||||
},
|
||||
formData({ features }) {
|
||||
|
|
@ -50,24 +91,28 @@ export default OakComponent({
|
|||
projection[ele] = 1;
|
||||
}
|
||||
});
|
||||
const [data] = this.features.cache.get(entity, {
|
||||
const data = this.features.cache.get(entity, {
|
||||
data: projection,
|
||||
filter: {
|
||||
systemId,
|
||||
}
|
||||
}, true);
|
||||
const { price, id } = data;
|
||||
total += price;
|
||||
return {
|
||||
entity,
|
||||
id,
|
||||
price,
|
||||
data,
|
||||
};
|
||||
});
|
||||
});
|
||||
data.forEach(ele => total += ele.price || 0);
|
||||
return data.map((ele) => {
|
||||
return {
|
||||
entity,
|
||||
data: {
|
||||
...ele,
|
||||
color: entity === 'offlineAccount' && features.style.getColor('offlineAccount', 'type', ele.type),
|
||||
}
|
||||
};
|
||||
});
|
||||
}).flat();
|
||||
return {
|
||||
total,
|
||||
accounts,
|
||||
systemId,
|
||||
};
|
||||
}
|
||||
},
|
||||
features: ['cache'],
|
||||
});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"sysAccount": "系统账户统计",
|
||||
"total": "总余额",
|
||||
"count": "账户个数",
|
||||
"qrCode": "二维码收款",
|
||||
"noDetailRender": "没有注入相应的详情渲染组件",
|
||||
"account": "业务账户统计",
|
||||
"accountNum": "账户个数",
|
||||
"accountTotalSum": "总账户余额",
|
||||
"accountAvailSum": "总账户可用余额",
|
||||
"systemAccountTotal": "本系统账户余额",
|
||||
"systemAccountAvail": "本系统账户可用余额"
|
||||
}
|
||||
|
|
@ -4,9 +4,14 @@ import React from 'react';
|
|||
export default function render(props: WebComponentProps<EntityDict, 'offlineAccount', false, {
|
||||
total?: number;
|
||||
accounts?: Array<{
|
||||
id: string;
|
||||
entity: string;
|
||||
data: any;
|
||||
price: number;
|
||||
}>;
|
||||
systemId?: string;
|
||||
accountNum?: number;
|
||||
accountTotalSum?: number;
|
||||
accountAvailSum?: number;
|
||||
systemAccountTotal?: number;
|
||||
systemAccountAvail?: number;
|
||||
}>): React.JSX.Element | null;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,154 @@
|
|||
import React from 'react';
|
||||
import { Descriptions, Tag, Modal, Flex, Button, Divider } from 'antd';
|
||||
import { AlipayOutlined, WechatOutlined } from '@ant-design/icons';
|
||||
import Styles from './web.pc.module.less';
|
||||
import { ThousandCont, ToYuan } from "oak-domain/lib/utils/money";
|
||||
import { OfflineAccount as OADetail } from '../../offlineAccount/config/web.pc';
|
||||
import { WpAccount as WADetail } from '../../wpAccount/config/web.pc';
|
||||
function OfflineAccount(props) {
|
||||
const { data, t } = props;
|
||||
const { type, channel, color, name } = data;
|
||||
switch (type) {
|
||||
case 'bank': {
|
||||
return (<Flex style={{ height: '100%' }} vertical gap="small" align="center" justify="center">
|
||||
<Tag>{t('offlineAccount:name')}</Tag>
|
||||
<div className={Styles.title}>{t(`offlineAccount:v.type.${type}`)}</div>
|
||||
<div className={Styles.subtitle}>{channel}</div>
|
||||
</Flex>);
|
||||
}
|
||||
case 'alipay': {
|
||||
return (<Flex style={{ height: '100%' }} vertical gap="small" align="center" justify="center">
|
||||
<Tag>{t('offlineAccount:name')}</Tag>
|
||||
<AlipayOutlined style={{ color, fontSize: 18 }}/>
|
||||
<div className={Styles.subtitle}>{name || t('qrCode')}</div>
|
||||
</Flex>);
|
||||
}
|
||||
case 'wechat': {
|
||||
return (<Flex style={{ height: '100%' }} vertical gap="small" align="center" justify="center">
|
||||
<Tag>{t('offlineAccount:name')}</Tag>
|
||||
<WechatOutlined style={{ color, fontSize: 18 }}/>
|
||||
<div className={Styles.subtitle}>{name || t('qrCode')}</div>
|
||||
</Flex>);
|
||||
}
|
||||
case 'shouqianba':
|
||||
case 'others': {
|
||||
return (<Flex style={{ height: '100%' }} vertical gap="small" align="center" justify="center">
|
||||
<Tag>{t('offlineAccount:name')}</Tag>
|
||||
<div className={Styles.title}>{t(`offlineAccount:v.type.${type}`)}</div>
|
||||
<div className={Styles.subtitle}>{name || t('qrCode')}</div>
|
||||
</Flex>);
|
||||
}
|
||||
}
|
||||
}
|
||||
function WpAccount(props) {
|
||||
const { data, t } = props;
|
||||
return (<Flex style={{ height: '100%' }} vertical gap="middle" align="center" justify="center">
|
||||
<Tag>{t('wpAccount:name')}</Tag>
|
||||
<WechatOutlined style={{ color: 'green', fontSize: 34 }}/>
|
||||
</Flex>);
|
||||
}
|
||||
function GeneralAccount(props) {
|
||||
const { entity, t } = props;
|
||||
return (<Flex style={{ height: '100%' }} vertical gap="small" align="center" justify="center">
|
||||
<Tag>{t(`${entity}:name`)}</Tag>
|
||||
</Flex>);
|
||||
}
|
||||
const RenderSysAccountCardTopDict = {
|
||||
'offlineAccount': OfflineAccount,
|
||||
'wpAccount': WpAccount,
|
||||
};
|
||||
const RenderSysAccountDetailDict = {
|
||||
'offlineAccount': OADetail,
|
||||
'wpAccount': WADetail,
|
||||
};
|
||||
export default function render(props) {
|
||||
const { accounts, total } = props.data;
|
||||
if (accounts) {
|
||||
const { accounts, total, systemId, accountNum, accountTotalSum, accountAvailSum, systemAccountAvail, systemAccountTotal, } = props.data;
|
||||
const { t, setMessage } = props.methods;
|
||||
if (accounts && systemId) {
|
||||
return (<div className={Styles.container}>
|
||||
{total}
|
||||
<Descriptions title={t('sysAccount')} bordered items={[
|
||||
{
|
||||
label: t('total'),
|
||||
children: <div className={Styles.total}>
|
||||
<span className={Styles.symbol}>{t('common::pay.symbol')}</span>
|
||||
<span className={Styles.value}>{ThousandCont(ToYuan(total || 0), 2)}</span>
|
||||
</div>
|
||||
},
|
||||
{
|
||||
label: t('count'),
|
||||
children: accounts.length,
|
||||
}
|
||||
]} column={2}/>
|
||||
<div className={Styles.sysAccounts}>
|
||||
{accounts.map(({ entity, data }, idx) => {
|
||||
const TopRender = RenderSysAccountCardTopDict[entity];
|
||||
return (<div className={Styles.sysAccount} key={idx}>
|
||||
<div className={Styles.top}>
|
||||
{TopRender ? <TopRender data={data} t={t}/> : <GeneralAccount entity={entity} t={t}/>}
|
||||
</div>
|
||||
<div className={Styles.middle}>
|
||||
<span className={Styles.symbol}>{t('common::pay.symbol')}</span>
|
||||
<span className={Styles.value}>{ThousandCont(ToYuan(data.price || 0), 2)}</span>
|
||||
</div>
|
||||
<div className={Styles.bottom}>
|
||||
<Button onClick={() => {
|
||||
const DetailRender = RenderSysAccountDetailDict[entity];
|
||||
if (DetailRender) {
|
||||
Modal.info({
|
||||
width: 560,
|
||||
title: `${t(`${entity}:name`)}${t('common::action.detail')}`,
|
||||
content: (<DetailRender data={data} systemId={systemId} t={t}/>),
|
||||
onOk() { },
|
||||
});
|
||||
}
|
||||
else {
|
||||
setMessage({
|
||||
title: t('noDetailRender'),
|
||||
type: 'error',
|
||||
});
|
||||
}
|
||||
}}>
|
||||
{t('common::action.detail')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>);
|
||||
})}
|
||||
</div>
|
||||
<Divider />
|
||||
{accountNum && <Descriptions title={t('account')} bordered items={[
|
||||
{
|
||||
label: t('accountTotalSum'),
|
||||
children: <div className={Styles.total}>
|
||||
<span className={Styles.symbol}>{t('common::pay.symbol')}</span>
|
||||
<span className={Styles.value}>{ThousandCont(ToYuan(accountTotalSum || 0), 2)}</span>
|
||||
</div>
|
||||
},
|
||||
{
|
||||
label: t('accountAvailSum'),
|
||||
children: <div className={Styles.total}>
|
||||
<span className={Styles.symbol}>{t('common::pay.symbol')}</span>
|
||||
<span className={Styles.value}>{ThousandCont(ToYuan(accountAvailSum || 0), 2)}</span>
|
||||
</div>
|
||||
},
|
||||
{
|
||||
label: t('accountNum'),
|
||||
children: accountNum,
|
||||
},
|
||||
{
|
||||
label: t('systemAccountTotal'),
|
||||
children: <div className={Styles.total}>
|
||||
<span className={Styles.symbol}>{t('common::pay.symbol')}</span>
|
||||
<span className={Styles.value}>{ThousandCont(ToYuan(systemAccountTotal || 0), 2)}</span>
|
||||
</div>
|
||||
},
|
||||
{
|
||||
label: t('systemAccountAvail'),
|
||||
children: <div className={Styles.total}>
|
||||
<span className={Styles.symbol}>{t('common::pay.symbol')}</span>
|
||||
<span className={Styles.value}>{ThousandCont(ToYuan(systemAccountAvail || 0), 2)}</span>
|
||||
</div>
|
||||
}
|
||||
]} column={3}/>}
|
||||
</div>);
|
||||
}
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -4,4 +4,64 @@
|
|||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
|
||||
.total {
|
||||
font-weight: bold;
|
||||
color: var(--oak-color-primary);
|
||||
|
||||
.symbol {
|
||||
margin-right: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
.sysAccounts {
|
||||
display: flex;
|
||||
padding: 8px;
|
||||
flex-wrap: wrap;
|
||||
margin-top: 12px;
|
||||
|
||||
.sysAccount {
|
||||
width: 244px;
|
||||
height: 284px;
|
||||
border: solid 0.1px silver;
|
||||
border-radius: 5px;
|
||||
margin-right: 14px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
|
||||
.top {
|
||||
height: 90px;
|
||||
|
||||
.title {
|
||||
font-size: larger;
|
||||
font-weight: bold;
|
||||
font-family: 黑体;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
color: var(--oak-text-color-disabled);
|
||||
font-size: smaller;
|
||||
}
|
||||
}
|
||||
|
||||
.middle {
|
||||
flex: 1;
|
||||
font-weight: bold;
|
||||
color: var(--oak-color-primary);
|
||||
font-size: large;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.bottom {
|
||||
padding: 10px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -34,7 +34,7 @@ export default OakComponent({
|
|||
return {
|
||||
withdrawCreate: withdrawData && {
|
||||
...withdrawData,
|
||||
refund$entity: withdrawData.refund$entity?.map((ele) => ele.data),
|
||||
refund$withdraw: withdrawData.refund$withdraw?.map((ele) => ele.data),
|
||||
withdrawTransfer$withdraw: withdrawData.withdrawTransfer$withdraw?.map((ele) => ele.data),
|
||||
},
|
||||
withdrawable,
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ export default OakComponent({
|
|||
iState: 1,
|
||||
reason: 1,
|
||||
meta: 1,
|
||||
refund$entity: {
|
||||
refund$withdraw: {
|
||||
$entity: 'refund',
|
||||
data: {
|
||||
id: 1,
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
.container {
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ export default OakComponent({
|
|||
},
|
||||
formData({ features }) {
|
||||
const { withdraw, create } = this.props;
|
||||
const { refund$entity: refundData, withdrawTransfer$withdraw: transferData } = withdraw;
|
||||
const { refund$withdraw: refundData, withdrawTransfer$withdraw: transferData } = withdraw;
|
||||
const refundData2 = (refundData)?.map((refund) => {
|
||||
const { meta, price, loss, iState, $$updateAt$$, reason } = refund;
|
||||
const { lossExplanation, channel } = meta;
|
||||
|
|
|
|||
|
|
@ -1 +1,8 @@
|
|||
{}
|
||||
{
|
||||
"usingComponents": {
|
||||
"l-loading": "@oak-frontend-base/miniprogram_npm/lin-ui/loading/index",
|
||||
"l-steps": "@oak-frontend-base/miniprogram_npm/lin-ui/steps/index",
|
||||
"l-step": "@oak-frontend-base/miniprogram_npm/lin-ui/step/index",
|
||||
"l-tag": "@oak-frontend-base/miniprogram_npm/lin-ui/tag/index"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,6 +57,13 @@
|
|||
font-size: small;
|
||||
border-top: solid 0.2rpx silver;
|
||||
|
||||
.header2 {
|
||||
width: 100%;
|
||||
padding: 4rpx;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.item {
|
||||
margin-top: 8rpx;
|
||||
display: flex;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
<view class="step">
|
||||
<l-steps active-index="{{step}}" dot="{{true}}">
|
||||
<l-step title="{{t('steps.first.title')}}" describe="{{createAt}}"></l-step>
|
||||
<l-step title="{{t('steps.second.title')}}" describe="{{t('method.v.' + withdrawMethod)}}"></l-step>
|
||||
<l-step title="{{t('steps.second.title')}}"></l-step>
|
||||
<l-step l-title-class="{{step === 2 ? (iState === 'failed' ? 'failed' : 'success') : ''}}"
|
||||
title="{{iState === 'failed' ? t('steps.third.failed') : (iState === 'partiallySuccessful' ? t('steps.third.partiallySuccess') : t('steps.third.success'))}}" ></l-step>
|
||||
</l-steps>
|
||||
|
|
@ -17,11 +17,14 @@
|
|||
<block wx:if="{{itemData}}">
|
||||
<view wx:for="{{itemData}}" wx:key="index" wx:for-item="data">
|
||||
<view class="refundItem">
|
||||
<view class="header2">
|
||||
<l-tag plain="{{true}}" size="mini" type="reading">{{data.type}}</l-tag>
|
||||
</view>
|
||||
<block wx:if="{{data.iState}}">
|
||||
<view class="item">
|
||||
<span class="label">{{t('refund:attr.iState')}}</span>
|
||||
<span class="vale">
|
||||
<l-tag bg-color="{{data.iStateColor}}">{{t('refund:v.iState.' + data.iState)}}</l-tag>
|
||||
<l-tag bg-color="{{data.iStateColor}}" size="mini" type="reading">{{t('refund:v.iState.' + data.iState)}}</l-tag>
|
||||
</span>
|
||||
</view>
|
||||
</block>
|
||||
|
|
|
|||
|
|
@ -19,6 +19,14 @@ export default OakComponent({
|
|||
},
|
||||
}
|
||||
],
|
||||
sorters: [{
|
||||
sorter: {
|
||||
$attr: {
|
||||
$$createAt$$: 1,
|
||||
},
|
||||
$direction: 'desc',
|
||||
}
|
||||
}],
|
||||
projection: {
|
||||
id: 1,
|
||||
price: 1,
|
||||
|
|
@ -26,7 +34,7 @@ export default OakComponent({
|
|||
loss: 1,
|
||||
dealLoss: 1,
|
||||
iState: 1,
|
||||
refund$entity$$aggr: {
|
||||
refund$withdraw$$aggr: {
|
||||
$entity: 'refund',
|
||||
data: {
|
||||
'#count-1': {
|
||||
|
|
@ -47,7 +55,7 @@ export default OakComponent({
|
|||
formData({ data }) {
|
||||
return {
|
||||
withdraws: data.map((ele) => {
|
||||
const { id, price, loss, dealPrice, dealLoss, iState, $$createAt$$, refund$entity$$aggr: refundAggr, withdrawTransfer$withdraw$$aggr: transferAggr } = ele;
|
||||
const { id, price, loss, iState, $$createAt$$, refund$withdraw$$aggr: refundAggr, withdrawTransfer$withdraw$$aggr: transferAggr } = ele;
|
||||
const count = (refundAggr?.[0]['#count-1'] || 0) + (transferAggr?.[0]['#count-1'] || 0);
|
||||
return {
|
||||
id,
|
||||
|
|
@ -61,9 +69,35 @@ export default OakComponent({
|
|||
}),
|
||||
};
|
||||
},
|
||||
data: {
|
||||
refreshing: false,
|
||||
},
|
||||
methods: {
|
||||
goBack() {
|
||||
this.navigateBack();
|
||||
}
|
||||
},
|
||||
goToDetailMp(e) {
|
||||
const { id } = e.currentTarget.dataset;
|
||||
const { gotoDetail } = this.props;
|
||||
gotoDetail && gotoDetail(id);
|
||||
},
|
||||
bindrefresherrefresh() {
|
||||
this.setState({
|
||||
refreshing: true
|
||||
});
|
||||
this.refresh();
|
||||
setTimeout(() => {
|
||||
this.setState({
|
||||
refreshing: false
|
||||
});
|
||||
}, 1000);
|
||||
},
|
||||
async loadMoreMp() {
|
||||
const { oakPagination, } = this.state;
|
||||
const { more } = oakPagination;
|
||||
if (more) {
|
||||
await this.loadMore();
|
||||
}
|
||||
},
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1 +1,9 @@
|
|||
{}
|
||||
{
|
||||
"usingComponents": {
|
||||
"l-loading": "@oak-frontend-base/miniprogram_npm/lin-ui/loading/index",
|
||||
"l-icon": "@oak-frontend-base/miniprogram_npm/lin-ui/icon/index",
|
||||
"l-button": "@oak-frontend-base/miniprogram_npm/lin-ui/button/index",
|
||||
"l-list": "@oak-frontend-base/miniprogram_npm/lin-ui/list/index",
|
||||
"oak-icon": "@oak-frontend-base/components/icon/index"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
.infoContainer {
|
||||
padding: 48rpx;
|
||||
background-color: #fff;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 40rpx;
|
||||
}
|
||||
|
||||
.backBtn {
|
||||
color: #333;
|
||||
border: 2rpx solid #eee;
|
||||
}
|
||||
|
||||
.myScroll {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.middle {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
justify-content: center;
|
||||
gap: 8rpx;
|
||||
padding: 16rpx;
|
||||
}
|
||||
|
||||
.tip {
|
||||
font-size: 28rpx;
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.price {
|
||||
font-size: 32rpx;
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
<block wx:if="{{withdraws && withdraws.length > 0}}">
|
||||
<scroll-view scroll-y bindscrolltolower="loadMoreMp" class="myScroll" refresher-enabled="{{true}}"
|
||||
bindrefresherrefresh="bindrefresherrefresh" refresher-triggered="{{refreshing}}">
|
||||
<view wx:for="{{withdraws}}" wx:key="id" style="background-color:#fff;">
|
||||
<l-list
|
||||
gap="{{16}}"
|
||||
tag-color="{{item.iStateColor}}"
|
||||
tag-content="{{item.iState}}"
|
||||
tag-position="right"
|
||||
bind:lintap="goToDetailMp"
|
||||
data-id="{{item.id}}"
|
||||
>
|
||||
<view slot="left-section" class="left">
|
||||
<oak-icon name="financial_fill" size="36" />
|
||||
<view class="middle">
|
||||
<view class="tip">{{item.lossDescription}}</view>
|
||||
<view class="price">{{t('common::pay.symbol')}} {{item.price}}</view>
|
||||
<view class="tip">{{item.createAt}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</l-list>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</block>
|
||||
<block wx:else>
|
||||
<view class="infoContainer">
|
||||
<l-icon size="64" name="warning" color="@oak-color-primary" />
|
||||
<view>{{t('noData')}}</view>
|
||||
<l-button
|
||||
bind:lintap="goBack"
|
||||
plain="true"
|
||||
l-class="backBtn"
|
||||
>
|
||||
{{t('common::back')}}
|
||||
</l-button>
|
||||
</view>
|
||||
</block>
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
/// <reference types="wechat-miniprogram" />
|
||||
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, "wpAccount", true, WechatMiniprogram.Component.DataOption>) => React.ReactElement;
|
||||
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, "wpAccount", true, {
|
||||
systemId: string;
|
||||
}>) => React.ReactElement;
|
||||
export default _default;
|
||||
|
|
|
|||
|
|
@ -5,14 +5,30 @@ export default OakComponent({
|
|||
id: 1,
|
||||
price: 1,
|
||||
mchId: 1,
|
||||
refundGapDays: 1,
|
||||
taxLossRatio: 1,
|
||||
enabled: 1,
|
||||
taxLossRatio: 1,
|
||||
refundCompensateRatio: 1,
|
||||
refundGapDays: 1,
|
||||
allowWithdrawTransfer: 1,
|
||||
withdrawTransferLossRatio: 1,
|
||||
},
|
||||
properties: {
|
||||
systemId: '',
|
||||
},
|
||||
filters: [
|
||||
{
|
||||
filter() {
|
||||
const { systemId } = this.props;
|
||||
return {
|
||||
systemId,
|
||||
};
|
||||
}
|
||||
}
|
||||
],
|
||||
formData({ data, legalActions }) {
|
||||
return {
|
||||
accounts: data,
|
||||
canCreate: legalActions?.includes('create'),
|
||||
canCreate: legalActions?.includes('create') && !data?.find(ele => ele.enabled),
|
||||
};
|
||||
},
|
||||
actions: ['create', 'update', 'remove'],
|
||||
|
|
|
|||
|
|
@ -1,6 +1,13 @@
|
|||
import React from 'react';
|
||||
import { EntityDict } from "../../../oak-app-domain";
|
||||
import { RowWithActions, WebComponentProps } from "oak-frontend-base";
|
||||
export declare function WpAccount(props: {
|
||||
data: RowWithActions<EntityDict, 'wpAccount'>;
|
||||
systemId: string;
|
||||
t: (k: string, param?: any) => string;
|
||||
onUpdate?: () => void;
|
||||
onRemove?: () => void;
|
||||
}): React.JSX.Element;
|
||||
export default function render(props: WebComponentProps<EntityDict, 'wpAccount', true, {
|
||||
accounts?: (RowWithActions<EntityDict, 'wpAccount'> & {})[];
|
||||
systemId: string;
|
||||
|
|
|
|||
|
|
@ -6,38 +6,46 @@ import Upsert from '../upsert';
|
|||
import WpProductConfig from '../../wpProduct/config';
|
||||
import { OakAttrNotNullException, OakException } from 'oak-domain/lib/types';
|
||||
import { generateNewIdAsync } from 'oak-domain/lib/utils/uuid';
|
||||
function WpAccount(props) {
|
||||
const { account, t, onUpdate, onRemove, oakFullpath, systemId } = props;
|
||||
const { refundGapDays, mchId, enabled, price, taxLossRatio } = account;
|
||||
const legalActions = account['#oakLegalActions'];
|
||||
import { ToYuan } from 'oak-domain/lib/utils/money';
|
||||
export function WpAccount(props) {
|
||||
const { data: account, t, onUpdate, onRemove, systemId } = props;
|
||||
const { refundGapDays, mchId, enabled, price, taxLossRatio, refundCompensateRatio, allowWithdrawTransfer, withdrawTransferLossRatio } = account;
|
||||
const [activeKey, setActiveKey] = useState("1");
|
||||
return (<Tabs activeKey={activeKey} onTabClick={(activeKey) => {
|
||||
setActiveKey(activeKey);
|
||||
}} tabBarExtraContent={activeKey === "1" && <>
|
||||
{legalActions.includes('update') && <Button style={{ marginRight: 4 }} size="small" onClick={() => onUpdate()}>
|
||||
{t('common::action.update')}
|
||||
</Button>}
|
||||
{legalActions.includes('remove') && <Button danger size="small" onClick={() => onRemove()}>
|
||||
{t('common::action.remove')}
|
||||
</Button>}
|
||||
</>} style={{ width: 380, height: 520 }} items={[
|
||||
{
|
||||
key: '1',
|
||||
label: t('common::action.detail'),
|
||||
children: (<Descriptions column={1} bordered size="small">
|
||||
<Descriptions.Item label={t('wpAccount:attr.mchId')}>{mchId}</Descriptions.Item>
|
||||
<Descriptions.Item label={t('wpAccount:attr.price')}>{price}</Descriptions.Item>
|
||||
<Descriptions.Item label={t('wpAccount:attr.refundGapDays')}>{refundGapDays}</Descriptions.Item>
|
||||
<Descriptions.Item label={t('wpAccount:attr.taxLossRatio')}>{taxLossRatio}%</Descriptions.Item>
|
||||
<Descriptions.Item label={t('wpAccount:attr.enabled')}>{t(`common::${enabled}`)}</Descriptions.Item>
|
||||
</Descriptions>)
|
||||
},
|
||||
{
|
||||
key: '2',
|
||||
label: t('wpProduct:name'),
|
||||
children: (<WpProductConfig oakPath={`$$wpProduct-${account.id}`} systemId={systemId} wpAccountId={account.id}/>)
|
||||
}
|
||||
]}/>);
|
||||
const D = (<Descriptions column={1} bordered title={t('wpAccount:name')} size="small">
|
||||
<Descriptions.Item label={t('wpAccount:attr.mchId')}>{mchId}</Descriptions.Item>
|
||||
<Descriptions.Item label={t('wpAccount:attr.price')}>{ToYuan(price)}{t('common::pay.scale')}</Descriptions.Item>
|
||||
<Descriptions.Item label={t('wpAccount:attr.taxLossRatio')}>{taxLossRatio}%</Descriptions.Item>
|
||||
<Descriptions.Item label={t('wpAccount:attr.refundCompensateRatio')}>{refundCompensateRatio}%</Descriptions.Item>
|
||||
<Descriptions.Item label={t('wpAccount:attr.refundGapDays')}>{refundGapDays}</Descriptions.Item>
|
||||
<Descriptions.Item label={t('wpAccount:attr.taxLossRatio')}>{taxLossRatio}%</Descriptions.Item>
|
||||
<Descriptions.Item label={t('wpAccount:attr.allowWithdrawTransfer')}>{t(`common::${allowWithdrawTransfer}`)}</Descriptions.Item>
|
||||
<Descriptions.Item label={t('wpAccount:attr.withdrawTransferLossRatio')}>{withdrawTransferLossRatio}%</Descriptions.Item>
|
||||
<Descriptions.Item label={t('wpAccount:attr.enabled')}>{t(`common::${enabled}`)}</Descriptions.Item>
|
||||
</Descriptions>);
|
||||
if (onUpdate) {
|
||||
return (<Tabs activeKey={activeKey} onTabClick={(activeKey) => {
|
||||
setActiveKey(activeKey);
|
||||
}} tabBarExtraContent={activeKey === "1" && <>
|
||||
{onUpdate && <Button style={{ marginRight: 4 }} size="small" onClick={() => onUpdate()}>
|
||||
{t('common::action.update')}
|
||||
</Button>}
|
||||
{onRemove && <Button danger size="small" onClick={() => onRemove()}>
|
||||
{t('common::action.remove')}
|
||||
</Button>}
|
||||
</>} style={{ width: 380, height: 520 }} items={[
|
||||
{
|
||||
key: '1',
|
||||
label: t('common::action.detail'),
|
||||
children: D,
|
||||
},
|
||||
{
|
||||
key: '2',
|
||||
label: t('wpProduct:name'),
|
||||
children: (<WpProductConfig oakPath={`$$wpProduct-${account.id}`} systemId={systemId} wpAccountId={account.id}/>)
|
||||
}
|
||||
]}/>);
|
||||
}
|
||||
return D;
|
||||
}
|
||||
export default function render(props) {
|
||||
const { accounts, oakFullpath, oakExecutable, canCreate, systemId } = props.data;
|
||||
|
|
@ -66,7 +74,7 @@ export default function render(props) {
|
|||
{U}
|
||||
<div className={Styles.list}>
|
||||
{accounts.filter(ele => ele.$$createAt$$ > 1).map((ele, idx) => <div className={Styles.item} key={idx}>
|
||||
<WpAccount oakFullpath={oakFullpath} systemId={systemId} account={ele} t={t} onRemove={() => {
|
||||
<WpAccount systemId={systemId} data={ele} t={t} onRemove={ele['#oakLegalActions']?.includes('remove') ? () => {
|
||||
Modal.confirm({
|
||||
title: t('confirmDelete'),
|
||||
content: t('areYouSure'),
|
||||
|
|
@ -84,7 +92,7 @@ export default function render(props) {
|
|||
}
|
||||
]),
|
||||
});
|
||||
}} onUpdate={() => setUpsertId(ele.id)}/>
|
||||
} : undefined} onUpdate={ele['#oakLegalActions']?.includes('update') ? () => setUpsertId(ele.id) : undefined}/>
|
||||
</div>)}
|
||||
</div>
|
||||
<div className={Styles.btnBar}>
|
||||
|
|
|
|||
|
|
@ -48,6 +48,8 @@ export default OakComponent({
|
|||
price: 0,
|
||||
enabled: true,
|
||||
taxLossRatio: 0.6,
|
||||
refundCompensateRatio: 100,
|
||||
allowWithdrawTransfer: false,
|
||||
});
|
||||
const { systemId } = this.props;
|
||||
const { data: [wechatPay] } = await this.features.cache.refresh('wechatPay', {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
"refundNotifyUrl": "endpoint",
|
||||
"apiV3Key": "需要登录商户后台获取",
|
||||
"refundGapDays": "超过这个天数后无法退款",
|
||||
"allowWithdrawTransfer": "开启转账允许后,提现时用户即可选择从此商户号提现到微信零钱,帐户需要开启此项能力",
|
||||
"allowWithdrawTransfer": "开启转账允许后,提现时用户即可选择从此商户号提现到微信零钱,微信商户必须要开启此项能力(当前尚未实现)",
|
||||
"withdrawTransferLossRatio": "渠道转账(提现)时收取的手续费百分比,0.6代表千分之六"
|
||||
},
|
||||
"wechatPayIsShared": "以上配置是全局的,请谨慎修改"
|
||||
|
|
|
|||
|
|
@ -167,6 +167,9 @@ const attrUpdateMatrix = {
|
|||
depositLossRatio: {
|
||||
actions: ['update'],
|
||||
},
|
||||
refundCompensateRatio: {
|
||||
actions: ['update'],
|
||||
},
|
||||
refundGapDays: {
|
||||
actions: ['update'],
|
||||
},
|
||||
|
|
|
|||
|
|
@ -329,6 +329,26 @@ const i18ns = [
|
|||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
id: "c014581e9b3508d49c8dc75b2c7f5730",
|
||||
namespace: "oak-pay-business-c-sysAccount-survey",
|
||||
language: "zh-CN",
|
||||
module: "oak-pay-business",
|
||||
position: "src/components/sysAccount/survey",
|
||||
data: {
|
||||
"sysAccount": "系统账户统计",
|
||||
"total": "总余额",
|
||||
"count": "账户个数",
|
||||
"qrCode": "二维码收款",
|
||||
"noDetailRender": "没有注入相应的详情渲染组件",
|
||||
"account": "业务账户统计",
|
||||
"accountNum": "账户个数",
|
||||
"accountTotalSum": "总账户余额",
|
||||
"accountAvailSum": "总账户可用余额",
|
||||
"systemAccountTotal": "本系统账户余额",
|
||||
"systemAccountAvail": "本系统账户可用余额"
|
||||
}
|
||||
},
|
||||
{
|
||||
id: "79255be8c093dfef9765b3f367cab553",
|
||||
namespace: "oak-pay-business-c-wechatPay-upsert",
|
||||
|
|
@ -525,7 +545,7 @@ const i18ns = [
|
|||
"refundNotifyUrl": "endpoint",
|
||||
"apiV3Key": "需要登录商户后台获取",
|
||||
"refundGapDays": "超过这个天数后无法退款",
|
||||
"allowWithdrawTransfer": "开启转账允许后,提现时用户即可选择从此商户号提现到微信零钱,帐户需要开启此项能力",
|
||||
"allowWithdrawTransfer": "开启转账允许后,提现时用户即可选择从此商户号提现到微信零钱,微信商户必须要开启此项能力(当前尚未实现)",
|
||||
"withdrawTransferLossRatio": "渠道转账(提现)时收取的手续费百分比,0.6代表千分之六"
|
||||
},
|
||||
"wechatPayIsShared": "以上配置是全局的,请谨慎修改"
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { String, Price } from 'oak-domain/lib/types/DataType';
|
|||
import { EntityShape } from 'oak-domain/lib/types/Entity';
|
||||
import { EntityDesc } from 'oak-domain/lib/types';
|
||||
import { Schema as Account } from './Account';
|
||||
type Type = 'deposit' | 'withdraw' | 'consume' | 'loan' | 'repay' | 'withdrawBack' | 'earn' | 'encash' | 'cutoffRefundable' | 'tax' | 'taxRefund';
|
||||
type Type = 'deposit' | 'withdraw' | 'consume' | 'loan' | 'repay' | 'withdrawBack' | 'earn' | 'encash' | 'cutoffRefundable' | 'tax' | 'taxRefund' | 'refund' | 'refundFailure';
|
||||
export interface Schema extends EntityShape {
|
||||
account: Account;
|
||||
type: Type;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,9 @@ export const entityDesc = {
|
|||
encash: '兑现',
|
||||
tax: '渠道费',
|
||||
taxRefund: '渠道费用退还',
|
||||
cutoffRefundable: '削减可自由退额度'
|
||||
cutoffRefundable: '削减可自由退额度',
|
||||
refund: '退款',
|
||||
refundFailure: '退款失败',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -43,6 +45,8 @@ export const entityDesc = {
|
|||
tax: '#A569BD',
|
||||
taxRefund: '#FF3333',
|
||||
cutoffRefundable: '#2E4053',
|
||||
refund: '#CC3333',
|
||||
refundFailure: '#009933',
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import { String, Price, Datetime } from 'oak-domain/lib/types/DataType';
|
||||
import { String, Price, Boolean, Datetime } from 'oak-domain/lib/types/DataType';
|
||||
import { EntityShape } from 'oak-domain/lib/types/Entity';
|
||||
import { EntityDesc, ActionDef } from 'oak-domain/lib/types';
|
||||
import { Schema as User } from 'oak-general-business/lib/entities/User';
|
||||
import { Schema as AccountOper } from './AccountOper';
|
||||
export interface Schema extends EntityShape {
|
||||
price: Price;
|
||||
paid: Price;
|
||||
|
|
@ -12,11 +13,13 @@ export interface Schema extends EntityShape {
|
|||
creator: User;
|
||||
entity: String<32>;
|
||||
entityId: String<64>;
|
||||
settled: Boolean;
|
||||
opers: AccountOper[];
|
||||
}
|
||||
export type IAction = 'startPaying' | 'payAll' | 'payPartially' | 'payNone' | 'timeout' | 'cancel' | 'startRefunding' | 'refundAll' | 'refundPartially' | 'refundNone';
|
||||
export type IState = 'paid' | 'unpaid' | 'timeout' | 'cancelled' | 'paying' | 'partiallyPaid' | 'paid' | 'refunding' | 'partiallyRefunded' | 'refunded';
|
||||
export declare const IActionDef: ActionDef<IAction, IState>;
|
||||
export type Action = IAction;
|
||||
export type Action = IAction | 'settle';
|
||||
export declare const entityDesc: EntityDesc<Schema, Action, '', {
|
||||
iState: IState;
|
||||
}>;
|
||||
|
|
|
|||
|
|
@ -40,6 +40,8 @@ export const entityDesc = {
|
|||
creator: '创建者',
|
||||
entity: '关联对象',
|
||||
entityId: '关联对象Id',
|
||||
settled: '是否结算',
|
||||
opers: '相关帐户操作'
|
||||
},
|
||||
action: {
|
||||
startPaying: '开始支付',
|
||||
|
|
@ -52,6 +54,7 @@ export const entityDesc = {
|
|||
refundAll: '完全退款',
|
||||
refundNone: '退款失败',
|
||||
refundPartially: '部分退款',
|
||||
settle: '结算',
|
||||
},
|
||||
v: {
|
||||
iState: {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ export const IActionDef = {
|
|||
startPaying: ['unpaid', 'paying'],
|
||||
succeedPaying: [['unpaid', 'paying'], 'paid'],
|
||||
close: [['unpaid', 'paying'], 'closed'],
|
||||
startRefunding: [['paid', 'partiallyRefunded', 'refunding'], 'refunding'],
|
||||
startRefunding: [['paid', 'partiallyRefunded'], 'refunding'],
|
||||
refundAll: [['paid', 'refunding', 'partiallyRefunded'], 'refunded'],
|
||||
refundPartially: [['paid', 'refunding', 'partiallyRefunded'], 'partiallyRefunded'],
|
||||
stopRefunding: ['refunding', 'paid'],
|
||||
|
|
|
|||
|
|
@ -3,9 +3,10 @@ import { EntityShape } from 'oak-domain/lib/types/Entity';
|
|||
import { EntityDesc, ActionDef } from 'oak-domain/lib/types';
|
||||
import { Schema as User } from './User';
|
||||
import { Schema as Pay } from './Pay';
|
||||
import { Schema as AccountOper } from './AccountOper';
|
||||
import { Schema as Withdraw } from './Withdraw';
|
||||
export interface Schema extends EntityShape {
|
||||
entity: String<32>;
|
||||
entityId: String<64>;
|
||||
withdraw?: Withdraw;
|
||||
loss: Price;
|
||||
pay: Pay;
|
||||
meta?: Object;
|
||||
|
|
@ -13,6 +14,7 @@ export interface Schema extends EntityShape {
|
|||
price: Price;
|
||||
creator: User;
|
||||
reason?: Text;
|
||||
opers: AccountOper[];
|
||||
}
|
||||
type IState = 'refunding' | 'refunded' | 'failed' | 'abnormal';
|
||||
type IAction = 'succeedRefunding' | 'failRefunding' | 'makeAbnormal';
|
||||
|
|
|
|||
|
|
@ -15,13 +15,13 @@ export const entityDesc = {
|
|||
pay: '关联支付',
|
||||
price: '价格',
|
||||
loss: '损耗',
|
||||
entity: '关联对象',
|
||||
entityId: '关联对象ID',
|
||||
withdraw: '关联提现',
|
||||
meta: 'metadata',
|
||||
externalId: '外部ID',
|
||||
iState: '状态',
|
||||
creator: '创建者',
|
||||
reason: '原因',
|
||||
opers: '相关账户操作'
|
||||
},
|
||||
action: {
|
||||
succeedRefunding: '退款成功',
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import { EntityDesc, ActionDef } from 'oak-domain/lib/types';
|
|||
import { Schema as Account } from './Account';
|
||||
import { Schema as AccountOper } from './AccountOper';
|
||||
import { Schema as User } from './User';
|
||||
import { Schema as Refund } from './Refund';
|
||||
export interface Schema extends EntityShape {
|
||||
account: Account;
|
||||
price: Price;
|
||||
|
|
@ -15,7 +14,6 @@ export interface Schema extends EntityShape {
|
|||
creator: User;
|
||||
reason?: Text;
|
||||
meta?: Object;
|
||||
refunds: Refund[];
|
||||
}
|
||||
type IState = 'withdrawing' | 'successful' | 'partiallySuccessful' | 'failed' | 'applying';
|
||||
type IAction = 'succeed' | 'fail' | 'succeedPartially';
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ export const entityDesc = {
|
|||
reason: '原因',
|
||||
meta: 'metadata',
|
||||
creator: '创建者',
|
||||
refunds: '退款',
|
||||
},
|
||||
v: {
|
||||
iState: {
|
||||
|
|
|
|||
|
|
@ -6,16 +6,18 @@ import { AppendOnlyAction } from "oak-domain/lib/actions/action";
|
|||
import { Price, String } from "oak-domain/lib/types/DataType";
|
||||
import * as Account from "../Account/Schema";
|
||||
import * as Deposit from "../Deposit/Schema";
|
||||
import * as Order from "../Order/Schema";
|
||||
import * as Pay from "../Pay/Schema";
|
||||
import * as Refund from "../Refund/Schema";
|
||||
import * as Withdraw from "../Withdraw/Schema";
|
||||
type Type = "deposit" | "withdraw" | "consume" | "loan" | "repay" | "withdrawBack" | "earn" | "encash" | "cutoffRefundable" | "tax" | "taxRefund";
|
||||
type Type = "deposit" | "withdraw" | "consume" | "loan" | "repay" | "withdrawBack" | "earn" | "encash" | "cutoffRefundable" | "tax" | "taxRefund" | "refund" | "refundFailure";
|
||||
export type OpSchema = EntityShape & {
|
||||
accountId: ForeignKey<"account">;
|
||||
type: Type;
|
||||
totalPlus: Price;
|
||||
availPlus: Price;
|
||||
refundablePlus?: Price | null;
|
||||
entity: "deposit" | "pay" | "withdraw" | string;
|
||||
entity: "deposit" | "order" | "pay" | "refund" | "withdraw" | string;
|
||||
entityId: String<64>;
|
||||
};
|
||||
export type OpAttr = keyof OpSchema;
|
||||
|
|
@ -25,11 +27,13 @@ export type Schema = EntityShape & {
|
|||
totalPlus: Price;
|
||||
availPlus: Price;
|
||||
refundablePlus?: Price | null;
|
||||
entity: "deposit" | "pay" | "withdraw" | string;
|
||||
entity: "deposit" | "order" | "pay" | "refund" | "withdraw" | string;
|
||||
entityId: String<64>;
|
||||
account: Account.Schema;
|
||||
deposit?: Deposit.Schema;
|
||||
order?: Order.Schema;
|
||||
pay?: Pay.Schema;
|
||||
refund?: Refund.Schema;
|
||||
withdraw?: Withdraw.Schema;
|
||||
} & {
|
||||
[A in ExpressionKey]?: any;
|
||||
|
|
@ -45,10 +49,12 @@ type AttrFilter = {
|
|||
totalPlus: Q_NumberValue;
|
||||
availPlus: Q_NumberValue;
|
||||
refundablePlus: Q_NumberValue;
|
||||
entity: Q_EnumValue<"deposit" | "pay" | "withdraw" | string>;
|
||||
entity: Q_EnumValue<"deposit" | "order" | "pay" | "refund" | "withdraw" | string>;
|
||||
entityId: Q_StringValue;
|
||||
deposit: Deposit.Filter;
|
||||
order: Order.Filter;
|
||||
pay: Pay.Filter;
|
||||
refund: Refund.Filter;
|
||||
withdraw: Withdraw.Filter;
|
||||
};
|
||||
export type Filter = MakeFilter<AttrFilter & ExprOp<OpAttr | string>>;
|
||||
|
|
@ -68,7 +74,9 @@ export type Projection = {
|
|||
entity?: number;
|
||||
entityId?: number;
|
||||
deposit?: Deposit.Projection;
|
||||
order?: Order.Projection;
|
||||
pay?: Pay.Projection;
|
||||
refund?: Refund.Projection;
|
||||
withdraw?: Withdraw.Projection;
|
||||
} & Partial<ExprOp<OpAttr | string>>;
|
||||
type AccountOperIdProjection = OneOf<{
|
||||
|
|
@ -80,9 +88,15 @@ type AccountIdProjection = OneOf<{
|
|||
type DepositIdProjection = OneOf<{
|
||||
entityId: number;
|
||||
}>;
|
||||
type OrderIdProjection = OneOf<{
|
||||
entityId: number;
|
||||
}>;
|
||||
type PayIdProjection = OneOf<{
|
||||
entityId: number;
|
||||
}>;
|
||||
type RefundIdProjection = OneOf<{
|
||||
entityId: number;
|
||||
}>;
|
||||
type WithdrawIdProjection = OneOf<{
|
||||
entityId: number;
|
||||
}>;
|
||||
|
|
@ -112,8 +126,12 @@ export type SortAttr = {
|
|||
entityId: number;
|
||||
} | {
|
||||
deposit: Deposit.SortAttr;
|
||||
} | {
|
||||
order: Order.SortAttr;
|
||||
} | {
|
||||
pay: Pay.SortAttr;
|
||||
} | {
|
||||
refund: Refund.SortAttr;
|
||||
} | {
|
||||
withdraw: Withdraw.SortAttr;
|
||||
} | {
|
||||
|
|
@ -148,6 +166,18 @@ export type CreateOperationData = FormCreateData<Omit<OpSchema, "entity" | "enti
|
|||
entity: "deposit";
|
||||
entityId: ForeignKey<"Deposit">;
|
||||
deposit?: never;
|
||||
} | {
|
||||
entity?: never;
|
||||
entityId?: never;
|
||||
order: Order.CreateSingleOperation;
|
||||
} | {
|
||||
entity: "order";
|
||||
entityId: ForeignKey<"Order">;
|
||||
order?: Order.UpdateOperation;
|
||||
} | {
|
||||
entity: "order";
|
||||
entityId: ForeignKey<"Order">;
|
||||
order?: never;
|
||||
} | {
|
||||
entity?: never;
|
||||
entityId?: never;
|
||||
|
|
@ -160,6 +190,18 @@ export type CreateOperationData = FormCreateData<Omit<OpSchema, "entity" | "enti
|
|||
entity: "pay";
|
||||
entityId: ForeignKey<"Pay">;
|
||||
pay?: never;
|
||||
} | {
|
||||
entity?: never;
|
||||
entityId?: never;
|
||||
refund: Refund.CreateSingleOperation;
|
||||
} | {
|
||||
entity: "refund";
|
||||
entityId: ForeignKey<"Refund">;
|
||||
refund?: Refund.UpdateOperation;
|
||||
} | {
|
||||
entity: "refund";
|
||||
entityId: ForeignKey<"Refund">;
|
||||
refund?: never;
|
||||
} | {
|
||||
entity?: never;
|
||||
entityId?: never;
|
||||
|
|
@ -196,19 +238,29 @@ export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "entity" | "enti
|
|||
deposit?: Deposit.CreateSingleOperation | Deposit.UpdateOperation | Deposit.RemoveOperation;
|
||||
entityId?: never;
|
||||
entity?: never;
|
||||
} | {
|
||||
order?: Order.CreateSingleOperation | Order.UpdateOperation | Order.RemoveOperation;
|
||||
entityId?: never;
|
||||
entity?: never;
|
||||
} | {
|
||||
pay?: Pay.CreateSingleOperation | Pay.UpdateOperation | Pay.RemoveOperation;
|
||||
entityId?: never;
|
||||
entity?: never;
|
||||
} | {
|
||||
refund?: Refund.CreateSingleOperation | Refund.UpdateOperation | Refund.RemoveOperation;
|
||||
entityId?: never;
|
||||
entity?: never;
|
||||
} | {
|
||||
withdraw?: Withdraw.CreateSingleOperation | Withdraw.UpdateOperation | Withdraw.RemoveOperation;
|
||||
entityId?: never;
|
||||
entity?: never;
|
||||
} | {
|
||||
entity?: ("deposit" | "pay" | "withdraw" | string) | null;
|
||||
entityId?: ForeignKey<"Deposit" | "Pay" | "Withdraw"> | null;
|
||||
entity?: ("deposit" | "order" | "pay" | "refund" | "withdraw" | string) | null;
|
||||
entityId?: ForeignKey<"Deposit" | "Order" | "Pay" | "Refund" | "Withdraw"> | null;
|
||||
deposit?: never;
|
||||
order?: never;
|
||||
pay?: never;
|
||||
refund?: never;
|
||||
withdraw?: never;
|
||||
}) & {
|
||||
[k: string]: any;
|
||||
|
|
@ -218,8 +270,12 @@ export type RemoveOperationData = {} & (({
|
|||
account?: Account.UpdateOperation | Account.RemoveOperation;
|
||||
})) & ({
|
||||
deposit?: Deposit.UpdateOperation | Deposit.RemoveOperation;
|
||||
} | {
|
||||
order?: Order.UpdateOperation | Order.RemoveOperation;
|
||||
} | {
|
||||
pay?: Pay.UpdateOperation | Pay.RemoveOperation;
|
||||
} | {
|
||||
refund?: Refund.UpdateOperation | Refund.RemoveOperation;
|
||||
} | {
|
||||
withdraw?: Withdraw.UpdateOperation | Withdraw.RemoveOperation;
|
||||
} | {
|
||||
|
|
@ -229,7 +285,9 @@ export type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter
|
|||
export type Operation = CreateOperation | UpdateOperation | RemoveOperation;
|
||||
export type AccountIdSubQuery = Selection<AccountIdProjection>;
|
||||
export type DepositIdSubQuery = Selection<DepositIdProjection>;
|
||||
export type OrderIdSubQuery = Selection<OrderIdProjection>;
|
||||
export type PayIdSubQuery = Selection<PayIdProjection>;
|
||||
export type RefundIdSubQuery = Selection<RefundIdProjection>;
|
||||
export type WithdrawIdSubQuery = Selection<WithdrawIdProjection>;
|
||||
export type AccountOperIdSubQuery = Selection<AccountOperIdProjection>;
|
||||
export type EntityDef = {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ export const desc = {
|
|||
type: {
|
||||
notNull: true,
|
||||
type: "enum",
|
||||
enumeration: ["deposit", "withdraw", "consume", "loan", "repay", "withdrawBack", "earn", "encash", "cutoffRefundable", "tax", "taxRefund"]
|
||||
enumeration: ["deposit", "withdraw", "consume", "loan", "repay", "withdrawBack", "earn", "encash", "cutoffRefundable", "tax", "taxRefund", "refund", "refundFailure"]
|
||||
},
|
||||
totalPlus: {
|
||||
notNull: true,
|
||||
|
|
@ -28,7 +28,7 @@ export const desc = {
|
|||
params: {
|
||||
length: 32
|
||||
},
|
||||
ref: ["deposit", "pay", "withdraw"]
|
||||
ref: ["deposit", "order", "pay", "refund", "withdraw"]
|
||||
},
|
||||
entityId: {
|
||||
notNull: true,
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ export const style = {
|
|||
tax: '#A569BD',
|
||||
taxRefund: '#FF3333',
|
||||
cutoffRefundable: '#2E4053',
|
||||
refund: '#CC3333',
|
||||
refundFailure: '#009933',
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
{ "name": "帐号操作", "attr": { "account": "帐号", "type": "类型", "totalPlus": "余额变化", "availPlus": "可用余额变化", "refundablePlus": "可退款余额变化", "entity": "关联对象", "entityId": "关联对象Id" }, "v": { "type": { "deposit": "充值", "withdraw": "提现", "consume": "消费", "loan": "抵押", "repay": "偿还", "withdrawBack": "提现失败", "earn": "赚取", "encash": "兑现", "tax": "渠道费", "taxRefund": "渠道费用退还", "cutoffRefundable": "削减可自由退额度" } } }
|
||||
{ "name": "帐号操作", "attr": { "account": "帐号", "type": "类型", "totalPlus": "余额变化", "availPlus": "可用余额变化", "refundablePlus": "可退款余额变化", "entity": "关联对象", "entityId": "关联对象Id" }, "v": { "type": { "deposit": "充值", "withdraw": "提现", "consume": "消费", "loan": "抵押", "repay": "偿还", "withdrawBack": "提现失败", "earn": "赚取", "encash": "兑现", "tax": "渠道费", "taxRefund": "渠道费用退还", "cutoffRefundable": "削减可自由退额度", "refund": "退款", "refundFailure": "退款失败" } } }
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { GenericAction } from "oak-domain/lib/actions/action";
|
|||
export type IAction = 'startPaying' | 'payAll' | 'payPartially' | 'payNone' | 'timeout' | 'cancel' | 'startRefunding' | 'refundAll' | 'refundPartially' | 'refundNone' | string;
|
||||
export type IState = 'paid' | 'unpaid' | 'timeout' | 'cancelled' | 'paying' | 'partiallyPaid' | 'paid' | 'refunding' | 'partiallyRefunded' | 'refunded' | string;
|
||||
export declare const IActionDef: ActionDef<IAction, IState>;
|
||||
export type ParticularAction = IAction;
|
||||
export type ParticularAction = IAction | 'settle';
|
||||
export declare const actions: string[];
|
||||
export type Action = GenericAction | ParticularAction | string;
|
||||
export declare const actionDefDict: {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ export const IActionDef = {
|
|||
},
|
||||
is: 'unpaid',
|
||||
};
|
||||
export const actions = ["count", "stat", "download", "select", "aggregate", "create", "remove", "update", "startPaying", "payAll", "payPartially", "payNone", "timeout", "cancel", "startRefunding", "refundAll", "refundPartially", "refundNone"];
|
||||
export const actions = ["count", "stat", "download", "select", "aggregate", "create", "remove", "update", "startPaying", "payAll", "payPartially", "payNone", "timeout", "cancel", "startRefunding", "refundAll", "refundPartially", "refundNone", "settle"];
|
||||
export const actionDefDict = {
|
||||
iState: IActionDef
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
import { ForeignKey } from "oak-domain/lib/types/DataType";
|
||||
import { Q_DateValue, Q_NumberValue, Q_StringValue, Q_EnumValue, NodeId, MakeFilter, ExprOp, ExpressionKey, SubQueryPredicateMetadata } from "oak-domain/lib/types/Demand";
|
||||
import { Q_DateValue, Q_BooleanValue, Q_NumberValue, Q_StringValue, Q_EnumValue, NodeId, MakeFilter, ExprOp, ExpressionKey, SubQueryPredicateMetadata } from "oak-domain/lib/types/Demand";
|
||||
import { OneOf } from "oak-domain/lib/types/Polyfill";
|
||||
import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOperation, Selection as OakSelection, MakeAction as OakMakeAction, AggregationResult, EntityShape } from "oak-domain/lib/types/Entity";
|
||||
import { Action, ParticularAction, IState } from "./Action";
|
||||
import { Price, String, Datetime } from "oak-domain/lib/types/DataType";
|
||||
import { Price, String, Datetime, Boolean } from "oak-domain/lib/types/DataType";
|
||||
import * as User from "../User/Schema";
|
||||
import * as Pay from "../Pay/Schema";
|
||||
import * as AccountOper from "../AccountOper/Schema";
|
||||
export type OpSchema = EntityShape & {
|
||||
price: Price;
|
||||
paid: Price;
|
||||
|
|
@ -16,6 +17,7 @@ export type OpSchema = EntityShape & {
|
|||
creatorId: ForeignKey<"user">;
|
||||
entity: String<32>;
|
||||
entityId: String<64>;
|
||||
settled: Boolean;
|
||||
iState?: IState | null;
|
||||
};
|
||||
export type OpAttr = keyof OpSchema;
|
||||
|
|
@ -29,10 +31,13 @@ export type Schema = EntityShape & {
|
|||
creatorId: ForeignKey<"user">;
|
||||
entity: String<32>;
|
||||
entityId: String<64>;
|
||||
settled: Boolean;
|
||||
iState?: IState | null;
|
||||
creator: User.Schema;
|
||||
pay$order?: Array<Pay.Schema>;
|
||||
pay$order$$aggr?: AggregationResult<Pay.Schema>;
|
||||
accountOper$entity?: Array<AccountOper.Schema>;
|
||||
accountOper$entity$$aggr?: AggregationResult<AccountOper.Schema>;
|
||||
} & {
|
||||
[A in ExpressionKey]?: any;
|
||||
};
|
||||
|
|
@ -51,8 +56,10 @@ type AttrFilter = {
|
|||
creator: User.Filter;
|
||||
entity: Q_StringValue;
|
||||
entityId: Q_StringValue;
|
||||
settled: Q_BooleanValue;
|
||||
iState: Q_EnumValue<IState>;
|
||||
pay$order: Pay.Filter & SubQueryPredicateMetadata;
|
||||
accountOper$entity: AccountOper.Filter & SubQueryPredicateMetadata;
|
||||
};
|
||||
export type Filter = MakeFilter<AttrFilter & ExprOp<OpAttr | string>>;
|
||||
export type Projection = {
|
||||
|
|
@ -72,6 +79,7 @@ export type Projection = {
|
|||
creator?: User.Projection;
|
||||
entity?: number;
|
||||
entityId?: number;
|
||||
settled?: number;
|
||||
iState?: number;
|
||||
pay$order?: Pay.Selection & {
|
||||
$entity: "pay";
|
||||
|
|
@ -79,6 +87,12 @@ export type Projection = {
|
|||
pay$order$$aggr?: Pay.Aggregation & {
|
||||
$entity: "pay";
|
||||
};
|
||||
accountOper$entity?: AccountOper.Selection & {
|
||||
$entity: "accountOper";
|
||||
};
|
||||
accountOper$entity$$aggr?: AccountOper.Aggregation & {
|
||||
$entity: "accountOper";
|
||||
};
|
||||
} & Partial<ExprOp<OpAttr | string>>;
|
||||
type OrderIdProjection = OneOf<{
|
||||
id: number;
|
||||
|
|
@ -114,6 +128,8 @@ export type SortAttr = {
|
|||
entity: number;
|
||||
} | {
|
||||
entityId: number;
|
||||
} | {
|
||||
settled: number;
|
||||
} | {
|
||||
iState: number;
|
||||
} | {
|
||||
|
|
@ -142,6 +158,7 @@ export type CreateOperationData = FormCreateData<Omit<OpSchema, "entity" | "enti
|
|||
[K: string]: any;
|
||||
}) & {
|
||||
pay$order?: OakOperation<Pay.UpdateOperation["action"], Omit<Pay.UpdateOperationData, "order" | "orderId">, Omit<Pay.Filter, "order" | "orderId">> | OakOperation<"create", Omit<Pay.CreateOperationData, "order" | "orderId">[]> | Array<OakOperation<"create", Omit<Pay.CreateOperationData, "order" | "orderId">> | OakOperation<Pay.UpdateOperation["action"], Omit<Pay.UpdateOperationData, "order" | "orderId">, Omit<Pay.Filter, "order" | "orderId">>>;
|
||||
accountOper$entity?: OakOperation<"create", Omit<AccountOper.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<AccountOper.CreateOperationData, "entity" | "entityId">>>;
|
||||
};
|
||||
export type CreateSingleOperation = OakOperation<"create", CreateOperationData>;
|
||||
export type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
|
||||
|
|
@ -161,6 +178,7 @@ export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "creatorId">> &
|
|||
})) & {
|
||||
[k: string]: any;
|
||||
pay$order?: OakOperation<Pay.UpdateOperation["action"], Omit<Pay.UpdateOperationData, "order" | "orderId">, Omit<Pay.Filter, "order" | "orderId">> | OakOperation<Pay.RemoveOperation["action"], Omit<Pay.RemoveOperationData, "order" | "orderId">, Omit<Pay.Filter, "order" | "orderId">> | OakOperation<"create", Omit<Pay.CreateOperationData, "order" | "orderId">[]> | Array<OakOperation<"create", Omit<Pay.CreateOperationData, "order" | "orderId">> | OakOperation<Pay.UpdateOperation["action"], Omit<Pay.UpdateOperationData, "order" | "orderId">, Omit<Pay.Filter, "order" | "orderId">> | OakOperation<Pay.RemoveOperation["action"], Omit<Pay.RemoveOperationData, "order" | "orderId">, Omit<Pay.Filter, "order" | "orderId">>>;
|
||||
accountOper$entity?: OakOperation<"create", Omit<AccountOper.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<AccountOper.CreateOperationData, "entity" | "entityId">>>;
|
||||
};
|
||||
export type UpdateOperation = OakOperation<"update" | ParticularAction | string, UpdateOperationData, Filter, Sorter>;
|
||||
export type RemoveOperationData = {} & (({
|
||||
|
|
|
|||
|
|
@ -50,6 +50,10 @@ export const desc = {
|
|||
length: 64
|
||||
}
|
||||
},
|
||||
settled: {
|
||||
notNull: true,
|
||||
type: "boolean"
|
||||
},
|
||||
iState: {
|
||||
type: "enum",
|
||||
enumeration: ["paid", "unpaid", "timeout", "cancelled", "paying", "partiallyPaid", "paid", "refunding", "partiallyRefunded", "refunded"]
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
{ "name": "订单", "attr": { "price": "订单金额", "paid": "已支付金额", "refunded": "已退款金额", "iState": "订单状态", "title": "订单标题", "desc": "订单描述", "timeoutAt": "过期时间", "creator": "创建者", "entity": "关联对象", "entityId": "关联对象Id" }, "action": { "startPaying": "开始支付", "payAll": "全部支付", "payPartially": "部分支付", "payNone": "支付失败", "timeout": "过期", "cancel": "放弃", "startRefunding": "开始退款", "refundAll": "完全退款", "refundNone": "退款失败", "refundPartially": "部分退款" }, "v": { "iState": { "paid": "已付款", "partiallyPaid": "部分支付", "paying": "支付中", "unpaid": "待付款", "timeout": "已超时", "cancelled": "已取消", "refunded": "已退款", "partiallyRefunded": "已部分退款", "refunding": "退款中" } } }
|
||||
{ "name": "订单", "attr": { "price": "订单金额", "paid": "已支付金额", "refunded": "已退款金额", "iState": "订单状态", "title": "订单标题", "desc": "订单描述", "timeoutAt": "过期时间", "creator": "创建者", "entity": "关联对象", "entityId": "关联对象Id", "settled": "是否结算", "opers": "相关帐户操作" }, "action": { "startPaying": "开始支付", "payAll": "全部支付", "payPartially": "部分支付", "payNone": "支付失败", "timeout": "过期", "cancel": "放弃", "startRefunding": "开始退款", "refundAll": "完全退款", "refundNone": "退款失败", "refundPartially": "部分退款", "settle": "结算" }, "v": { "iState": { "paid": "已付款", "partiallyPaid": "部分支付", "paying": "支付中", "unpaid": "待付款", "timeout": "已超时", "cancelled": "已取消", "refunded": "已退款", "partiallyRefunded": "已部分退款", "refunding": "退款中" } } }
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ export const IActionDef = {
|
|||
startPaying: ['unpaid', 'paying'],
|
||||
succeedPaying: [['unpaid', 'paying'], 'paid'],
|
||||
close: [['unpaid', 'paying'], 'closed'],
|
||||
startRefunding: [['paid', 'partiallyRefunded', 'refunding'], 'refunding'],
|
||||
startRefunding: [['paid', 'partiallyRefunded'], 'refunding'],
|
||||
refundAll: [['paid', 'refunding', 'partiallyRefunded'], 'refunded'],
|
||||
refundPartially: [['paid', 'refunding', 'partiallyRefunded'], 'partiallyRefunded'],
|
||||
stopRefunding: ['refunding', 'paid'],
|
||||
|
|
|
|||
|
|
@ -3,14 +3,14 @@ import { Q_DateValue, Q_NumberValue, Q_StringValue, Q_EnumValue, NodeId, MakeFil
|
|||
import { OneOf } from "oak-domain/lib/types/Polyfill";
|
||||
import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOperation, Selection as OakSelection, MakeAction as OakMakeAction, AggregationResult, EntityShape } from "oak-domain/lib/types/Entity";
|
||||
import { Action, ParticularAction, IState } from "./Action";
|
||||
import { String, Price, Text } from "oak-domain/lib/types/DataType";
|
||||
import { Price, String, Text } from "oak-domain/lib/types/DataType";
|
||||
import * as Withdraw from "../Withdraw/Schema";
|
||||
import * as Pay from "../Pay/Schema";
|
||||
import * as User from "../User/Schema";
|
||||
import * as Withdraw from "../Withdraw/Schema";
|
||||
import * as SysAccountOper from "../SysAccountOper/Schema";
|
||||
import * as AccountOper from "../AccountOper/Schema";
|
||||
export type OpSchema = EntityShape & {
|
||||
entity: "withdraw" | string;
|
||||
entityId: String<64>;
|
||||
withdrawId?: ForeignKey<"withdraw"> | null;
|
||||
loss: Price;
|
||||
payId: ForeignKey<"pay">;
|
||||
meta?: Object | null;
|
||||
|
|
@ -22,8 +22,7 @@ export type OpSchema = EntityShape & {
|
|||
};
|
||||
export type OpAttr = keyof OpSchema;
|
||||
export type Schema = EntityShape & {
|
||||
entity: "withdraw" | string;
|
||||
entityId: String<64>;
|
||||
withdrawId?: ForeignKey<"withdraw"> | null;
|
||||
loss: Price;
|
||||
payId: ForeignKey<"pay">;
|
||||
meta?: Object | null;
|
||||
|
|
@ -32,11 +31,13 @@ export type Schema = EntityShape & {
|
|||
creatorId: ForeignKey<"user">;
|
||||
reason?: Text | null;
|
||||
iState?: IState | null;
|
||||
withdraw?: Withdraw.Schema | null;
|
||||
pay: Pay.Schema;
|
||||
creator: User.Schema;
|
||||
withdraw?: Withdraw.Schema;
|
||||
sysAccountOper$refund?: Array<SysAccountOper.Schema>;
|
||||
sysAccountOper$refund$$aggr?: AggregationResult<SysAccountOper.Schema>;
|
||||
accountOper$entity?: Array<AccountOper.Schema>;
|
||||
accountOper$entity$$aggr?: AggregationResult<AccountOper.Schema>;
|
||||
} & {
|
||||
[A in ExpressionKey]?: any;
|
||||
};
|
||||
|
|
@ -45,8 +46,8 @@ type AttrFilter = {
|
|||
$$createAt$$: Q_DateValue;
|
||||
$$seq$$: Q_NumberValue;
|
||||
$$updateAt$$: Q_DateValue;
|
||||
entity: Q_EnumValue<"withdraw" | string>;
|
||||
entityId: Q_StringValue;
|
||||
withdrawId: Q_StringValue;
|
||||
withdraw: Withdraw.Filter;
|
||||
loss: Q_NumberValue;
|
||||
payId: Q_StringValue;
|
||||
pay: Pay.Filter;
|
||||
|
|
@ -57,8 +58,8 @@ type AttrFilter = {
|
|||
creator: User.Filter;
|
||||
reason: Q_StringValue;
|
||||
iState: Q_EnumValue<IState>;
|
||||
withdraw: Withdraw.Filter;
|
||||
sysAccountOper$refund: SysAccountOper.Filter & SubQueryPredicateMetadata;
|
||||
accountOper$entity: AccountOper.Filter & SubQueryPredicateMetadata;
|
||||
};
|
||||
export type Filter = MakeFilter<AttrFilter & ExprOp<OpAttr | string>>;
|
||||
export type Projection = {
|
||||
|
|
@ -68,8 +69,8 @@ export type Projection = {
|
|||
$$createAt$$?: number;
|
||||
$$updateAt$$?: number;
|
||||
$$seq$$?: number;
|
||||
entity?: number;
|
||||
entityId?: number;
|
||||
withdrawId?: number;
|
||||
withdraw?: Withdraw.Projection;
|
||||
loss?: number;
|
||||
payId?: number;
|
||||
pay?: Pay.Projection;
|
||||
|
|
@ -80,26 +81,31 @@ export type Projection = {
|
|||
creator?: User.Projection;
|
||||
reason?: number;
|
||||
iState?: number;
|
||||
withdraw?: Withdraw.Projection;
|
||||
sysAccountOper$refund?: SysAccountOper.Selection & {
|
||||
$entity: "sysAccountOper";
|
||||
};
|
||||
sysAccountOper$refund$$aggr?: SysAccountOper.Aggregation & {
|
||||
$entity: "sysAccountOper";
|
||||
};
|
||||
accountOper$entity?: AccountOper.Selection & {
|
||||
$entity: "accountOper";
|
||||
};
|
||||
accountOper$entity$$aggr?: AccountOper.Aggregation & {
|
||||
$entity: "accountOper";
|
||||
};
|
||||
} & Partial<ExprOp<OpAttr | string>>;
|
||||
type RefundIdProjection = OneOf<{
|
||||
id: number;
|
||||
}>;
|
||||
type WithdrawIdProjection = OneOf<{
|
||||
withdrawId: number;
|
||||
}>;
|
||||
type PayIdProjection = OneOf<{
|
||||
payId: number;
|
||||
}>;
|
||||
type UserIdProjection = OneOf<{
|
||||
creatorId: number;
|
||||
}>;
|
||||
type WithdrawIdProjection = OneOf<{
|
||||
entityId: number;
|
||||
}>;
|
||||
export type SortAttr = {
|
||||
id: number;
|
||||
} | {
|
||||
|
|
@ -109,9 +115,9 @@ export type SortAttr = {
|
|||
} | {
|
||||
$$updateAt$$: number;
|
||||
} | {
|
||||
entity: number;
|
||||
withdrawId: number;
|
||||
} | {
|
||||
entityId: number;
|
||||
withdraw: Withdraw.SortAttr;
|
||||
} | {
|
||||
loss: number;
|
||||
} | {
|
||||
|
|
@ -130,8 +136,6 @@ export type SortAttr = {
|
|||
reason: number;
|
||||
} | {
|
||||
iState: number;
|
||||
} | {
|
||||
withdraw: Withdraw.SortAttr;
|
||||
} | {
|
||||
[k: string]: any;
|
||||
} | OneOf<ExprOp<OpAttr | string>>;
|
||||
|
|
@ -143,7 +147,16 @@ export type Sorter = SortNode[];
|
|||
export type SelectOperation<P extends Object = Projection> = OakSelection<"select", P, Filter, Sorter>;
|
||||
export type Selection<P extends Object = Projection> = SelectOperation<P>;
|
||||
export type Aggregation = DeduceAggregation<Projection, Filter, Sorter>;
|
||||
export type CreateOperationData = FormCreateData<Omit<OpSchema, "entity" | "entityId" | "payId" | "creatorId">> & (({
|
||||
export type CreateOperationData = FormCreateData<Omit<OpSchema, "withdrawId" | "payId" | "creatorId">> & (({
|
||||
withdrawId?: never;
|
||||
withdraw?: Withdraw.CreateSingleOperation;
|
||||
} | {
|
||||
withdrawId: ForeignKey<"withdraw">;
|
||||
withdraw?: Withdraw.UpdateOperation;
|
||||
} | {
|
||||
withdraw?: never;
|
||||
withdrawId?: ForeignKey<"withdraw">;
|
||||
}) & ({
|
||||
payId?: never;
|
||||
pay: Pay.CreateSingleOperation;
|
||||
} | {
|
||||
|
|
@ -161,29 +174,26 @@ export type CreateOperationData = FormCreateData<Omit<OpSchema, "entity" | "enti
|
|||
} | {
|
||||
creator?: never;
|
||||
creatorId: ForeignKey<"creator">;
|
||||
})) & ({
|
||||
entity?: never;
|
||||
entityId?: never;
|
||||
withdraw: Withdraw.CreateSingleOperation;
|
||||
} | {
|
||||
entity: "withdraw";
|
||||
entityId: ForeignKey<"Withdraw">;
|
||||
withdraw?: Withdraw.UpdateOperation;
|
||||
} | {
|
||||
entity: "withdraw";
|
||||
entityId: ForeignKey<"Withdraw">;
|
||||
withdraw?: never;
|
||||
} | {
|
||||
entity?: string;
|
||||
entityId?: string;
|
||||
[K: string]: any;
|
||||
}) & {
|
||||
})) & {
|
||||
sysAccountOper$refund?: OakOperation<"create", Omit<SysAccountOper.CreateOperationData, "refund" | "refundId">[]> | Array<OakOperation<"create", Omit<SysAccountOper.CreateOperationData, "refund" | "refundId">>>;
|
||||
accountOper$entity?: OakOperation<"create", Omit<AccountOper.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<AccountOper.CreateOperationData, "entity" | "entityId">>>;
|
||||
};
|
||||
export type CreateSingleOperation = OakOperation<"create", CreateOperationData>;
|
||||
export type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
|
||||
export type CreateOperation = CreateSingleOperation | CreateMultipleOperation;
|
||||
export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "entity" | "entityId" | "payId" | "creatorId">> & (({
|
||||
export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "withdrawId" | "payId" | "creatorId">> & (({
|
||||
withdraw?: Withdraw.CreateSingleOperation;
|
||||
withdrawId?: never;
|
||||
} | {
|
||||
withdraw?: Withdraw.UpdateOperation;
|
||||
withdrawId?: never;
|
||||
} | {
|
||||
withdraw?: Withdraw.RemoveOperation;
|
||||
withdrawId?: never;
|
||||
} | {
|
||||
withdraw?: never;
|
||||
withdrawId?: ForeignKey<"withdraw"> | null;
|
||||
}) & ({
|
||||
pay?: Pay.CreateSingleOperation;
|
||||
payId?: never;
|
||||
} | {
|
||||
|
|
@ -207,33 +217,24 @@ export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "entity" | "enti
|
|||
} | {
|
||||
creator?: never;
|
||||
creatorId?: ForeignKey<"creator">;
|
||||
})) & ({
|
||||
withdraw?: Withdraw.CreateSingleOperation | Withdraw.UpdateOperation | Withdraw.RemoveOperation;
|
||||
entityId?: never;
|
||||
entity?: never;
|
||||
} | {
|
||||
entity?: ("withdraw" | string) | null;
|
||||
entityId?: ForeignKey<"Withdraw"> | null;
|
||||
withdraw?: never;
|
||||
}) & {
|
||||
})) & {
|
||||
[k: string]: any;
|
||||
sysAccountOper$refund?: OakOperation<"create", Omit<SysAccountOper.CreateOperationData, "refund" | "refundId">[]> | Array<OakOperation<"create", Omit<SysAccountOper.CreateOperationData, "refund" | "refundId">>>;
|
||||
accountOper$entity?: OakOperation<"create", Omit<AccountOper.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<AccountOper.CreateOperationData, "entity" | "entityId">>>;
|
||||
};
|
||||
export type UpdateOperation = OakOperation<"update" | ParticularAction | string, UpdateOperationData, Filter, Sorter>;
|
||||
export type RemoveOperationData = {} & (({
|
||||
withdraw?: Withdraw.UpdateOperation | Withdraw.RemoveOperation;
|
||||
}) & ({
|
||||
pay?: Pay.UpdateOperation | Pay.RemoveOperation;
|
||||
}) & ({
|
||||
creator?: User.UpdateOperation | User.RemoveOperation;
|
||||
})) & ({
|
||||
withdraw?: Withdraw.UpdateOperation | Withdraw.RemoveOperation;
|
||||
} | {
|
||||
[k: string]: any;
|
||||
});
|
||||
}));
|
||||
export type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
|
||||
export type Operation = CreateOperation | UpdateOperation | RemoveOperation;
|
||||
export type WithdrawIdSubQuery = Selection<WithdrawIdProjection>;
|
||||
export type PayIdSubQuery = Selection<PayIdProjection>;
|
||||
export type UserIdSubQuery = Selection<UserIdProjection>;
|
||||
export type WithdrawIdSubQuery = Selection<WithdrawIdProjection>;
|
||||
export type RefundIdSubQuery = Selection<RefundIdProjection>;
|
||||
export type EntityDef = {
|
||||
Schema: Schema;
|
||||
|
|
|
|||
|
|
@ -1,20 +1,9 @@
|
|||
import { actions } from "./Action";
|
||||
export const desc = {
|
||||
attributes: {
|
||||
entity: {
|
||||
notNull: true,
|
||||
type: "varchar",
|
||||
params: {
|
||||
length: 32
|
||||
},
|
||||
ref: ["withdraw"]
|
||||
},
|
||||
entityId: {
|
||||
notNull: true,
|
||||
type: "varchar",
|
||||
params: {
|
||||
length: 64
|
||||
}
|
||||
withdrawId: {
|
||||
type: "ref",
|
||||
ref: "withdraw"
|
||||
},
|
||||
loss: {
|
||||
notNull: true,
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
{ "name": "帐户", "attr": { "pay": "关联支付", "price": "价格", "loss": "损耗", "entity": "关联对象", "entityId": "关联对象ID", "meta": "metadata", "externalId": "外部ID", "iState": "状态", "creator": "创建者", "reason": "原因" }, "action": { "succeedRefunding": "退款成功", "failRefunding": "退款失败", "makeAbnormal": "退款异常" }, "v": { "iState": { "refunding": "退款中", "refunded": "退款成功", "failed": "退款失败", "abnormal": "退款异常" } } }
|
||||
{ "name": "帐户", "attr": { "pay": "关联支付", "price": "价格", "loss": "损耗", "withdraw": "关联提现", "meta": "metadata", "externalId": "外部ID", "iState": "状态", "creator": "创建者", "reason": "原因", "opers": "相关账户操作" }, "action": { "succeedRefunding": "退款成功", "failRefunding": "退款失败", "makeAbnormal": "退款异常" }, "v": { "iState": { "refunding": "退款中", "refunded": "退款成功", "failed": "退款失败", "abnormal": "退款异常" } } }
|
||||
|
|
|
|||
|
|
@ -6,12 +6,12 @@ import { Action, ParticularAction, IState } from "./Action";
|
|||
import { Price, Text } from "oak-domain/lib/types/DataType";
|
||||
import * as Account from "../Account/Schema";
|
||||
import * as User from "../User/Schema";
|
||||
import * as Refund from "../Refund/Schema";
|
||||
import * as SysAccountOper from "../SysAccountOper/Schema";
|
||||
import * as WithdrawTransfer from "../WithdrawTransfer/Schema";
|
||||
import * as ModiEntity from "../ModiEntity/Schema";
|
||||
import * as OperEntity from "../OperEntity/Schema";
|
||||
import * as AccountOper from "../AccountOper/Schema";
|
||||
import * as Refund from "../Refund/Schema";
|
||||
export type OpSchema = EntityShape & {
|
||||
accountId: ForeignKey<"account">;
|
||||
price: Price;
|
||||
|
|
@ -36,6 +36,8 @@ export type Schema = EntityShape & {
|
|||
iState?: IState | null;
|
||||
account: Account.Schema;
|
||||
creator: User.Schema;
|
||||
refund$withdraw?: Array<Refund.Schema>;
|
||||
refund$withdraw$$aggr?: AggregationResult<Refund.Schema>;
|
||||
sysAccountOper$withdraw?: Array<SysAccountOper.Schema>;
|
||||
sysAccountOper$withdraw$$aggr?: AggregationResult<SysAccountOper.Schema>;
|
||||
withdrawTransfer$withdraw?: Array<WithdrawTransfer.Schema>;
|
||||
|
|
@ -46,8 +48,6 @@ export type Schema = EntityShape & {
|
|||
operEntity$entity$$aggr?: AggregationResult<OperEntity.Schema>;
|
||||
accountOper$entity?: Array<AccountOper.Schema>;
|
||||
accountOper$entity$$aggr?: AggregationResult<AccountOper.Schema>;
|
||||
refund$entity?: Array<Refund.Schema>;
|
||||
refund$entity$$aggr?: AggregationResult<Refund.Schema>;
|
||||
} & {
|
||||
[A in ExpressionKey]?: any;
|
||||
};
|
||||
|
|
@ -67,12 +67,12 @@ type AttrFilter = {
|
|||
reason: Q_StringValue;
|
||||
meta: Object;
|
||||
iState: Q_EnumValue<IState>;
|
||||
refund$withdraw: Refund.Filter & SubQueryPredicateMetadata;
|
||||
sysAccountOper$withdraw: SysAccountOper.Filter & SubQueryPredicateMetadata;
|
||||
withdrawTransfer$withdraw: WithdrawTransfer.Filter & SubQueryPredicateMetadata;
|
||||
modiEntity$entity: ModiEntity.Filter & SubQueryPredicateMetadata;
|
||||
operEntity$entity: OperEntity.Filter & SubQueryPredicateMetadata;
|
||||
accountOper$entity: AccountOper.Filter & SubQueryPredicateMetadata;
|
||||
refund$entity: Refund.Filter & SubQueryPredicateMetadata;
|
||||
};
|
||||
export type Filter = MakeFilter<AttrFilter & ExprOp<OpAttr | string>>;
|
||||
export type Projection = {
|
||||
|
|
@ -93,6 +93,12 @@ export type Projection = {
|
|||
reason?: number;
|
||||
meta?: number | Object;
|
||||
iState?: number;
|
||||
refund$withdraw?: Refund.Selection & {
|
||||
$entity: "refund";
|
||||
};
|
||||
refund$withdraw$$aggr?: Refund.Aggregation & {
|
||||
$entity: "refund";
|
||||
};
|
||||
sysAccountOper$withdraw?: SysAccountOper.Selection & {
|
||||
$entity: "sysAccountOper";
|
||||
};
|
||||
|
|
@ -123,12 +129,6 @@ export type Projection = {
|
|||
accountOper$entity$$aggr?: AccountOper.Aggregation & {
|
||||
$entity: "accountOper";
|
||||
};
|
||||
refund$entity?: Refund.Selection & {
|
||||
$entity: "refund";
|
||||
};
|
||||
refund$entity$$aggr?: Refund.Aggregation & {
|
||||
$entity: "refund";
|
||||
};
|
||||
} & Partial<ExprOp<OpAttr | string>>;
|
||||
type WithdrawIdProjection = OneOf<{
|
||||
id: number;
|
||||
|
|
@ -197,12 +197,12 @@ export type CreateOperationData = FormCreateData<Omit<OpSchema, "accountId" | "c
|
|||
creator?: never;
|
||||
creatorId: ForeignKey<"creator">;
|
||||
})) & {
|
||||
refund$withdraw?: OakOperation<Refund.UpdateOperation["action"], Omit<Refund.UpdateOperationData, "withdraw" | "withdrawId">, Omit<Refund.Filter, "withdraw" | "withdrawId">> | OakOperation<"create", Omit<Refund.CreateOperationData, "withdraw" | "withdrawId">[]> | Array<OakOperation<"create", Omit<Refund.CreateOperationData, "withdraw" | "withdrawId">> | OakOperation<Refund.UpdateOperation["action"], Omit<Refund.UpdateOperationData, "withdraw" | "withdrawId">, Omit<Refund.Filter, "withdraw" | "withdrawId">>>;
|
||||
sysAccountOper$withdraw?: OakOperation<"create", Omit<SysAccountOper.CreateOperationData, "withdraw" | "withdrawId">[]> | Array<OakOperation<"create", Omit<SysAccountOper.CreateOperationData, "withdraw" | "withdrawId">>>;
|
||||
withdrawTransfer$withdraw?: OakOperation<WithdrawTransfer.UpdateOperation["action"], Omit<WithdrawTransfer.UpdateOperationData, "withdraw" | "withdrawId">, Omit<WithdrawTransfer.Filter, "withdraw" | "withdrawId">> | OakOperation<"create", Omit<WithdrawTransfer.CreateOperationData, "withdraw" | "withdrawId">[]> | Array<OakOperation<"create", Omit<WithdrawTransfer.CreateOperationData, "withdraw" | "withdrawId">> | OakOperation<WithdrawTransfer.UpdateOperation["action"], Omit<WithdrawTransfer.UpdateOperationData, "withdraw" | "withdrawId">, Omit<WithdrawTransfer.Filter, "withdraw" | "withdrawId">>>;
|
||||
modiEntity$entity?: OakOperation<"create", Omit<ModiEntity.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<ModiEntity.CreateOperationData, "entity" | "entityId">>>;
|
||||
operEntity$entity?: OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">>>;
|
||||
accountOper$entity?: OakOperation<"create", Omit<AccountOper.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<AccountOper.CreateOperationData, "entity" | "entityId">>>;
|
||||
refund$entity?: OakOperation<Refund.UpdateOperation["action"], Omit<Refund.UpdateOperationData, "entity" | "entityId">, Omit<Refund.Filter, "entity" | "entityId">> | OakOperation<"create", Omit<Refund.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<Refund.CreateOperationData, "entity" | "entityId">> | OakOperation<Refund.UpdateOperation["action"], Omit<Refund.UpdateOperationData, "entity" | "entityId">, Omit<Refund.Filter, "entity" | "entityId">>>;
|
||||
};
|
||||
export type CreateSingleOperation = OakOperation<"create", CreateOperationData>;
|
||||
export type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
|
||||
|
|
@ -233,12 +233,12 @@ export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "accountId" | "c
|
|||
creatorId?: ForeignKey<"creator">;
|
||||
})) & {
|
||||
[k: string]: any;
|
||||
refund$withdraw?: OakOperation<Refund.UpdateOperation["action"], Omit<Refund.UpdateOperationData, "withdraw" | "withdrawId">, Omit<Refund.Filter, "withdraw" | "withdrawId">> | OakOperation<Refund.RemoveOperation["action"], Omit<Refund.RemoveOperationData, "withdraw" | "withdrawId">, Omit<Refund.Filter, "withdraw" | "withdrawId">> | OakOperation<"create", Omit<Refund.CreateOperationData, "withdraw" | "withdrawId">[]> | Array<OakOperation<"create", Omit<Refund.CreateOperationData, "withdraw" | "withdrawId">> | OakOperation<Refund.UpdateOperation["action"], Omit<Refund.UpdateOperationData, "withdraw" | "withdrawId">, Omit<Refund.Filter, "withdraw" | "withdrawId">> | OakOperation<Refund.RemoveOperation["action"], Omit<Refund.RemoveOperationData, "withdraw" | "withdrawId">, Omit<Refund.Filter, "withdraw" | "withdrawId">>>;
|
||||
sysAccountOper$withdraw?: OakOperation<"create", Omit<SysAccountOper.CreateOperationData, "withdraw" | "withdrawId">[]> | Array<OakOperation<"create", Omit<SysAccountOper.CreateOperationData, "withdraw" | "withdrawId">>>;
|
||||
withdrawTransfer$withdraw?: OakOperation<WithdrawTransfer.UpdateOperation["action"], Omit<WithdrawTransfer.UpdateOperationData, "withdraw" | "withdrawId">, Omit<WithdrawTransfer.Filter, "withdraw" | "withdrawId">> | OakOperation<WithdrawTransfer.RemoveOperation["action"], Omit<WithdrawTransfer.RemoveOperationData, "withdraw" | "withdrawId">, Omit<WithdrawTransfer.Filter, "withdraw" | "withdrawId">> | OakOperation<"create", Omit<WithdrawTransfer.CreateOperationData, "withdraw" | "withdrawId">[]> | Array<OakOperation<"create", Omit<WithdrawTransfer.CreateOperationData, "withdraw" | "withdrawId">> | OakOperation<WithdrawTransfer.UpdateOperation["action"], Omit<WithdrawTransfer.UpdateOperationData, "withdraw" | "withdrawId">, Omit<WithdrawTransfer.Filter, "withdraw" | "withdrawId">> | OakOperation<WithdrawTransfer.RemoveOperation["action"], Omit<WithdrawTransfer.RemoveOperationData, "withdraw" | "withdrawId">, Omit<WithdrawTransfer.Filter, "withdraw" | "withdrawId">>>;
|
||||
modiEntity$entity?: OakOperation<"create", Omit<ModiEntity.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<ModiEntity.CreateOperationData, "entity" | "entityId">>>;
|
||||
operEntity$entity?: OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">>>;
|
||||
accountOper$entity?: OakOperation<"create", Omit<AccountOper.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<AccountOper.CreateOperationData, "entity" | "entityId">>>;
|
||||
refund$entity?: OakOperation<Refund.UpdateOperation["action"], Omit<Refund.UpdateOperationData, "entity" | "entityId">, Omit<Refund.Filter, "entity" | "entityId">> | OakOperation<Refund.RemoveOperation["action"], Omit<Refund.RemoveOperationData, "entity" | "entityId">, Omit<Refund.Filter, "entity" | "entityId">> | OakOperation<"create", Omit<Refund.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<Refund.CreateOperationData, "entity" | "entityId">> | OakOperation<Refund.UpdateOperation["action"], Omit<Refund.UpdateOperationData, "entity" | "entityId">, Omit<Refund.Filter, "entity" | "entityId">> | OakOperation<Refund.RemoveOperation["action"], Omit<Refund.RemoveOperationData, "entity" | "entityId">, Omit<Refund.Filter, "entity" | "entityId">>>;
|
||||
};
|
||||
export type UpdateOperation = OakOperation<"update" | ParticularAction | string, UpdateOperationData, Filter, Sorter>;
|
||||
export type RemoveOperationData = {} & (({
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
{ "name": "提现", "attr": { "account": "帐户", "price": "金额", "loss": "损耗", "dealPrice": "完成金额", "dealLoss": "完成损耗", "iState": "状态", "opers": "被关联帐户操作", "reason": "原因", "meta": "metadata", "creator": "创建者", "refunds": "退款" }, "v": { "iState": { "withdrawing": "提现中", "successful": "成功的", "partiallySuccessful": "部分成功的", "failed": "失败的", "applying": "申请中" } }, "action": { "succeed": "成功", "succeedPartially": "部分成功", "fail": "失败" } }
|
||||
{ "name": "提现", "attr": { "account": "帐户", "price": "金额", "loss": "损耗", "dealPrice": "完成金额", "dealLoss": "完成损耗", "iState": "状态", "opers": "被关联帐户操作", "reason": "原因", "meta": "metadata", "creator": "创建者" }, "v": { "iState": { "withdrawing": "提现中", "successful": "成功的", "partiallySuccessful": "部分成功的", "failed": "失败的", "applying": "申请中" } }, "action": { "succeed": "成功", "succeedPartially": "部分成功", "fail": "失败" } }
|
||||
|
|
|
|||
|
|
@ -582,6 +582,8 @@ export type OfflineAccountIdSubQuery = {
|
|||
export type OrderIdSubQuery = {
|
||||
[K in "$in" | "$nin"]?: (Pay.OrderIdSubQuery & {
|
||||
entity: "pay";
|
||||
}) | (AccountOper.OrderIdSubQuery & {
|
||||
entity: "accountOper";
|
||||
}) | (Order.OrderIdSubQuery & {
|
||||
entity: "order";
|
||||
}) | any;
|
||||
|
|
@ -600,6 +602,8 @@ export type PayIdSubQuery = {
|
|||
export type RefundIdSubQuery = {
|
||||
[K in "$in" | "$nin"]?: (SysAccountOper.RefundIdSubQuery & {
|
||||
entity: "sysAccountOper";
|
||||
}) | (AccountOper.RefundIdSubQuery & {
|
||||
entity: "accountOper";
|
||||
}) | (Refund.RefundIdSubQuery & {
|
||||
entity: "refund";
|
||||
}) | any;
|
||||
|
|
@ -621,7 +625,9 @@ export type WechatPayIdSubQuery = {
|
|||
}) | any;
|
||||
};
|
||||
export type WithdrawIdSubQuery = {
|
||||
[K in "$in" | "$nin"]?: (SysAccountOper.WithdrawIdSubQuery & {
|
||||
[K in "$in" | "$nin"]?: (Refund.WithdrawIdSubQuery & {
|
||||
entity: "refund";
|
||||
}) | (SysAccountOper.WithdrawIdSubQuery & {
|
||||
entity: "sysAccountOper";
|
||||
}) | (WithdrawTransfer.WithdrawIdSubQuery & {
|
||||
entity: "withdrawTransfer";
|
||||
|
|
@ -631,8 +637,6 @@ export type WithdrawIdSubQuery = {
|
|||
entity: "operEntity";
|
||||
}) | (AccountOper.WithdrawIdSubQuery & {
|
||||
entity: "accountOper";
|
||||
}) | (Refund.WithdrawIdSubQuery & {
|
||||
entity: "refund";
|
||||
}) | (Withdraw.WithdrawIdSubQuery & {
|
||||
entity: "withdraw";
|
||||
}) | any;
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ const triggers = [
|
|||
}
|
||||
}, { forUpdate: true });
|
||||
const { total, avail, refundable } = account;
|
||||
// 提现不可能提成负数
|
||||
if (type === 'withdraw') {
|
||||
// 提现和退款不能把账户提成负数
|
||||
if (['withdraw', 'refund'].includes(type)) {
|
||||
if (avail + availPlus < 0) {
|
||||
throw new OakInputIllegalException('accountOper', ['availPlus'], 'withdraw::availOverflow');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ async function changeOrderStateByPay(filter, context, option) {
|
|||
assert(payPaid === orderPrice && payPaid === orderPaid);
|
||||
const iState = payPaid === orderPrice ? 'refunded' : 'partiallyRefunded';
|
||||
if (orderIState !== iState || orderRefunded !== payRefunded) {
|
||||
const action = payPaid === orderPrice ? 'refundAll' : 'refundPartially';
|
||||
const action = payRefunded === orderPrice ? 'refundAll' : 'refundPartially';
|
||||
await context.operate('order', {
|
||||
id: await generateNewIdAsync(),
|
||||
action,
|
||||
|
|
@ -201,64 +201,6 @@ const triggers = [
|
|||
if (orderId) {
|
||||
return await changeOrderStateByPay({ id: orderId }, context, option);
|
||||
}
|
||||
else {
|
||||
assert(depositId && deposit);
|
||||
// 如果是支付成功,则使deposit成功(生成对应的accountOper,这里应该只有这条路径会让deposit成功)
|
||||
if (action === 'succeedPaying') {
|
||||
const payPrice = pay.price;
|
||||
const { price, loss } = deposit;
|
||||
assert(price === payPrice);
|
||||
const accountOpers = [
|
||||
{
|
||||
id: await generateNewIdAsync(),
|
||||
data: {
|
||||
id: await generateNewIdAsync(),
|
||||
totalPlus: price - loss,
|
||||
availPlus: price - loss,
|
||||
refundablePlus: pay.refundable ? price : 0,
|
||||
accountId: deposit.accountId,
|
||||
type: 'deposit',
|
||||
},
|
||||
action: 'create',
|
||||
}
|
||||
];
|
||||
if (loss > 0) {
|
||||
// 如果有loss就充入system的account账户
|
||||
const [account] = await context.select('account', {
|
||||
data: {
|
||||
id: 1,
|
||||
},
|
||||
filter: {
|
||||
entity: 'system',
|
||||
entityId: application?.systemId,
|
||||
},
|
||||
}, { dontCollect: true });
|
||||
accountOpers.push({
|
||||
id: await generateNewIdAsync(),
|
||||
data: {
|
||||
id: await generateNewIdAsync(),
|
||||
totalPlus: loss,
|
||||
availPlus: loss,
|
||||
accountId: account.id,
|
||||
type: 'earn',
|
||||
},
|
||||
action: 'create',
|
||||
});
|
||||
}
|
||||
await context.operate('deposit', {
|
||||
id: await generateNewIdAsync(),
|
||||
action: 'succeed',
|
||||
data: {
|
||||
accountOper$entity: accountOpers,
|
||||
},
|
||||
filter: {
|
||||
id: depositId,
|
||||
},
|
||||
}, {});
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
@ -371,7 +313,7 @@ const triggers = [
|
|||
},
|
||||
},
|
||||
{
|
||||
name: '当pay完成支付时,计算相应的account以及syste account中的余额变化',
|
||||
name: '当pay完成支付时,计算相应的account以及syste account中的余额变化,使deposit完成',
|
||||
entity: 'pay',
|
||||
action: 'succeedPaying',
|
||||
when: 'after',
|
||||
|
|
@ -389,7 +331,12 @@ const triggers = [
|
|||
orderId: 1,
|
||||
application: {
|
||||
systemId: 1,
|
||||
}
|
||||
},
|
||||
deposit: {
|
||||
id: 1,
|
||||
price: 1,
|
||||
loss: 1,
|
||||
},
|
||||
};
|
||||
const pays = await context.select('pay', {
|
||||
data: projection,
|
||||
|
|
@ -397,7 +344,7 @@ const triggers = [
|
|||
}, {});
|
||||
assert(pays.length === 1);
|
||||
const [pay] = pays;
|
||||
const { price, paid, entity, entityId, iState, applicationId, application } = pay;
|
||||
const { price, paid, entity, entityId, iState, applicationId, application, depositId, deposit } = pay;
|
||||
assert(iState === 'paid' && paid === price);
|
||||
const clazz = await getPayClazz(applicationId, entity, entityId, context);
|
||||
const [tax, sysAccountEntity, sysAccountEntityId] = clazz.calcPayTax(paid);
|
||||
|
|
@ -439,7 +386,59 @@ const triggers = [
|
|||
}, {});
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
if (depositId) {
|
||||
const payPrice = pay.price;
|
||||
const { price, loss } = deposit;
|
||||
assert(price === payPrice);
|
||||
const accountOpers = [
|
||||
{
|
||||
id: await generateNewIdAsync(),
|
||||
data: {
|
||||
id: await generateNewIdAsync(),
|
||||
totalPlus: price - loss,
|
||||
availPlus: price - loss,
|
||||
refundablePlus: pay.refundable ? price : 0,
|
||||
accountId: deposit.accountId,
|
||||
type: 'deposit',
|
||||
},
|
||||
action: 'create',
|
||||
}
|
||||
];
|
||||
await context.operate('deposit', {
|
||||
id: await generateNewIdAsync(),
|
||||
action: 'succeed',
|
||||
data: {
|
||||
accountOper$entity: accountOpers,
|
||||
},
|
||||
filter: {
|
||||
id: depositId,
|
||||
},
|
||||
}, {});
|
||||
if (loss > 0) {
|
||||
// 如果有loss就充入system的account账户
|
||||
const [account] = await context.select('account', {
|
||||
data: {
|
||||
id: 1,
|
||||
},
|
||||
filter: {
|
||||
entity: 'system',
|
||||
entityId: application?.systemId,
|
||||
},
|
||||
}, { dontCollect: true });
|
||||
accountOpers.push({
|
||||
id: await generateNewIdAsync(),
|
||||
data: {
|
||||
id: await generateNewIdAsync(),
|
||||
totalPlus: loss,
|
||||
availPlus: loss,
|
||||
accountId: account.id,
|
||||
type: 'earn',
|
||||
},
|
||||
action: 'create',
|
||||
});
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,13 +6,13 @@ import assert from 'assert';
|
|||
* @param context
|
||||
* @param refunds
|
||||
*/
|
||||
async function changeWithdrawStateByRefunds(context, refunds) {
|
||||
async function changeWithdrawStateByRefunds(context, id) {
|
||||
const withdraws = await context.select('withdraw', {
|
||||
data: {
|
||||
id: 1,
|
||||
iState: 1,
|
||||
price: 1,
|
||||
refund$entity: {
|
||||
refund$withdraw: {
|
||||
$entity: 'refund',
|
||||
data: {
|
||||
id: 1,
|
||||
|
|
@ -23,53 +23,309 @@ async function changeWithdrawStateByRefunds(context, refunds) {
|
|||
},
|
||||
},
|
||||
filter: {
|
||||
id: {
|
||||
$in: refunds.filter(ele => ele.entity === 'withdraw').map(ele => ele.entityId),
|
||||
}
|
||||
id,
|
||||
}
|
||||
}, { forUpdate: true });
|
||||
let count = 0;
|
||||
const [withdraw] = withdraws;
|
||||
const { price, iState, refund$withdraw: relatedRefunds } = withdraw;
|
||||
assert(iState === 'withdrawing');
|
||||
let dealPrice = 0;
|
||||
let dealLoss = 0;
|
||||
let allRefundsOver = true;
|
||||
for (const refund2 of relatedRefunds) {
|
||||
if (refund2.iState === 'refunding') {
|
||||
allRefundsOver = false;
|
||||
break;
|
||||
}
|
||||
if (refund2.iState === 'refunded') {
|
||||
dealPrice += refund2.price;
|
||||
dealLoss += refund2.loss;
|
||||
}
|
||||
}
|
||||
if (!allRefundsOver) {
|
||||
return 0;
|
||||
}
|
||||
const action = dealPrice === 0 ? 'fail' : (dealPrice === price ? 'succeed' : 'succeedPartially');
|
||||
await context.operate('withdraw', {
|
||||
id: await generateNewIdAsync(),
|
||||
action,
|
||||
data: {
|
||||
dealPrice,
|
||||
dealLoss,
|
||||
},
|
||||
filter: {
|
||||
id: withdraw.id,
|
||||
}
|
||||
}, {});
|
||||
let count = 0;
|
||||
for (const withdraw of withdraws) {
|
||||
const { price, iState, refund$entity: relatedRefunds } = withdraw;
|
||||
assert(iState === 'withdrawing');
|
||||
let dealPrice = 0;
|
||||
let dealLoss = 0;
|
||||
let allRefundsOver = true;
|
||||
for (const refund2 of relatedRefunds) {
|
||||
if (refund2.iState === 'refunding') {
|
||||
allRefundsOver = false;
|
||||
break;
|
||||
return 1;
|
||||
}
|
||||
/**
|
||||
* 开始退款的逻辑
|
||||
* @param context
|
||||
* @param data
|
||||
*/
|
||||
async function startRefunding(context, data) {
|
||||
assert(!data.pay && data.payId);
|
||||
const [pay] = await context.select('pay', {
|
||||
data: {
|
||||
id: 1,
|
||||
paid: 1,
|
||||
refunded: 1,
|
||||
iState: 1,
|
||||
deposit: {
|
||||
id: 1,
|
||||
accountId: 1,
|
||||
},
|
||||
order: {
|
||||
id: 1,
|
||||
settled: 1,
|
||||
}
|
||||
if (refund2.iState === 'refunded') {
|
||||
dealPrice += refund2.price;
|
||||
dealLoss += refund2.loss;
|
||||
},
|
||||
}, { dontCollect: true });
|
||||
const { paid, refunded, deposit, order } = pay;
|
||||
assert(paid - refunded >= data.price);
|
||||
if (deposit) {
|
||||
// 是提现,其Account相应的计算在withdraw进行
|
||||
assert(data.withdrawId);
|
||||
}
|
||||
else {
|
||||
assert(order);
|
||||
if (order.settled) {
|
||||
// 如果已经分账,退款的钱要有明确的来源account
|
||||
const { accountOper$entity: opers } = data;
|
||||
assert(opers && opers instanceof Array, '订单退款一定要有相应的account来源');
|
||||
let amount = 0;
|
||||
opers.forEach(({ action, data }) => {
|
||||
assert(action === 'create');
|
||||
const { type, totalPlus, availPlus, refundablePlus } = data;
|
||||
assert(type === 'refund');
|
||||
assert(totalPlus === availPlus);
|
||||
amount += totalPlus;
|
||||
});
|
||||
assert(amount === data.price);
|
||||
}
|
||||
}
|
||||
data.pay = {
|
||||
id: generateNewId(),
|
||||
action: 'startRefunding',
|
||||
data: {},
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 退款成功的逻辑
|
||||
* @param context
|
||||
* @param data
|
||||
*/
|
||||
async function succeedRefunding(context, refundId) {
|
||||
const pays = await context.select('pay', {
|
||||
data: {
|
||||
id: 1,
|
||||
price: 1,
|
||||
refunded: 1,
|
||||
entity: 1,
|
||||
entityId: 1,
|
||||
iState: 1,
|
||||
applicationId: 1,
|
||||
application: {
|
||||
systemId: 1,
|
||||
},
|
||||
deposit: {
|
||||
id: 1,
|
||||
accountId: 1,
|
||||
},
|
||||
refund$pay: {
|
||||
$entity: 'refund',
|
||||
data: {
|
||||
id: 1,
|
||||
price: 1,
|
||||
iState: 1,
|
||||
entity: 1,
|
||||
entityId: 1,
|
||||
withdrawId: 1,
|
||||
},
|
||||
filter: {
|
||||
id: refundId,
|
||||
},
|
||||
}
|
||||
},
|
||||
filter: {
|
||||
refund$pay: {
|
||||
'#sqp': 'in',
|
||||
id: refundId,
|
||||
},
|
||||
}
|
||||
if (!allRefundsOver) {
|
||||
continue;
|
||||
}, { forUpdate: true, dontCollect: true });
|
||||
assert(pays.length === 1);
|
||||
const [pay] = pays;
|
||||
const { price, paid, refunded, refund$pay: refunds, application, applicationId, entity, entityId } = pay;
|
||||
assert(refunds.length === 1);
|
||||
const [refund] = refunds;
|
||||
const { price: refundPrice, loss: refundLoss, withdrawId } = refund;
|
||||
const refunded2 = refunded + refundPrice;
|
||||
assert(refunded2 <= paid);
|
||||
const action = refunded2 === paid ? 'refundAll' : 'refundPartially';
|
||||
await context.operate('pay', {
|
||||
id: await generateNewIdAsync(),
|
||||
action,
|
||||
data: {
|
||||
refunded: refunded2,
|
||||
},
|
||||
filter: {
|
||||
id: pay.id,
|
||||
}
|
||||
const action = dealPrice === 0 ? 'fail' : (dealPrice === price ? 'succeed' : 'succeedPartially');
|
||||
await context.operate('withdraw', {
|
||||
}, {});
|
||||
const payClazz = await getPayClazz(applicationId, entity, entityId, context);
|
||||
// 实际执行的退款的额度应该是price - loss
|
||||
const [delta, sysAccountEntity, sysAccountEntityId] = payClazz.calcRefundTax(refundPrice - refundLoss);
|
||||
// sysAccount上减掉实际退款的额度
|
||||
await context.operate('sysAccountOper', {
|
||||
id: await generateNewIdAsync(),
|
||||
action: 'create',
|
||||
data: {
|
||||
id: await generateNewIdAsync(),
|
||||
action,
|
||||
delta: refundLoss - refundPrice,
|
||||
entity: sysAccountEntity,
|
||||
entityId: sysAccountEntityId,
|
||||
refundId: refund.id,
|
||||
type: 'refund',
|
||||
}
|
||||
}, {});
|
||||
let cnt = 2;
|
||||
if (delta !== 0) {
|
||||
// 如果有退回或者要缴纳的税费,进入system相关联的account账户
|
||||
const [account] = await context.select('account', {
|
||||
data: {
|
||||
dealPrice,
|
||||
dealLoss,
|
||||
id: 1,
|
||||
},
|
||||
filter: {
|
||||
id: withdraw.id,
|
||||
}
|
||||
entity: 'system',
|
||||
entityId: application.systemId,
|
||||
},
|
||||
}, { dontCollect: true });
|
||||
await context.operate('accountOper', {
|
||||
id: await generateNewIdAsync(),
|
||||
action: 'create',
|
||||
data: {
|
||||
id: await generateNewIdAsync(),
|
||||
accountId: account.id,
|
||||
type: delta < 0 ? 'taxRefund' : 'tax',
|
||||
totalPlus: -delta,
|
||||
availPlus: -delta,
|
||||
entity: 'refund',
|
||||
entityId: refund.id,
|
||||
},
|
||||
}, {});
|
||||
count++;
|
||||
cnt++;
|
||||
}
|
||||
// 如果有withdraw,尝试去同步withdraw的状态
|
||||
if (withdrawId) {
|
||||
return cnt + await changeWithdrawStateByRefunds(context, withdrawId);
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
async function failRefunding(context, refundId) {
|
||||
const pays = await context.select('pay', {
|
||||
data: {
|
||||
id: 1,
|
||||
price: 1,
|
||||
refunded: 1,
|
||||
entity: 1,
|
||||
entityId: 1,
|
||||
iState: 1,
|
||||
applicationId: 1,
|
||||
application: {
|
||||
systemId: 1,
|
||||
},
|
||||
deposit: {
|
||||
id: 1,
|
||||
accountId: 1,
|
||||
},
|
||||
refund$pay: {
|
||||
$entity: 'refund',
|
||||
data: {
|
||||
id: 1,
|
||||
price: 1,
|
||||
iState: 1,
|
||||
entity: 1,
|
||||
entityId: 1,
|
||||
withdrawId: 1,
|
||||
},
|
||||
filter: {
|
||||
id: refundId,
|
||||
},
|
||||
}
|
||||
},
|
||||
filter: {
|
||||
refund$pay: {
|
||||
'#sqp': 'in',
|
||||
id: refundId,
|
||||
},
|
||||
}
|
||||
}, { forUpdate: true, dontCollect: true });
|
||||
assert(pays.length === 1);
|
||||
const [pay] = pays;
|
||||
const { refunded, refund$pay: refunds } = pay;
|
||||
assert(refunds.length === 1);
|
||||
const [refund] = refunds;
|
||||
const { withdrawId } = refund;
|
||||
const action = refunded === 0 ? 'stopRefunding' : 'refundPartially';
|
||||
await context.operate('pay', {
|
||||
id: await generateNewIdAsync(),
|
||||
action,
|
||||
data: {},
|
||||
filter: {
|
||||
id: pay.id,
|
||||
}
|
||||
}, {});
|
||||
// 如果有withdraw,尝试去同步withdraw的状态
|
||||
if (withdrawId) {
|
||||
return 1 + await changeWithdrawStateByRefunds(context, withdrawId);
|
||||
}
|
||||
else {
|
||||
// 说明是从order那条线产生的refund,此时要把当时扣除掉的account部分返还
|
||||
const accountOpers = await context.select('accountOper', {
|
||||
data: {
|
||||
id: 1,
|
||||
totalPlus: 1,
|
||||
availPlus: 1,
|
||||
accountId: 1,
|
||||
},
|
||||
filter: {
|
||||
type: 'refund',
|
||||
entity: 'refund',
|
||||
entityId: refundId,
|
||||
},
|
||||
}, { dontCollect: true });
|
||||
let amount = 0;
|
||||
for (const oper of accountOpers) {
|
||||
const { totalPlus, availPlus, accountId } = oper;
|
||||
assert(totalPlus < 0 && totalPlus === availPlus);
|
||||
await context.operate('accountOper', {
|
||||
id: await generateNewIdAsync(),
|
||||
action: 'create',
|
||||
data: {
|
||||
id: await generateNewIdAsync(),
|
||||
totalPlus: -totalPlus,
|
||||
availPlus: -availPlus,
|
||||
type: 'refundFailure',
|
||||
entity: 'refund',
|
||||
entityId: refundId,
|
||||
accountId,
|
||||
}
|
||||
}, {});
|
||||
amount += -availPlus;
|
||||
}
|
||||
assert(amount === refund.price);
|
||||
return 1 + accountOpers.length;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
const triggers = [
|
||||
{
|
||||
entity: 'refund',
|
||||
action: 'create',
|
||||
when: 'commit',
|
||||
name: '当refund建立时,触发外部退款操作',
|
||||
name: '当refund建立时,尝试触发外部退款操作',
|
||||
strict: 'makeSure',
|
||||
fn: async ({ ids }, context) => {
|
||||
const refunds = await context.select('refund', {
|
||||
|
|
@ -121,90 +377,9 @@ const triggers = [
|
|||
name: '退款成功时,更新对应的pay状态以及对应的withdraw状态',
|
||||
fn: async ({ operation }, context) => {
|
||||
const { filter } = operation;
|
||||
const payProj = {
|
||||
id: 1,
|
||||
price: 1,
|
||||
refunded: 1,
|
||||
entity: 1,
|
||||
entityId: 1,
|
||||
iState: 1,
|
||||
applicationId: 1,
|
||||
application: {
|
||||
systemId: 1,
|
||||
}
|
||||
};
|
||||
const refunds = await context.select('refund', {
|
||||
data: {
|
||||
id: 1,
|
||||
price: 1,
|
||||
iState: 1,
|
||||
entity: 1,
|
||||
entityId: 1,
|
||||
pay: payProj,
|
||||
loss: 1,
|
||||
},
|
||||
filter,
|
||||
}, {});
|
||||
for (const refund of refunds) {
|
||||
const { price, iState, pay, loss } = refund;
|
||||
assert(iState === 'refunded' && pay.iState === 'refunding');
|
||||
const { price: payPrice, refunded, entity, entityId, applicationId, application } = pay;
|
||||
const refunded2 = refunded + price;
|
||||
assert(refunded2 <= payPrice, '退款金额不应高于pay的总金额');
|
||||
const action = refunded2 === payPrice ? 'refundAll' : 'refundPartially';
|
||||
await context.operate('pay', {
|
||||
id: await generateNewIdAsync(),
|
||||
action,
|
||||
data: {
|
||||
refunded: refunded2,
|
||||
},
|
||||
filter: {
|
||||
id: pay.id,
|
||||
}
|
||||
}, {});
|
||||
const payClazz = await getPayClazz(applicationId, entity, entityId, context);
|
||||
// 实际执行的退款的额度应该是price - loss
|
||||
const [delta, sysAccountEntity, sysAccountEntityId] = payClazz.calcRefundTax(price - loss);
|
||||
// sysAccount上减掉实际退款的额度
|
||||
await context.operate('sysAccountOper', {
|
||||
id: await generateNewIdAsync(),
|
||||
action: 'create',
|
||||
data: {
|
||||
id: await generateNewIdAsync(),
|
||||
delta: loss - price,
|
||||
entity: sysAccountEntity,
|
||||
entityId: sysAccountEntityId,
|
||||
refundId: refund.id,
|
||||
type: 'refund',
|
||||
}
|
||||
}, {});
|
||||
if (delta !== 0) {
|
||||
// 如果有退回或者要缴纳的税费,进入system相关联的account账户
|
||||
const [account] = await context.select('account', {
|
||||
data: {
|
||||
id: 1,
|
||||
},
|
||||
filter: {
|
||||
entity: 'system',
|
||||
entityId: application.systemId,
|
||||
},
|
||||
}, { dontCollect: true });
|
||||
await context.operate('accountOper', {
|
||||
id: await generateNewIdAsync(),
|
||||
action: 'create',
|
||||
data: {
|
||||
id: await generateNewIdAsync(),
|
||||
accountId: account.id,
|
||||
type: delta < 0 ? 'taxRefund' : 'tax',
|
||||
totalPlus: -delta,
|
||||
availPlus: -delta,
|
||||
entity: 'refund',
|
||||
entityId: refund.id,
|
||||
},
|
||||
}, {});
|
||||
}
|
||||
}
|
||||
return refunds.length + await changeWithdrawStateByRefunds(context, refunds);
|
||||
const refundId = filter?.['#id'];
|
||||
assert(typeof refundId === 'string');
|
||||
return succeedRefunding(context, refundId);
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
@ -215,66 +390,21 @@ const triggers = [
|
|||
name: '退款失败时,更新对应的pay状态以及对应的withdraw状态',
|
||||
fn: async ({ operation }, context) => {
|
||||
const { filter } = operation;
|
||||
const refunds = await context.select('refund', {
|
||||
data: {
|
||||
id: 1,
|
||||
price: 1,
|
||||
iState: 1,
|
||||
entity: 1,
|
||||
entityId: 1,
|
||||
pay: {
|
||||
id: 1,
|
||||
price: 1,
|
||||
iState: 1,
|
||||
refunded: 1,
|
||||
applicationId: 1,
|
||||
orderId: 1,
|
||||
},
|
||||
},
|
||||
filter,
|
||||
}, {});
|
||||
for (const refund of refunds) {
|
||||
const { id, iState, pay } = refund;
|
||||
assert(iState === 'failed' && pay.iState === 'refunding');
|
||||
const { refunded } = pay;
|
||||
const action = refunded === 0 ? 'stopRefunding' : 'refundPartially';
|
||||
await context.operate('pay', {
|
||||
id: await generateNewIdAsync(),
|
||||
action,
|
||||
data: {},
|
||||
filter: {
|
||||
id: pay.id,
|
||||
}
|
||||
}, {});
|
||||
}
|
||||
return refunds.length + await changeWithdrawStateByRefunds(context, refunds);
|
||||
const refundId = filter?.['#id'];
|
||||
assert(typeof refundId === 'string');
|
||||
return failRefunding(context, refundId);
|
||||
}
|
||||
},
|
||||
{
|
||||
entity: 'refund',
|
||||
name: '当发起退款时,将对应的pay置退款中状态',
|
||||
name: '当发起退款时,置pay的状态并做相应检查',
|
||||
action: 'create',
|
||||
asRoot: true,
|
||||
when: 'before',
|
||||
fn: async ({ operation }, context) => {
|
||||
const { data } = operation;
|
||||
if (data instanceof Array) {
|
||||
data.forEach((refund) => {
|
||||
assert(!refund.pay && refund.payId);
|
||||
refund.pay = {
|
||||
id: generateNewId(),
|
||||
action: 'startRefunding',
|
||||
data: {},
|
||||
};
|
||||
});
|
||||
}
|
||||
else {
|
||||
data.pay = {
|
||||
id: generateNewId(),
|
||||
action: 'startRefunding',
|
||||
data: {},
|
||||
};
|
||||
}
|
||||
assert(!(data instanceof Array));
|
||||
await startRefunding(context, data);
|
||||
return 1;
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ const triggers = [
|
|||
fn: async ({ operation }, context, option) => {
|
||||
const { data } = operation;
|
||||
assert(!(data instanceof Array));
|
||||
const { accountId, price, refund$entity: refunds, withdrawTransfer$withdraw: transfers } = data;
|
||||
const { accountId, price, refund$withdraw: refunds, withdrawTransfer$withdraw: transfers } = data;
|
||||
let refundAmount = 0;
|
||||
refunds?.forEach(({ data }) => {
|
||||
const { price } = data;
|
||||
|
|
@ -56,7 +56,6 @@ const triggers = [
|
|||
iState: 1,
|
||||
price: 1,
|
||||
dealPrice: 1,
|
||||
withdrawAccountId: 1,
|
||||
},
|
||||
filter,
|
||||
}, {});
|
||||
|
|
@ -94,7 +93,6 @@ const triggers = [
|
|||
iState: 1,
|
||||
price: 1,
|
||||
dealPrice: 1,
|
||||
withdrawAccountId: 1,
|
||||
},
|
||||
filter,
|
||||
}, {});
|
||||
|
|
|
|||
|
|
@ -14,5 +14,4 @@ type CalcLoss = <ED extends EntityDict & BaseEntityDict>(entityId: string, appli
|
|||
* @param application
|
||||
*/
|
||||
export declare function getDepositLoss<ED extends EntityDict & BaseEntityDict>(price: number, application: ED['application']['Schema']): ReturnType<CalcLoss>;
|
||||
export declare function getAccountPayRefunds<ED extends EntityDict & BaseEntityDict>(context: BackendRuntimeContext<ED>, accountId: string, totalPrice?: number): Promise<Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "entity" | "entityId">[]>;
|
||||
export {};
|
||||
|
|
|
|||
136
es/utils/pay.js
136
es/utils/pay.js
|
|
@ -83,63 +83,6 @@ export async function payNotify(context, body, payId, headers) {
|
|||
}
|
||||
return;
|
||||
}
|
||||
/* const CalcRefundLossDict: Record<string, {
|
||||
projection: EntityDict['application']['Selection']['data'],
|
||||
fn: CalcLoss,
|
||||
}> = {
|
||||
'wpProduct': {
|
||||
projection: {
|
||||
wpProduct$application: {
|
||||
$entity: 'wpProduct',
|
||||
data: {
|
||||
id: 1,
|
||||
wpAccount: {
|
||||
id: 1,
|
||||
refundLossFloor: 1,
|
||||
refundLossRatio: 1,
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
fn: (entityId, application, price) => {
|
||||
const { wpProduct$application: wpProducts } = application;
|
||||
const wpProduct = wpProducts!.find(ele => ele.id === entityId);
|
||||
const { refundLossFloor, refundLossRatio } = wpProduct!.wpAccount!;
|
||||
if (refundLossRatio) {
|
||||
return [
|
||||
Math.ceil(price * refundLossRatio / 100),
|
||||
'common::refund.lossReason.ratio',
|
||||
{ value: refundLossRatio },
|
||||
];
|
||||
}
|
||||
else if (refundLossFloor) {
|
||||
let loss = 0;
|
||||
switch (refundLossFloor) {
|
||||
case 'jiao': {
|
||||
loss = price - Math.floor(price / 10) * 10;
|
||||
break;
|
||||
}
|
||||
case 'yuan': {
|
||||
loss = price - Math.floor(price / 100) * 100;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return [loss, 'common::refund.lossReason.floor', { unit: refundLossFloor }];
|
||||
}
|
||||
return [0, '', undefined];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export function registerCalcRefundLoss<ED extends EntityDict & BaseEntityDict>(entity: string, projection: ED['application']['Selection']['data'], fn: CalcLoss) {
|
||||
assert(!CalcRefundLossDict[entity], `${entity}上已经定义了CalcLoss`);
|
||||
CalcRefundLossDict[entity] = {
|
||||
projection,
|
||||
fn,
|
||||
};
|
||||
}
|
||||
*/
|
||||
/**
|
||||
* 计算充值的损耗比例
|
||||
* attention: 这个函数目前是在前端调用的
|
||||
|
|
@ -166,82 +109,3 @@ export function getDepositLoss(price, application) {
|
|||
}
|
||||
return [0, '', undefined];
|
||||
}
|
||||
export async function getAccountPayRefunds(context, accountId, totalPrice) {
|
||||
const refundData = [];
|
||||
/* const appProj: EntityDict['application']['Selection']['data'] = {
|
||||
id: 1,
|
||||
};
|
||||
for (const k in CalcRefundLossDict) {
|
||||
merge(appProj, CalcRefundLossDict[k].projection);
|
||||
}
|
||||
const pays = await context.select('pay', {
|
||||
data: {
|
||||
id: 1,
|
||||
price: 1,
|
||||
paid: 1,
|
||||
refundable: 1,
|
||||
refunded: 1,
|
||||
entity: 1,
|
||||
entityId: 1,
|
||||
application: appProj,
|
||||
},
|
||||
filter: {
|
||||
refundable: true,
|
||||
deposit: {
|
||||
accountId,
|
||||
},
|
||||
orderId: {
|
||||
$exists: false,
|
||||
},
|
||||
},
|
||||
sorter: [
|
||||
{
|
||||
$attr: {
|
||||
forbidRefundAt: 1,
|
||||
},
|
||||
$direction: 'asc',
|
||||
}
|
||||
],
|
||||
}, { dontCollect: true, forUpdate: true });
|
||||
|
||||
let price2 = 0;
|
||||
|
||||
for (const pay of pays) {
|
||||
const { price, paid, refunded, refundable, entity, entityId, application } = pay;
|
||||
assert(price === paid && refundable);
|
||||
assert(!['account', 'offlineAccount'].includes(entity!));
|
||||
|
||||
const rest = paid! - refunded!;
|
||||
assert(rest > 0);
|
||||
let refundPrice = rest;
|
||||
if (totalPrice && totalPrice - price2 < rest) {
|
||||
refundPrice = totalPrice - price2;
|
||||
}
|
||||
const [loss, lossExplanation, lossExplanationParams] = CalcRefundLossDict[entity!]!.fn(entityId!, application as EntityDict['application']['Schema'], price!);
|
||||
|
||||
refundData.push({
|
||||
id: await generateNewIdAsync(),
|
||||
price: refundPrice,
|
||||
loss,
|
||||
creatorId: context.getCurrentUserId(),
|
||||
payId: pay.id!,
|
||||
iState: 'refunding',
|
||||
meta: {
|
||||
channel: entity,
|
||||
lossExplanation,
|
||||
lossExplanationParams,
|
||||
}
|
||||
});
|
||||
|
||||
price2 += refundPrice;
|
||||
|
||||
if (totalPrice && price2 === totalPrice) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (totalPrice && price2 < totalPrice) {
|
||||
throw new RefundExceedMax();
|
||||
} */
|
||||
return refundData;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import WechatPay from './WechatPay';
|
||||
import WechatPayDebug from './WechatPay.debug';
|
||||
declare const _default: typeof WechatPay | typeof WechatPayDebug;
|
||||
declare const _default: typeof WechatPayDebug | typeof WechatPay;
|
||||
export default _default;
|
||||
|
|
|
|||
|
|
@ -12,12 +12,12 @@ export declare function getWithdrawCreateData(params: {
|
|||
creatorId: string;
|
||||
creator?: import("../oak-app-domain/User/Schema").UpdateOperation | undefined;
|
||||
} & {
|
||||
refund$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "withdraw" | "withdrawId">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "withdraw" | "withdrawId">>)[] | undefined;
|
||||
sysAccountOper$withdraw?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/SysAccountOper/Schema").CreateOperationData, "withdraw" | "withdrawId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/SysAccountOper/Schema").CreateOperationData, "withdraw" | "withdrawId">>[] | undefined;
|
||||
withdrawTransfer$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/WithdrawTransfer/Schema").CreateOperationData, "withdraw" | "withdrawId">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/WithdrawTransfer/Schema").CreateOperationData, "withdraw" | "withdrawId">>)[] | undefined;
|
||||
modiEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/ModiEntity/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/ModiEntity/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
|
||||
operEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/OperEntity/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/OperEntity/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
|
||||
accountOper$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/AccountOper/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/AccountOper/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
|
||||
refund$entity?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "entity" | "entityId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "entity" | "entityId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "entity" | "entityId">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "entity" | "entityId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "entity" | "entityId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "entity" | "entityId">>)[] | undefined;
|
||||
}) | (Partial<Omit<import("../oak-app-domain/Withdraw/Schema").OpSchema, "accountId" | "creatorId">> & {
|
||||
id: string;
|
||||
} & {
|
||||
|
|
@ -27,12 +27,12 @@ export declare function getWithdrawCreateData(params: {
|
|||
creator?: undefined;
|
||||
creatorId: string;
|
||||
} & {
|
||||
refund$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "withdraw" | "withdrawId">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "withdraw" | "withdrawId">>)[] | undefined;
|
||||
sysAccountOper$withdraw?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/SysAccountOper/Schema").CreateOperationData, "withdraw" | "withdrawId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/SysAccountOper/Schema").CreateOperationData, "withdraw" | "withdrawId">>[] | undefined;
|
||||
withdrawTransfer$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/WithdrawTransfer/Schema").CreateOperationData, "withdraw" | "withdrawId">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/WithdrawTransfer/Schema").CreateOperationData, "withdraw" | "withdrawId">>)[] | undefined;
|
||||
modiEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/ModiEntity/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/ModiEntity/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
|
||||
operEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/OperEntity/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/OperEntity/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
|
||||
accountOper$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/AccountOper/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/AccountOper/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
|
||||
refund$entity?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "entity" | "entityId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "entity" | "entityId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "entity" | "entityId">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "entity" | "entityId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "entity" | "entityId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "entity" | "entityId">>)[] | undefined;
|
||||
}) | (Partial<Omit<import("../oak-app-domain/Withdraw/Schema").OpSchema, "accountId" | "creatorId">> & {
|
||||
id: string;
|
||||
} & {
|
||||
|
|
@ -42,12 +42,12 @@ export declare function getWithdrawCreateData(params: {
|
|||
creatorId: string;
|
||||
creator?: import("../oak-app-domain/User/Schema").UpdateOperation | undefined;
|
||||
} & {
|
||||
refund$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "withdraw" | "withdrawId">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "withdraw" | "withdrawId">>)[] | undefined;
|
||||
sysAccountOper$withdraw?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/SysAccountOper/Schema").CreateOperationData, "withdraw" | "withdrawId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/SysAccountOper/Schema").CreateOperationData, "withdraw" | "withdrawId">>[] | undefined;
|
||||
withdrawTransfer$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/WithdrawTransfer/Schema").CreateOperationData, "withdraw" | "withdrawId">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/WithdrawTransfer/Schema").CreateOperationData, "withdraw" | "withdrawId">>)[] | undefined;
|
||||
modiEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/ModiEntity/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/ModiEntity/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
|
||||
operEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/OperEntity/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/OperEntity/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
|
||||
accountOper$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/AccountOper/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/AccountOper/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
|
||||
refund$entity?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "entity" | "entityId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "entity" | "entityId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "entity" | "entityId">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "entity" | "entityId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "entity" | "entityId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "entity" | "entityId">>)[] | undefined;
|
||||
}) | (Partial<Omit<import("../oak-app-domain/Withdraw/Schema").OpSchema, "accountId" | "creatorId">> & {
|
||||
id: string;
|
||||
} & {
|
||||
|
|
@ -57,10 +57,10 @@ export declare function getWithdrawCreateData(params: {
|
|||
creator?: undefined;
|
||||
creatorId: string;
|
||||
} & {
|
||||
refund$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "withdraw" | "withdrawId">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "withdraw" | "withdrawId">>)[] | undefined;
|
||||
sysAccountOper$withdraw?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/SysAccountOper/Schema").CreateOperationData, "withdraw" | "withdrawId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/SysAccountOper/Schema").CreateOperationData, "withdraw" | "withdrawId">>[] | undefined;
|
||||
withdrawTransfer$withdraw?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/WithdrawTransfer/Schema").CreateOperationData, "withdraw" | "withdrawId">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").UpdateOperationData, "withdraw" | "withdrawId">, Omit<import("../oak-app-domain/WithdrawTransfer/Schema").Filter, "withdraw" | "withdrawId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/WithdrawTransfer/Schema").CreateOperationData, "withdraw" | "withdrawId">>)[] | undefined;
|
||||
modiEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/ModiEntity/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/ModiEntity/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
|
||||
operEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/OperEntity/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/OperEntity/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
|
||||
accountOper$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/AccountOper/Schema").CreateOperationData, "entity" | "entityId">[]> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/AccountOper/Schema").CreateOperationData, "entity" | "entityId">>[] | undefined;
|
||||
refund$entity?: import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "entity" | "entityId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "entity" | "entityId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "entity" | "entityId">[]> | (import("oak-domain/lib/types").Operation<string, Omit<import("../oak-app-domain/Refund/Schema").UpdateOperationData, "entity" | "entityId">, Omit<import("../oak-app-domain/Refund/Schema").Filter, "entity" | "entityId">> | import("oak-domain/lib/types").Operation<"create", Omit<import("../oak-app-domain/Refund/Schema").CreateOperationData, "entity" | "entityId">>)[] | undefined;
|
||||
})>;
|
||||
|
|
|
|||
|
|
@ -141,14 +141,14 @@ async function getWithdrawCreateData(params, context) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
data.refund$entity = await Promise.all(refundData.map(async (ele) => ({
|
||||
data.refund$withdraw = await Promise.all(refundData.map(async (ele) => ({
|
||||
id: await (0, uuid_1.generateNewIdAsync)(),
|
||||
action: 'create',
|
||||
data: ele,
|
||||
})));
|
||||
}
|
||||
else {
|
||||
data.refund$entity = [];
|
||||
data.refund$withdraw = [];
|
||||
}
|
||||
if (totalPrice > price2) {
|
||||
// 如果还有要退的部分,就从withdrawAccount来进行转账
|
||||
|
|
|
|||
|
|
@ -54,12 +54,14 @@ const checkers = [
|
|||
}
|
||||
break;
|
||||
}
|
||||
case 'refund':
|
||||
case 'withdraw': {
|
||||
if (totalPlus >= 0 || availPlus >= 0 || totalPlus !== availPlus) {
|
||||
throw new types_1.OakInputIllegalException('accountOper', ['availPlus'], 'accountOper为withdraw时,其totalPlus和availPlus必须为不相等的负数');
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'refundFailure':
|
||||
case 'withdrawBack': {
|
||||
if (totalPlus <= 0 || availPlus <= 0 || totalPlus !== availPlus) {
|
||||
throw new types_1.OakInputIllegalException('accountOper', ['availPlus'], 'accountOper为withdraw时,其totalPlus和availPlus必须为不相等的正数');
|
||||
|
|
@ -90,7 +92,7 @@ const checkers = [
|
|||
}
|
||||
break;
|
||||
}
|
||||
case 'tax': {
|
||||
case 'taxRefund': {
|
||||
if (totalPlus <= 0 || availPlus <= 0 || totalPlus !== availPlus) {
|
||||
throw new types_1.OakInputIllegalException('accountOper', ['totalPlus', 'availPlus'], 'accountOper为taxRefund时,其totalPlus/availPlus必须为正且相等');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const tslib_1 = require("tslib");
|
||||
const assert_1 = tslib_1.__importDefault(require("assert"));
|
||||
const executor_1 = require("oak-domain/lib/utils/executor");
|
||||
const checkers = [
|
||||
{
|
||||
type: 'logical',
|
||||
|
|
@ -12,7 +15,45 @@ const checkers = [
|
|||
}
|
||||
data.paid = 0;
|
||||
data.refunded = 0;
|
||||
return 1;
|
||||
data.settled = false;
|
||||
}
|
||||
},
|
||||
{
|
||||
// 订单结算,将收入分帐到相关的Account中
|
||||
type: 'logical',
|
||||
entity: 'order',
|
||||
action: 'settle',
|
||||
checker: (operation, context) => {
|
||||
const { data, filter } = operation;
|
||||
(0, assert_1.default)(typeof filter.id === 'string');
|
||||
data.settled = true;
|
||||
return (0, executor_1.pipeline)(() => context.select('order', {
|
||||
data: {
|
||||
id: 1,
|
||||
price: 1,
|
||||
paid: 1,
|
||||
refunded: 1,
|
||||
iState: 1,
|
||||
},
|
||||
filter: {
|
||||
id: filter.id,
|
||||
},
|
||||
}, {}), (orders) => {
|
||||
const [order] = orders;
|
||||
const { price, paid, refunded, iState } = order;
|
||||
(0, assert_1.default)(['paid', 'partiallyRefunded'].includes(iState));
|
||||
const { accountOper$entity: opers } = data;
|
||||
(0, assert_1.default)(opers instanceof Array);
|
||||
let amount = 0;
|
||||
opers.forEach(({ action, data }) => {
|
||||
(0, assert_1.default)(action === 'create');
|
||||
const { type, totalPlus, availPlus, refundablePlus } = data;
|
||||
(0, assert_1.default)(type === 'earn');
|
||||
(0, assert_1.default)(totalPlus === availPlus);
|
||||
amount += totalPlus;
|
||||
});
|
||||
(0, assert_1.default)(amount === paid - refunded);
|
||||
});
|
||||
}
|
||||
}
|
||||
];
|
||||
|
|
|
|||
|
|
@ -14,10 +14,25 @@ exports.default = OakComponent({
|
|||
systemId: 1,
|
||||
price: 1,
|
||||
enabled: 1,
|
||||
taxLossRatio: 1,
|
||||
refundCompensateRatio: 1,
|
||||
refundGapDays: 1,
|
||||
allowWithdrawTransfer: 1,
|
||||
withdrawTransferLossRatio: 1,
|
||||
},
|
||||
properties: {
|
||||
systemId: '',
|
||||
},
|
||||
filters: [
|
||||
{
|
||||
filter() {
|
||||
const { systemId } = this.props;
|
||||
return {
|
||||
systemId,
|
||||
};
|
||||
}
|
||||
}
|
||||
],
|
||||
formData({ data, legalActions }) {
|
||||
return {
|
||||
accounts: data.map((ele) => {
|
||||
|
|
|
|||
|
|
@ -10,4 +10,5 @@ export default function render(props: WebComponentProps<EntityDict, 'system', fa
|
|||
system: RowWithActions<EntityDict, 'system'>;
|
||||
operation?: EntityDict['system']['Update'];
|
||||
serverUrl?: string;
|
||||
canUpdate?: boolean;
|
||||
}>): import("react/jsx-runtime").JSX.Element | null;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ function PayConfig(props) {
|
|||
const withdrawLoss = payConfig?.withdrawLoss;
|
||||
const depositLoss = payConfig?.depositLoss;
|
||||
const updateDepositLoss = (data) => {
|
||||
update({
|
||||
update && update({
|
||||
depositLoss: {
|
||||
...depositLoss,
|
||||
...data,
|
||||
|
|
@ -30,7 +30,7 @@ function PayConfig(props) {
|
|||
});
|
||||
};
|
||||
const updateWithdrawLoss = (data) => {
|
||||
update({
|
||||
update && update({
|
||||
depositLoss: depositLoss || {},
|
||||
withdrawLoss: {
|
||||
conservative: !!(withdrawLoss?.conservative),
|
||||
|
|
@ -39,43 +39,43 @@ function PayConfig(props) {
|
|||
},
|
||||
});
|
||||
};
|
||||
return ((0, jsx_runtime_1.jsxs)(antd_1.Flex, { gap: "middle", children: [(0, jsx_runtime_1.jsx)(antd_1.Card, { title: t('payConfig.label.depositLoss'), extra: (0, jsx_runtime_1.jsx)(antd_1.Popover, { content: t("payConfig.help.depositLoss"), children: (0, jsx_runtime_1.jsx)("span", { className: web_pc_module_less_1.default.help, children: t("help") }) }), children: (0, jsx_runtime_1.jsxs)(antd_1.Form, { labelCol: { span: 8 }, wrapperCol: { span: 18 }, layout: "horizontal", style: { width: '100%' }, children: [(0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: t('payConfig.label.ratio'), children: (0, jsx_runtime_1.jsx)(antd_1.InputNumber, { value: depositLoss?.ratio, max: 20, min: 0.01, addonAfter: "%", step: 0.01, precision: 2, onChange: (value) => {
|
||||
return ((0, jsx_runtime_1.jsxs)(antd_1.Flex, { gap: "middle", children: [(0, jsx_runtime_1.jsx)(antd_1.Card, { title: t('payConfig.label.depositLoss'), extra: (0, jsx_runtime_1.jsx)(antd_1.Popover, { content: t("payConfig.help.depositLoss"), children: (0, jsx_runtime_1.jsx)("span", { className: web_pc_module_less_1.default.help, children: t("help") }) }), children: (0, jsx_runtime_1.jsxs)(antd_1.Form, { labelCol: { span: 8 }, wrapperCol: { span: 18 }, layout: "horizontal", style: { width: '100%' }, children: [(0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: t('payConfig.label.ratio'), children: (0, jsx_runtime_1.jsx)(antd_1.InputNumber, { value: depositLoss?.ratio, max: 20, min: 0.01, addonAfter: "%", step: 0.01, precision: 2, disabled: !update, onChange: (value) => {
|
||||
const ratio = value;
|
||||
updateDepositLoss({
|
||||
ratio: ratio || 0
|
||||
});
|
||||
} }) }), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: t('payConfig.label.highest'), children: (0, jsx_runtime_1.jsx)(antd_1.InputNumber, { value: depositLoss?.highest, min: 0, step: 1, onChange: (value) => {
|
||||
} }) }), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: t('payConfig.label.highest'), children: (0, jsx_runtime_1.jsx)(antd_1.InputNumber, { value: depositLoss?.highest, min: 0, step: 1, disabled: !update, onChange: (value) => {
|
||||
const highest = value;
|
||||
updateDepositLoss({
|
||||
highest: highest || undefined
|
||||
});
|
||||
return;
|
||||
} }) }), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: t('payConfig.label.lowest'), children: (0, jsx_runtime_1.jsx)(antd_1.InputNumber, { value: depositLoss?.lowest, min: 0, step: 1, onChange: (value) => {
|
||||
} }) }), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: t('payConfig.label.lowest'), children: (0, jsx_runtime_1.jsx)(antd_1.InputNumber, { value: depositLoss?.lowest, min: 0, step: 1, disabled: !update, onChange: (value) => {
|
||||
const lowest = value;
|
||||
updateDepositLoss({
|
||||
lowest: lowest || undefined
|
||||
});
|
||||
return;
|
||||
} }) })] }) }), (0, jsx_runtime_1.jsx)(antd_1.Card, { title: t('payConfig.label.withdrawLoss'), extra: (0, jsx_runtime_1.jsx)(antd_1.Popover, { content: t('payConfig.help.withdrawLoss'), children: (0, jsx_runtime_1.jsx)("span", { className: web_pc_module_less_1.default.help, children: t("help") }) }), children: (0, jsx_runtime_1.jsxs)(antd_1.Form, { labelCol: { span: 8 }, wrapperCol: { span: 18 }, layout: "horizontal", style: { width: '100%' }, children: [(0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: t('payConfig.label.conservative'), children: (0, jsx_runtime_1.jsx)(antd_1.Switch, { value: withdrawLoss?.conservative, onChange: (conservative) => {
|
||||
} }) })] }) }), (0, jsx_runtime_1.jsx)(antd_1.Card, { title: t('payConfig.label.withdrawLoss'), extra: (0, jsx_runtime_1.jsx)(antd_1.Popover, { content: t('payConfig.help.withdrawLoss'), children: (0, jsx_runtime_1.jsx)("span", { className: web_pc_module_less_1.default.help, children: t("help") }) }), children: (0, jsx_runtime_1.jsxs)(antd_1.Form, { labelCol: { span: 8 }, wrapperCol: { span: 18 }, layout: "horizontal", style: { width: '100%' }, children: [(0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: t('payConfig.label.conservative'), children: (0, jsx_runtime_1.jsx)(antd_1.Switch, { disabled: !update, value: withdrawLoss?.conservative, onChange: (conservative) => {
|
||||
updateWithdrawLoss({ conservative });
|
||||
} }) }), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: t('payConfig.label.ratio'), children: (0, jsx_runtime_1.jsx)(antd_1.InputNumber, { disabled: !!withdrawLoss?.conservative, value: withdrawLoss?.ratio, max: 20, min: 0.01, addonAfter: "%", step: 0.01, precision: 2, onChange: (value) => {
|
||||
} }) }), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: t('payConfig.label.ratio'), children: (0, jsx_runtime_1.jsx)(antd_1.InputNumber, { disabled: !!withdrawLoss?.conservative || !update, value: withdrawLoss?.ratio, max: 20, min: 0.01, addonAfter: "%", step: 0.01, precision: 2, onChange: (value) => {
|
||||
const ratio = value;
|
||||
updateWithdrawLoss({
|
||||
ratio: ratio || 0
|
||||
});
|
||||
} }) }), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: t('payConfig.label.highest'), children: (0, jsx_runtime_1.jsx)(antd_1.InputNumber, { disabled: !!withdrawLoss?.conservative, value: withdrawLoss?.highest, min: 0, step: 1, onChange: (value) => {
|
||||
} }) }), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: t('payConfig.label.highest'), children: (0, jsx_runtime_1.jsx)(antd_1.InputNumber, { disabled: !!withdrawLoss?.conservative || !update, value: withdrawLoss?.highest, min: 0, step: 1, onChange: (value) => {
|
||||
const highest = value;
|
||||
updateWithdrawLoss({
|
||||
highest: highest || undefined
|
||||
});
|
||||
return;
|
||||
} }) }), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: t('payConfig.label.lowest'), children: (0, jsx_runtime_1.jsx)(antd_1.InputNumber, { disabled: !!withdrawLoss?.conservative, value: withdrawLoss?.lowest, min: 0, step: 1, onChange: (value) => {
|
||||
} }) }), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: t('payConfig.label.lowest'), children: (0, jsx_runtime_1.jsx)(antd_1.InputNumber, { disabled: !!withdrawLoss?.conservative || !update, value: withdrawLoss?.lowest, min: 0, step: 1, onChange: (value) => {
|
||||
const lowest = value;
|
||||
updateWithdrawLoss({
|
||||
lowest: lowest || undefined
|
||||
});
|
||||
return;
|
||||
} }) }), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: t('payConfig.label.trim'), children: (0, jsx_runtime_1.jsx)(antd_1.Radio.Group, { disabled: !!withdrawLoss?.conservative, options: [
|
||||
} }) }), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: t('payConfig.label.trim'), children: (0, jsx_runtime_1.jsx)(antd_1.Radio.Group, { disabled: !!withdrawLoss?.conservative || !update, options: [
|
||||
{
|
||||
label: t('payConfig.label.jiao'),
|
||||
value: 'jiao',
|
||||
|
|
@ -93,14 +93,14 @@ function PayConfig(props) {
|
|||
}) }) })] }) })] }));
|
||||
}
|
||||
function render(props) {
|
||||
const { system, oakFullpath, operation, oakDirty, serverUrl, oakExecutable } = props.data;
|
||||
const { system, oakFullpath, operation, oakDirty, serverUrl, oakExecutable, canUpdate } = props.data;
|
||||
const { t, update, clean, execute } = props.methods;
|
||||
if (system && oakFullpath) {
|
||||
return ((0, jsx_runtime_1.jsx)("div", { className: web_pc_module_less_1.default.container, children: (0, jsx_runtime_1.jsx)(antd_1.Tabs, { className: web_pc_module_less_1.default.tabs, tabPosition: "left", items: [
|
||||
{
|
||||
label: ((0, jsx_runtime_1.jsx)("div", { className: web_pc_module_less_1.default.systemLabel, children: t('system') })),
|
||||
key: 'system',
|
||||
children: ((0, jsx_runtime_1.jsxs)(antd_1.Flex, { vertical: true, children: [(0, jsx_runtime_1.jsx)(PayConfig, { payConfig: system.payConfig, update: (payConfig) => update({ payConfig }), t: t }), (0, jsx_runtime_1.jsxs)(antd_1.Flex, { gap: "middle", justify: 'end', children: [(0, jsx_runtime_1.jsx)(antd_1.Button, { type: "primary", disabled: oakExecutable !== true, onClick: () => execute(), children: t('common::confirm') }), (0, jsx_runtime_1.jsx)(antd_1.Button, { disabled: !oakDirty, onClick: () => clean(), children: t('common::reset') })] })] })),
|
||||
children: ((0, jsx_runtime_1.jsxs)(antd_1.Flex, { vertical: true, children: [(0, jsx_runtime_1.jsx)(PayConfig, { payConfig: system.payConfig, update: canUpdate ? (payConfig) => update({ payConfig }) : undefined, t: t }), (0, jsx_runtime_1.jsxs)(antd_1.Flex, { gap: "middle", justify: 'end', children: [(0, jsx_runtime_1.jsx)(antd_1.Button, { type: "primary", disabled: oakExecutable !== true, onClick: () => execute(), children: t('common::confirm') }), (0, jsx_runtime_1.jsx)(antd_1.Button, { disabled: !oakDirty, onClick: () => clean(), children: t('common::reset') })] })] })),
|
||||
},
|
||||
{
|
||||
label: ((0, jsx_runtime_1.jsx)("div", { className: web_pc_module_less_1.default.systemLabel, children: t('offlineAccount:name') })),
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
/// <reference types="wechat-miniprogram" />
|
||||
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, "wpAccount", true, WechatMiniprogram.Component.DataOption>) => React.ReactElement;
|
||||
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, "wpAccount", true, {
|
||||
systemId: string;
|
||||
}>) => React.ReactElement;
|
||||
export default _default;
|
||||
|
|
|
|||
|
|
@ -7,14 +7,30 @@ exports.default = OakComponent({
|
|||
id: 1,
|
||||
price: 1,
|
||||
mchId: 1,
|
||||
refundGapDays: 1,
|
||||
taxLossRatio: 1,
|
||||
enabled: 1,
|
||||
taxLossRatio: 1,
|
||||
refundCompensateRatio: 1,
|
||||
refundGapDays: 1,
|
||||
allowWithdrawTransfer: 1,
|
||||
withdrawTransferLossRatio: 1,
|
||||
},
|
||||
properties: {
|
||||
systemId: '',
|
||||
},
|
||||
filters: [
|
||||
{
|
||||
filter() {
|
||||
const { systemId } = this.props;
|
||||
return {
|
||||
systemId,
|
||||
};
|
||||
}
|
||||
}
|
||||
],
|
||||
formData({ data, legalActions }) {
|
||||
return {
|
||||
accounts: data,
|
||||
canCreate: legalActions?.includes('create'),
|
||||
canCreate: legalActions?.includes('create') && !data?.find(ele => ele.enabled),
|
||||
};
|
||||
},
|
||||
actions: ['create', 'update', 'remove'],
|
||||
|
|
|
|||
|
|
@ -169,6 +169,9 @@ const attrUpdateMatrix = {
|
|||
depositLossRatio: {
|
||||
actions: ['update'],
|
||||
},
|
||||
refundCompensateRatio: {
|
||||
actions: ['update'],
|
||||
},
|
||||
refundGapDays: {
|
||||
actions: ['update'],
|
||||
},
|
||||
|
|
|
|||
|
|
@ -331,6 +331,26 @@ const i18ns = [
|
|||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
id: "c014581e9b3508d49c8dc75b2c7f5730",
|
||||
namespace: "oak-pay-business-c-sysAccount-survey",
|
||||
language: "zh-CN",
|
||||
module: "oak-pay-business",
|
||||
position: "src/components/sysAccount/survey",
|
||||
data: {
|
||||
"sysAccount": "系统账户统计",
|
||||
"total": "总余额",
|
||||
"count": "账户个数",
|
||||
"qrCode": "二维码收款",
|
||||
"noDetailRender": "没有注入相应的详情渲染组件",
|
||||
"account": "业务账户统计",
|
||||
"accountNum": "账户个数",
|
||||
"accountTotalSum": "总账户余额",
|
||||
"accountAvailSum": "总账户可用余额",
|
||||
"systemAccountTotal": "本系统账户余额",
|
||||
"systemAccountAvail": "本系统账户可用余额"
|
||||
}
|
||||
},
|
||||
{
|
||||
id: "79255be8c093dfef9765b3f367cab553",
|
||||
namespace: "oak-pay-business-c-wechatPay-upsert",
|
||||
|
|
@ -527,7 +547,7 @@ const i18ns = [
|
|||
"refundNotifyUrl": "endpoint",
|
||||
"apiV3Key": "需要登录商户后台获取",
|
||||
"refundGapDays": "超过这个天数后无法退款",
|
||||
"allowWithdrawTransfer": "开启转账允许后,提现时用户即可选择从此商户号提现到微信零钱,帐户需要开启此项能力",
|
||||
"allowWithdrawTransfer": "开启转账允许后,提现时用户即可选择从此商户号提现到微信零钱,微信商户必须要开启此项能力(当前尚未实现)",
|
||||
"withdrawTransferLossRatio": "渠道转账(提现)时收取的手续费百分比,0.6代表千分之六"
|
||||
},
|
||||
"wechatPayIsShared": "以上配置是全局的,请谨慎修改"
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { String, Price } from 'oak-domain/lib/types/DataType';
|
|||
import { EntityShape } from 'oak-domain/lib/types/Entity';
|
||||
import { EntityDesc } from 'oak-domain/lib/types';
|
||||
import { Schema as Account } from './Account';
|
||||
type Type = 'deposit' | 'withdraw' | 'consume' | 'loan' | 'repay' | 'withdrawBack' | 'earn' | 'encash' | 'cutoffRefundable' | 'tax' | 'taxRefund';
|
||||
type Type = 'deposit' | 'withdraw' | 'consume' | 'loan' | 'repay' | 'withdrawBack' | 'earn' | 'encash' | 'cutoffRefundable' | 'tax' | 'taxRefund' | 'refund' | 'refundFailure';
|
||||
export interface Schema extends EntityShape {
|
||||
account: Account;
|
||||
type: Type;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,9 @@ exports.entityDesc = {
|
|||
encash: '兑现',
|
||||
tax: '渠道费',
|
||||
taxRefund: '渠道费用退还',
|
||||
cutoffRefundable: '削减可自由退额度'
|
||||
cutoffRefundable: '削减可自由退额度',
|
||||
refund: '退款',
|
||||
refundFailure: '退款失败',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -46,6 +48,8 @@ exports.entityDesc = {
|
|||
tax: '#A569BD',
|
||||
taxRefund: '#FF3333',
|
||||
cutoffRefundable: '#2E4053',
|
||||
refund: '#CC3333',
|
||||
refundFailure: '#009933',
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import { String, Price, Datetime } from 'oak-domain/lib/types/DataType';
|
||||
import { String, Price, Boolean, Datetime } from 'oak-domain/lib/types/DataType';
|
||||
import { EntityShape } from 'oak-domain/lib/types/Entity';
|
||||
import { EntityDesc, ActionDef } from 'oak-domain/lib/types';
|
||||
import { Schema as User } from 'oak-general-business/lib/entities/User';
|
||||
import { Schema as AccountOper } from './AccountOper';
|
||||
export interface Schema extends EntityShape {
|
||||
price: Price;
|
||||
paid: Price;
|
||||
|
|
@ -12,11 +13,13 @@ export interface Schema extends EntityShape {
|
|||
creator: User;
|
||||
entity: String<32>;
|
||||
entityId: String<64>;
|
||||
settled: Boolean;
|
||||
opers: AccountOper[];
|
||||
}
|
||||
export type IAction = 'startPaying' | 'payAll' | 'payPartially' | 'payNone' | 'timeout' | 'cancel' | 'startRefunding' | 'refundAll' | 'refundPartially' | 'refundNone';
|
||||
export type IState = 'paid' | 'unpaid' | 'timeout' | 'cancelled' | 'paying' | 'partiallyPaid' | 'paid' | 'refunding' | 'partiallyRefunded' | 'refunded';
|
||||
export declare const IActionDef: ActionDef<IAction, IState>;
|
||||
export type Action = IAction;
|
||||
export type Action = IAction | 'settle';
|
||||
export declare const entityDesc: EntityDesc<Schema, Action, '', {
|
||||
iState: IState;
|
||||
}>;
|
||||
|
|
|
|||
|
|
@ -43,6 +43,8 @@ exports.entityDesc = {
|
|||
creator: '创建者',
|
||||
entity: '关联对象',
|
||||
entityId: '关联对象Id',
|
||||
settled: '是否结算',
|
||||
opers: '相关帐户操作'
|
||||
},
|
||||
action: {
|
||||
startPaying: '开始支付',
|
||||
|
|
@ -55,6 +57,7 @@ exports.entityDesc = {
|
|||
refundAll: '完全退款',
|
||||
refundNone: '退款失败',
|
||||
refundPartially: '部分退款',
|
||||
settle: '结算',
|
||||
},
|
||||
v: {
|
||||
iState: {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ exports.IActionDef = {
|
|||
startPaying: ['unpaid', 'paying'],
|
||||
succeedPaying: [['unpaid', 'paying'], 'paid'],
|
||||
close: [['unpaid', 'paying'], 'closed'],
|
||||
startRefunding: [['paid', 'partiallyRefunded', 'refunding'], 'refunding'],
|
||||
startRefunding: [['paid', 'partiallyRefunded'], 'refunding'],
|
||||
refundAll: [['paid', 'refunding', 'partiallyRefunded'], 'refunded'],
|
||||
refundPartially: [['paid', 'refunding', 'partiallyRefunded'], 'partiallyRefunded'],
|
||||
stopRefunding: ['refunding', 'paid'],
|
||||
|
|
|
|||
|
|
@ -3,9 +3,10 @@ import { EntityShape } from 'oak-domain/lib/types/Entity';
|
|||
import { EntityDesc, ActionDef } from 'oak-domain/lib/types';
|
||||
import { Schema as User } from './User';
|
||||
import { Schema as Pay } from './Pay';
|
||||
import { Schema as AccountOper } from './AccountOper';
|
||||
import { Schema as Withdraw } from './Withdraw';
|
||||
export interface Schema extends EntityShape {
|
||||
entity: String<32>;
|
||||
entityId: String<64>;
|
||||
withdraw?: Withdraw;
|
||||
loss: Price;
|
||||
pay: Pay;
|
||||
meta?: Object;
|
||||
|
|
@ -13,6 +14,7 @@ export interface Schema extends EntityShape {
|
|||
price: Price;
|
||||
creator: User;
|
||||
reason?: Text;
|
||||
opers: AccountOper[];
|
||||
}
|
||||
type IState = 'refunding' | 'refunded' | 'failed' | 'abnormal';
|
||||
type IAction = 'succeedRefunding' | 'failRefunding' | 'makeAbnormal';
|
||||
|
|
|
|||
|
|
@ -18,13 +18,13 @@ exports.entityDesc = {
|
|||
pay: '关联支付',
|
||||
price: '价格',
|
||||
loss: '损耗',
|
||||
entity: '关联对象',
|
||||
entityId: '关联对象ID',
|
||||
withdraw: '关联提现',
|
||||
meta: 'metadata',
|
||||
externalId: '外部ID',
|
||||
iState: '状态',
|
||||
creator: '创建者',
|
||||
reason: '原因',
|
||||
opers: '相关账户操作'
|
||||
},
|
||||
action: {
|
||||
succeedRefunding: '退款成功',
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import { EntityDesc, ActionDef } from 'oak-domain/lib/types';
|
|||
import { Schema as Account } from './Account';
|
||||
import { Schema as AccountOper } from './AccountOper';
|
||||
import { Schema as User } from './User';
|
||||
import { Schema as Refund } from './Refund';
|
||||
export interface Schema extends EntityShape {
|
||||
account: Account;
|
||||
price: Price;
|
||||
|
|
@ -15,7 +14,6 @@ export interface Schema extends EntityShape {
|
|||
creator: User;
|
||||
reason?: Text;
|
||||
meta?: Object;
|
||||
refunds: Refund[];
|
||||
}
|
||||
type IState = 'withdrawing' | 'successful' | 'partiallySuccessful' | 'failed' | 'applying';
|
||||
type IAction = 'succeed' | 'fail' | 'succeedPartially';
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ exports.entityDesc = {
|
|||
reason: '原因',
|
||||
meta: 'metadata',
|
||||
creator: '创建者',
|
||||
refunds: '退款',
|
||||
},
|
||||
v: {
|
||||
iState: {
|
||||
|
|
|
|||
|
|
@ -6,16 +6,18 @@ import { AppendOnlyAction } from "oak-domain/lib/actions/action";
|
|||
import { Price, String } from "oak-domain/lib/types/DataType";
|
||||
import * as Account from "../Account/Schema";
|
||||
import * as Deposit from "../Deposit/Schema";
|
||||
import * as Order from "../Order/Schema";
|
||||
import * as Pay from "../Pay/Schema";
|
||||
import * as Refund from "../Refund/Schema";
|
||||
import * as Withdraw from "../Withdraw/Schema";
|
||||
type Type = "deposit" | "withdraw" | "consume" | "loan" | "repay" | "withdrawBack" | "earn" | "encash" | "cutoffRefundable" | "tax" | "taxRefund";
|
||||
type Type = "deposit" | "withdraw" | "consume" | "loan" | "repay" | "withdrawBack" | "earn" | "encash" | "cutoffRefundable" | "tax" | "taxRefund" | "refund" | "refundFailure";
|
||||
export type OpSchema = EntityShape & {
|
||||
accountId: ForeignKey<"account">;
|
||||
type: Type;
|
||||
totalPlus: Price;
|
||||
availPlus: Price;
|
||||
refundablePlus?: Price | null;
|
||||
entity: "deposit" | "pay" | "withdraw" | string;
|
||||
entity: "deposit" | "order" | "pay" | "refund" | "withdraw" | string;
|
||||
entityId: String<64>;
|
||||
};
|
||||
export type OpAttr = keyof OpSchema;
|
||||
|
|
@ -25,11 +27,13 @@ export type Schema = EntityShape & {
|
|||
totalPlus: Price;
|
||||
availPlus: Price;
|
||||
refundablePlus?: Price | null;
|
||||
entity: "deposit" | "pay" | "withdraw" | string;
|
||||
entity: "deposit" | "order" | "pay" | "refund" | "withdraw" | string;
|
||||
entityId: String<64>;
|
||||
account: Account.Schema;
|
||||
deposit?: Deposit.Schema;
|
||||
order?: Order.Schema;
|
||||
pay?: Pay.Schema;
|
||||
refund?: Refund.Schema;
|
||||
withdraw?: Withdraw.Schema;
|
||||
} & {
|
||||
[A in ExpressionKey]?: any;
|
||||
|
|
@ -45,10 +49,12 @@ type AttrFilter = {
|
|||
totalPlus: Q_NumberValue;
|
||||
availPlus: Q_NumberValue;
|
||||
refundablePlus: Q_NumberValue;
|
||||
entity: Q_EnumValue<"deposit" | "pay" | "withdraw" | string>;
|
||||
entity: Q_EnumValue<"deposit" | "order" | "pay" | "refund" | "withdraw" | string>;
|
||||
entityId: Q_StringValue;
|
||||
deposit: Deposit.Filter;
|
||||
order: Order.Filter;
|
||||
pay: Pay.Filter;
|
||||
refund: Refund.Filter;
|
||||
withdraw: Withdraw.Filter;
|
||||
};
|
||||
export type Filter = MakeFilter<AttrFilter & ExprOp<OpAttr | string>>;
|
||||
|
|
@ -68,7 +74,9 @@ export type Projection = {
|
|||
entity?: number;
|
||||
entityId?: number;
|
||||
deposit?: Deposit.Projection;
|
||||
order?: Order.Projection;
|
||||
pay?: Pay.Projection;
|
||||
refund?: Refund.Projection;
|
||||
withdraw?: Withdraw.Projection;
|
||||
} & Partial<ExprOp<OpAttr | string>>;
|
||||
type AccountOperIdProjection = OneOf<{
|
||||
|
|
@ -80,9 +88,15 @@ type AccountIdProjection = OneOf<{
|
|||
type DepositIdProjection = OneOf<{
|
||||
entityId: number;
|
||||
}>;
|
||||
type OrderIdProjection = OneOf<{
|
||||
entityId: number;
|
||||
}>;
|
||||
type PayIdProjection = OneOf<{
|
||||
entityId: number;
|
||||
}>;
|
||||
type RefundIdProjection = OneOf<{
|
||||
entityId: number;
|
||||
}>;
|
||||
type WithdrawIdProjection = OneOf<{
|
||||
entityId: number;
|
||||
}>;
|
||||
|
|
@ -112,8 +126,12 @@ export type SortAttr = {
|
|||
entityId: number;
|
||||
} | {
|
||||
deposit: Deposit.SortAttr;
|
||||
} | {
|
||||
order: Order.SortAttr;
|
||||
} | {
|
||||
pay: Pay.SortAttr;
|
||||
} | {
|
||||
refund: Refund.SortAttr;
|
||||
} | {
|
||||
withdraw: Withdraw.SortAttr;
|
||||
} | {
|
||||
|
|
@ -148,6 +166,18 @@ export type CreateOperationData = FormCreateData<Omit<OpSchema, "entity" | "enti
|
|||
entity: "deposit";
|
||||
entityId: ForeignKey<"Deposit">;
|
||||
deposit?: never;
|
||||
} | {
|
||||
entity?: never;
|
||||
entityId?: never;
|
||||
order: Order.CreateSingleOperation;
|
||||
} | {
|
||||
entity: "order";
|
||||
entityId: ForeignKey<"Order">;
|
||||
order?: Order.UpdateOperation;
|
||||
} | {
|
||||
entity: "order";
|
||||
entityId: ForeignKey<"Order">;
|
||||
order?: never;
|
||||
} | {
|
||||
entity?: never;
|
||||
entityId?: never;
|
||||
|
|
@ -160,6 +190,18 @@ export type CreateOperationData = FormCreateData<Omit<OpSchema, "entity" | "enti
|
|||
entity: "pay";
|
||||
entityId: ForeignKey<"Pay">;
|
||||
pay?: never;
|
||||
} | {
|
||||
entity?: never;
|
||||
entityId?: never;
|
||||
refund: Refund.CreateSingleOperation;
|
||||
} | {
|
||||
entity: "refund";
|
||||
entityId: ForeignKey<"Refund">;
|
||||
refund?: Refund.UpdateOperation;
|
||||
} | {
|
||||
entity: "refund";
|
||||
entityId: ForeignKey<"Refund">;
|
||||
refund?: never;
|
||||
} | {
|
||||
entity?: never;
|
||||
entityId?: never;
|
||||
|
|
@ -196,19 +238,29 @@ export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "entity" | "enti
|
|||
deposit?: Deposit.CreateSingleOperation | Deposit.UpdateOperation | Deposit.RemoveOperation;
|
||||
entityId?: never;
|
||||
entity?: never;
|
||||
} | {
|
||||
order?: Order.CreateSingleOperation | Order.UpdateOperation | Order.RemoveOperation;
|
||||
entityId?: never;
|
||||
entity?: never;
|
||||
} | {
|
||||
pay?: Pay.CreateSingleOperation | Pay.UpdateOperation | Pay.RemoveOperation;
|
||||
entityId?: never;
|
||||
entity?: never;
|
||||
} | {
|
||||
refund?: Refund.CreateSingleOperation | Refund.UpdateOperation | Refund.RemoveOperation;
|
||||
entityId?: never;
|
||||
entity?: never;
|
||||
} | {
|
||||
withdraw?: Withdraw.CreateSingleOperation | Withdraw.UpdateOperation | Withdraw.RemoveOperation;
|
||||
entityId?: never;
|
||||
entity?: never;
|
||||
} | {
|
||||
entity?: ("deposit" | "pay" | "withdraw" | string) | null;
|
||||
entityId?: ForeignKey<"Deposit" | "Pay" | "Withdraw"> | null;
|
||||
entity?: ("deposit" | "order" | "pay" | "refund" | "withdraw" | string) | null;
|
||||
entityId?: ForeignKey<"Deposit" | "Order" | "Pay" | "Refund" | "Withdraw"> | null;
|
||||
deposit?: never;
|
||||
order?: never;
|
||||
pay?: never;
|
||||
refund?: never;
|
||||
withdraw?: never;
|
||||
}) & {
|
||||
[k: string]: any;
|
||||
|
|
@ -218,8 +270,12 @@ export type RemoveOperationData = {} & (({
|
|||
account?: Account.UpdateOperation | Account.RemoveOperation;
|
||||
})) & ({
|
||||
deposit?: Deposit.UpdateOperation | Deposit.RemoveOperation;
|
||||
} | {
|
||||
order?: Order.UpdateOperation | Order.RemoveOperation;
|
||||
} | {
|
||||
pay?: Pay.UpdateOperation | Pay.RemoveOperation;
|
||||
} | {
|
||||
refund?: Refund.UpdateOperation | Refund.RemoveOperation;
|
||||
} | {
|
||||
withdraw?: Withdraw.UpdateOperation | Withdraw.RemoveOperation;
|
||||
} | {
|
||||
|
|
@ -229,7 +285,9 @@ export type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter
|
|||
export type Operation = CreateOperation | UpdateOperation | RemoveOperation;
|
||||
export type AccountIdSubQuery = Selection<AccountIdProjection>;
|
||||
export type DepositIdSubQuery = Selection<DepositIdProjection>;
|
||||
export type OrderIdSubQuery = Selection<OrderIdProjection>;
|
||||
export type PayIdSubQuery = Selection<PayIdProjection>;
|
||||
export type RefundIdSubQuery = Selection<RefundIdProjection>;
|
||||
export type WithdrawIdSubQuery = Selection<WithdrawIdProjection>;
|
||||
export type AccountOperIdSubQuery = Selection<AccountOperIdProjection>;
|
||||
export type EntityDef = {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ exports.desc = {
|
|||
type: {
|
||||
notNull: true,
|
||||
type: "enum",
|
||||
enumeration: ["deposit", "withdraw", "consume", "loan", "repay", "withdrawBack", "earn", "encash", "cutoffRefundable", "tax", "taxRefund"]
|
||||
enumeration: ["deposit", "withdraw", "consume", "loan", "repay", "withdrawBack", "earn", "encash", "cutoffRefundable", "tax", "taxRefund", "refund", "refundFailure"]
|
||||
},
|
||||
totalPlus: {
|
||||
notNull: true,
|
||||
|
|
@ -31,7 +31,7 @@ exports.desc = {
|
|||
params: {
|
||||
length: 32
|
||||
},
|
||||
ref: ["deposit", "pay", "withdraw"]
|
||||
ref: ["deposit", "order", "pay", "refund", "withdraw"]
|
||||
},
|
||||
entityId: {
|
||||
notNull: true,
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ exports.style = {
|
|||
tax: '#A569BD',
|
||||
taxRefund: '#FF3333',
|
||||
cutoffRefundable: '#2E4053',
|
||||
refund: '#CC3333',
|
||||
refundFailure: '#009933',
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
{ "name": "帐号操作", "attr": { "account": "帐号", "type": "类型", "totalPlus": "余额变化", "availPlus": "可用余额变化", "refundablePlus": "可退款余额变化", "entity": "关联对象", "entityId": "关联对象Id" }, "v": { "type": { "deposit": "充值", "withdraw": "提现", "consume": "消费", "loan": "抵押", "repay": "偿还", "withdrawBack": "提现失败", "earn": "赚取", "encash": "兑现", "tax": "渠道费", "taxRefund": "渠道费用退还", "cutoffRefundable": "削减可自由退额度" } } }
|
||||
{ "name": "帐号操作", "attr": { "account": "帐号", "type": "类型", "totalPlus": "余额变化", "availPlus": "可用余额变化", "refundablePlus": "可退款余额变化", "entity": "关联对象", "entityId": "关联对象Id" }, "v": { "type": { "deposit": "充值", "withdraw": "提现", "consume": "消费", "loan": "抵押", "repay": "偿还", "withdrawBack": "提现失败", "earn": "赚取", "encash": "兑现", "tax": "渠道费", "taxRefund": "渠道费用退还", "cutoffRefundable": "削减可自由退额度", "refund": "退款", "refundFailure": "退款失败" } } }
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { GenericAction } from "oak-domain/lib/actions/action";
|
|||
export type IAction = 'startPaying' | 'payAll' | 'payPartially' | 'payNone' | 'timeout' | 'cancel' | 'startRefunding' | 'refundAll' | 'refundPartially' | 'refundNone' | string;
|
||||
export type IState = 'paid' | 'unpaid' | 'timeout' | 'cancelled' | 'paying' | 'partiallyPaid' | 'paid' | 'refunding' | 'partiallyRefunded' | 'refunded' | string;
|
||||
export declare const IActionDef: ActionDef<IAction, IState>;
|
||||
export type ParticularAction = IAction;
|
||||
export type ParticularAction = IAction | 'settle';
|
||||
export declare const actions: string[];
|
||||
export type Action = GenericAction | ParticularAction | string;
|
||||
export declare const actionDefDict: {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ exports.IActionDef = {
|
|||
},
|
||||
is: 'unpaid',
|
||||
};
|
||||
exports.actions = ["count", "stat", "download", "select", "aggregate", "create", "remove", "update", "startPaying", "payAll", "payPartially", "payNone", "timeout", "cancel", "startRefunding", "refundAll", "refundPartially", "refundNone"];
|
||||
exports.actions = ["count", "stat", "download", "select", "aggregate", "create", "remove", "update", "startPaying", "payAll", "payPartially", "payNone", "timeout", "cancel", "startRefunding", "refundAll", "refundPartially", "refundNone", "settle"];
|
||||
exports.actionDefDict = {
|
||||
iState: exports.IActionDef
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
import { ForeignKey } from "oak-domain/lib/types/DataType";
|
||||
import { Q_DateValue, Q_NumberValue, Q_StringValue, Q_EnumValue, NodeId, MakeFilter, ExprOp, ExpressionKey, SubQueryPredicateMetadata } from "oak-domain/lib/types/Demand";
|
||||
import { Q_DateValue, Q_BooleanValue, Q_NumberValue, Q_StringValue, Q_EnumValue, NodeId, MakeFilter, ExprOp, ExpressionKey, SubQueryPredicateMetadata } from "oak-domain/lib/types/Demand";
|
||||
import { OneOf } from "oak-domain/lib/types/Polyfill";
|
||||
import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOperation, Selection as OakSelection, MakeAction as OakMakeAction, AggregationResult, EntityShape } from "oak-domain/lib/types/Entity";
|
||||
import { Action, ParticularAction, IState } from "./Action";
|
||||
import { Price, String, Datetime } from "oak-domain/lib/types/DataType";
|
||||
import { Price, String, Datetime, Boolean } from "oak-domain/lib/types/DataType";
|
||||
import * as User from "../User/Schema";
|
||||
import * as Pay from "../Pay/Schema";
|
||||
import * as AccountOper from "../AccountOper/Schema";
|
||||
export type OpSchema = EntityShape & {
|
||||
price: Price;
|
||||
paid: Price;
|
||||
|
|
@ -16,6 +17,7 @@ export type OpSchema = EntityShape & {
|
|||
creatorId: ForeignKey<"user">;
|
||||
entity: String<32>;
|
||||
entityId: String<64>;
|
||||
settled: Boolean;
|
||||
iState?: IState | null;
|
||||
};
|
||||
export type OpAttr = keyof OpSchema;
|
||||
|
|
@ -29,10 +31,13 @@ export type Schema = EntityShape & {
|
|||
creatorId: ForeignKey<"user">;
|
||||
entity: String<32>;
|
||||
entityId: String<64>;
|
||||
settled: Boolean;
|
||||
iState?: IState | null;
|
||||
creator: User.Schema;
|
||||
pay$order?: Array<Pay.Schema>;
|
||||
pay$order$$aggr?: AggregationResult<Pay.Schema>;
|
||||
accountOper$entity?: Array<AccountOper.Schema>;
|
||||
accountOper$entity$$aggr?: AggregationResult<AccountOper.Schema>;
|
||||
} & {
|
||||
[A in ExpressionKey]?: any;
|
||||
};
|
||||
|
|
@ -51,8 +56,10 @@ type AttrFilter = {
|
|||
creator: User.Filter;
|
||||
entity: Q_StringValue;
|
||||
entityId: Q_StringValue;
|
||||
settled: Q_BooleanValue;
|
||||
iState: Q_EnumValue<IState>;
|
||||
pay$order: Pay.Filter & SubQueryPredicateMetadata;
|
||||
accountOper$entity: AccountOper.Filter & SubQueryPredicateMetadata;
|
||||
};
|
||||
export type Filter = MakeFilter<AttrFilter & ExprOp<OpAttr | string>>;
|
||||
export type Projection = {
|
||||
|
|
@ -72,6 +79,7 @@ export type Projection = {
|
|||
creator?: User.Projection;
|
||||
entity?: number;
|
||||
entityId?: number;
|
||||
settled?: number;
|
||||
iState?: number;
|
||||
pay$order?: Pay.Selection & {
|
||||
$entity: "pay";
|
||||
|
|
@ -79,6 +87,12 @@ export type Projection = {
|
|||
pay$order$$aggr?: Pay.Aggregation & {
|
||||
$entity: "pay";
|
||||
};
|
||||
accountOper$entity?: AccountOper.Selection & {
|
||||
$entity: "accountOper";
|
||||
};
|
||||
accountOper$entity$$aggr?: AccountOper.Aggregation & {
|
||||
$entity: "accountOper";
|
||||
};
|
||||
} & Partial<ExprOp<OpAttr | string>>;
|
||||
type OrderIdProjection = OneOf<{
|
||||
id: number;
|
||||
|
|
@ -114,6 +128,8 @@ export type SortAttr = {
|
|||
entity: number;
|
||||
} | {
|
||||
entityId: number;
|
||||
} | {
|
||||
settled: number;
|
||||
} | {
|
||||
iState: number;
|
||||
} | {
|
||||
|
|
@ -142,6 +158,7 @@ export type CreateOperationData = FormCreateData<Omit<OpSchema, "entity" | "enti
|
|||
[K: string]: any;
|
||||
}) & {
|
||||
pay$order?: OakOperation<Pay.UpdateOperation["action"], Omit<Pay.UpdateOperationData, "order" | "orderId">, Omit<Pay.Filter, "order" | "orderId">> | OakOperation<"create", Omit<Pay.CreateOperationData, "order" | "orderId">[]> | Array<OakOperation<"create", Omit<Pay.CreateOperationData, "order" | "orderId">> | OakOperation<Pay.UpdateOperation["action"], Omit<Pay.UpdateOperationData, "order" | "orderId">, Omit<Pay.Filter, "order" | "orderId">>>;
|
||||
accountOper$entity?: OakOperation<"create", Omit<AccountOper.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<AccountOper.CreateOperationData, "entity" | "entityId">>>;
|
||||
};
|
||||
export type CreateSingleOperation = OakOperation<"create", CreateOperationData>;
|
||||
export type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
|
||||
|
|
@ -161,6 +178,7 @@ export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "creatorId">> &
|
|||
})) & {
|
||||
[k: string]: any;
|
||||
pay$order?: OakOperation<Pay.UpdateOperation["action"], Omit<Pay.UpdateOperationData, "order" | "orderId">, Omit<Pay.Filter, "order" | "orderId">> | OakOperation<Pay.RemoveOperation["action"], Omit<Pay.RemoveOperationData, "order" | "orderId">, Omit<Pay.Filter, "order" | "orderId">> | OakOperation<"create", Omit<Pay.CreateOperationData, "order" | "orderId">[]> | Array<OakOperation<"create", Omit<Pay.CreateOperationData, "order" | "orderId">> | OakOperation<Pay.UpdateOperation["action"], Omit<Pay.UpdateOperationData, "order" | "orderId">, Omit<Pay.Filter, "order" | "orderId">> | OakOperation<Pay.RemoveOperation["action"], Omit<Pay.RemoveOperationData, "order" | "orderId">, Omit<Pay.Filter, "order" | "orderId">>>;
|
||||
accountOper$entity?: OakOperation<"create", Omit<AccountOper.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<AccountOper.CreateOperationData, "entity" | "entityId">>>;
|
||||
};
|
||||
export type UpdateOperation = OakOperation<"update" | ParticularAction | string, UpdateOperationData, Filter, Sorter>;
|
||||
export type RemoveOperationData = {} & (({
|
||||
|
|
|
|||
|
|
@ -53,6 +53,10 @@ exports.desc = {
|
|||
length: 64
|
||||
}
|
||||
},
|
||||
settled: {
|
||||
notNull: true,
|
||||
type: "boolean"
|
||||
},
|
||||
iState: {
|
||||
type: "enum",
|
||||
enumeration: ["paid", "unpaid", "timeout", "cancelled", "paying", "partiallyPaid", "paid", "refunding", "partiallyRefunded", "refunded"]
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
{ "name": "订单", "attr": { "price": "订单金额", "paid": "已支付金额", "refunded": "已退款金额", "iState": "订单状态", "title": "订单标题", "desc": "订单描述", "timeoutAt": "过期时间", "creator": "创建者", "entity": "关联对象", "entityId": "关联对象Id" }, "action": { "startPaying": "开始支付", "payAll": "全部支付", "payPartially": "部分支付", "payNone": "支付失败", "timeout": "过期", "cancel": "放弃", "startRefunding": "开始退款", "refundAll": "完全退款", "refundNone": "退款失败", "refundPartially": "部分退款" }, "v": { "iState": { "paid": "已付款", "partiallyPaid": "部分支付", "paying": "支付中", "unpaid": "待付款", "timeout": "已超时", "cancelled": "已取消", "refunded": "已退款", "partiallyRefunded": "已部分退款", "refunding": "退款中" } } }
|
||||
{ "name": "订单", "attr": { "price": "订单金额", "paid": "已支付金额", "refunded": "已退款金额", "iState": "订单状态", "title": "订单标题", "desc": "订单描述", "timeoutAt": "过期时间", "creator": "创建者", "entity": "关联对象", "entityId": "关联对象Id", "settled": "是否结算", "opers": "相关帐户操作" }, "action": { "startPaying": "开始支付", "payAll": "全部支付", "payPartially": "部分支付", "payNone": "支付失败", "timeout": "过期", "cancel": "放弃", "startRefunding": "开始退款", "refundAll": "完全退款", "refundNone": "退款失败", "refundPartially": "部分退款", "settle": "结算" }, "v": { "iState": { "paid": "已付款", "partiallyPaid": "部分支付", "paying": "支付中", "unpaid": "待付款", "timeout": "已超时", "cancelled": "已取消", "refunded": "已退款", "partiallyRefunded": "已部分退款", "refunding": "退款中" } } }
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ exports.IActionDef = {
|
|||
startPaying: ['unpaid', 'paying'],
|
||||
succeedPaying: [['unpaid', 'paying'], 'paid'],
|
||||
close: [['unpaid', 'paying'], 'closed'],
|
||||
startRefunding: [['paid', 'partiallyRefunded', 'refunding'], 'refunding'],
|
||||
startRefunding: [['paid', 'partiallyRefunded'], 'refunding'],
|
||||
refundAll: [['paid', 'refunding', 'partiallyRefunded'], 'refunded'],
|
||||
refundPartially: [['paid', 'refunding', 'partiallyRefunded'], 'partiallyRefunded'],
|
||||
stopRefunding: ['refunding', 'paid'],
|
||||
|
|
|
|||
|
|
@ -3,14 +3,14 @@ import { Q_DateValue, Q_NumberValue, Q_StringValue, Q_EnumValue, NodeId, MakeFil
|
|||
import { OneOf } from "oak-domain/lib/types/Polyfill";
|
||||
import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOperation, Selection as OakSelection, MakeAction as OakMakeAction, AggregationResult, EntityShape } from "oak-domain/lib/types/Entity";
|
||||
import { Action, ParticularAction, IState } from "./Action";
|
||||
import { String, Price, Text } from "oak-domain/lib/types/DataType";
|
||||
import { Price, String, Text } from "oak-domain/lib/types/DataType";
|
||||
import * as Withdraw from "../Withdraw/Schema";
|
||||
import * as Pay from "../Pay/Schema";
|
||||
import * as User from "../User/Schema";
|
||||
import * as Withdraw from "../Withdraw/Schema";
|
||||
import * as SysAccountOper from "../SysAccountOper/Schema";
|
||||
import * as AccountOper from "../AccountOper/Schema";
|
||||
export type OpSchema = EntityShape & {
|
||||
entity: "withdraw" | string;
|
||||
entityId: String<64>;
|
||||
withdrawId?: ForeignKey<"withdraw"> | null;
|
||||
loss: Price;
|
||||
payId: ForeignKey<"pay">;
|
||||
meta?: Object | null;
|
||||
|
|
@ -22,8 +22,7 @@ export type OpSchema = EntityShape & {
|
|||
};
|
||||
export type OpAttr = keyof OpSchema;
|
||||
export type Schema = EntityShape & {
|
||||
entity: "withdraw" | string;
|
||||
entityId: String<64>;
|
||||
withdrawId?: ForeignKey<"withdraw"> | null;
|
||||
loss: Price;
|
||||
payId: ForeignKey<"pay">;
|
||||
meta?: Object | null;
|
||||
|
|
@ -32,11 +31,13 @@ export type Schema = EntityShape & {
|
|||
creatorId: ForeignKey<"user">;
|
||||
reason?: Text | null;
|
||||
iState?: IState | null;
|
||||
withdraw?: Withdraw.Schema | null;
|
||||
pay: Pay.Schema;
|
||||
creator: User.Schema;
|
||||
withdraw?: Withdraw.Schema;
|
||||
sysAccountOper$refund?: Array<SysAccountOper.Schema>;
|
||||
sysAccountOper$refund$$aggr?: AggregationResult<SysAccountOper.Schema>;
|
||||
accountOper$entity?: Array<AccountOper.Schema>;
|
||||
accountOper$entity$$aggr?: AggregationResult<AccountOper.Schema>;
|
||||
} & {
|
||||
[A in ExpressionKey]?: any;
|
||||
};
|
||||
|
|
@ -45,8 +46,8 @@ type AttrFilter = {
|
|||
$$createAt$$: Q_DateValue;
|
||||
$$seq$$: Q_NumberValue;
|
||||
$$updateAt$$: Q_DateValue;
|
||||
entity: Q_EnumValue<"withdraw" | string>;
|
||||
entityId: Q_StringValue;
|
||||
withdrawId: Q_StringValue;
|
||||
withdraw: Withdraw.Filter;
|
||||
loss: Q_NumberValue;
|
||||
payId: Q_StringValue;
|
||||
pay: Pay.Filter;
|
||||
|
|
@ -57,8 +58,8 @@ type AttrFilter = {
|
|||
creator: User.Filter;
|
||||
reason: Q_StringValue;
|
||||
iState: Q_EnumValue<IState>;
|
||||
withdraw: Withdraw.Filter;
|
||||
sysAccountOper$refund: SysAccountOper.Filter & SubQueryPredicateMetadata;
|
||||
accountOper$entity: AccountOper.Filter & SubQueryPredicateMetadata;
|
||||
};
|
||||
export type Filter = MakeFilter<AttrFilter & ExprOp<OpAttr | string>>;
|
||||
export type Projection = {
|
||||
|
|
@ -68,8 +69,8 @@ export type Projection = {
|
|||
$$createAt$$?: number;
|
||||
$$updateAt$$?: number;
|
||||
$$seq$$?: number;
|
||||
entity?: number;
|
||||
entityId?: number;
|
||||
withdrawId?: number;
|
||||
withdraw?: Withdraw.Projection;
|
||||
loss?: number;
|
||||
payId?: number;
|
||||
pay?: Pay.Projection;
|
||||
|
|
@ -80,26 +81,31 @@ export type Projection = {
|
|||
creator?: User.Projection;
|
||||
reason?: number;
|
||||
iState?: number;
|
||||
withdraw?: Withdraw.Projection;
|
||||
sysAccountOper$refund?: SysAccountOper.Selection & {
|
||||
$entity: "sysAccountOper";
|
||||
};
|
||||
sysAccountOper$refund$$aggr?: SysAccountOper.Aggregation & {
|
||||
$entity: "sysAccountOper";
|
||||
};
|
||||
accountOper$entity?: AccountOper.Selection & {
|
||||
$entity: "accountOper";
|
||||
};
|
||||
accountOper$entity$$aggr?: AccountOper.Aggregation & {
|
||||
$entity: "accountOper";
|
||||
};
|
||||
} & Partial<ExprOp<OpAttr | string>>;
|
||||
type RefundIdProjection = OneOf<{
|
||||
id: number;
|
||||
}>;
|
||||
type WithdrawIdProjection = OneOf<{
|
||||
withdrawId: number;
|
||||
}>;
|
||||
type PayIdProjection = OneOf<{
|
||||
payId: number;
|
||||
}>;
|
||||
type UserIdProjection = OneOf<{
|
||||
creatorId: number;
|
||||
}>;
|
||||
type WithdrawIdProjection = OneOf<{
|
||||
entityId: number;
|
||||
}>;
|
||||
export type SortAttr = {
|
||||
id: number;
|
||||
} | {
|
||||
|
|
@ -109,9 +115,9 @@ export type SortAttr = {
|
|||
} | {
|
||||
$$updateAt$$: number;
|
||||
} | {
|
||||
entity: number;
|
||||
withdrawId: number;
|
||||
} | {
|
||||
entityId: number;
|
||||
withdraw: Withdraw.SortAttr;
|
||||
} | {
|
||||
loss: number;
|
||||
} | {
|
||||
|
|
@ -130,8 +136,6 @@ export type SortAttr = {
|
|||
reason: number;
|
||||
} | {
|
||||
iState: number;
|
||||
} | {
|
||||
withdraw: Withdraw.SortAttr;
|
||||
} | {
|
||||
[k: string]: any;
|
||||
} | OneOf<ExprOp<OpAttr | string>>;
|
||||
|
|
@ -143,7 +147,16 @@ export type Sorter = SortNode[];
|
|||
export type SelectOperation<P extends Object = Projection> = OakSelection<"select", P, Filter, Sorter>;
|
||||
export type Selection<P extends Object = Projection> = SelectOperation<P>;
|
||||
export type Aggregation = DeduceAggregation<Projection, Filter, Sorter>;
|
||||
export type CreateOperationData = FormCreateData<Omit<OpSchema, "entity" | "entityId" | "payId" | "creatorId">> & (({
|
||||
export type CreateOperationData = FormCreateData<Omit<OpSchema, "withdrawId" | "payId" | "creatorId">> & (({
|
||||
withdrawId?: never;
|
||||
withdraw?: Withdraw.CreateSingleOperation;
|
||||
} | {
|
||||
withdrawId: ForeignKey<"withdraw">;
|
||||
withdraw?: Withdraw.UpdateOperation;
|
||||
} | {
|
||||
withdraw?: never;
|
||||
withdrawId?: ForeignKey<"withdraw">;
|
||||
}) & ({
|
||||
payId?: never;
|
||||
pay: Pay.CreateSingleOperation;
|
||||
} | {
|
||||
|
|
@ -161,29 +174,26 @@ export type CreateOperationData = FormCreateData<Omit<OpSchema, "entity" | "enti
|
|||
} | {
|
||||
creator?: never;
|
||||
creatorId: ForeignKey<"creator">;
|
||||
})) & ({
|
||||
entity?: never;
|
||||
entityId?: never;
|
||||
withdraw: Withdraw.CreateSingleOperation;
|
||||
} | {
|
||||
entity: "withdraw";
|
||||
entityId: ForeignKey<"Withdraw">;
|
||||
withdraw?: Withdraw.UpdateOperation;
|
||||
} | {
|
||||
entity: "withdraw";
|
||||
entityId: ForeignKey<"Withdraw">;
|
||||
withdraw?: never;
|
||||
} | {
|
||||
entity?: string;
|
||||
entityId?: string;
|
||||
[K: string]: any;
|
||||
}) & {
|
||||
})) & {
|
||||
sysAccountOper$refund?: OakOperation<"create", Omit<SysAccountOper.CreateOperationData, "refund" | "refundId">[]> | Array<OakOperation<"create", Omit<SysAccountOper.CreateOperationData, "refund" | "refundId">>>;
|
||||
accountOper$entity?: OakOperation<"create", Omit<AccountOper.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<AccountOper.CreateOperationData, "entity" | "entityId">>>;
|
||||
};
|
||||
export type CreateSingleOperation = OakOperation<"create", CreateOperationData>;
|
||||
export type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
|
||||
export type CreateOperation = CreateSingleOperation | CreateMultipleOperation;
|
||||
export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "entity" | "entityId" | "payId" | "creatorId">> & (({
|
||||
export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "withdrawId" | "payId" | "creatorId">> & (({
|
||||
withdraw?: Withdraw.CreateSingleOperation;
|
||||
withdrawId?: never;
|
||||
} | {
|
||||
withdraw?: Withdraw.UpdateOperation;
|
||||
withdrawId?: never;
|
||||
} | {
|
||||
withdraw?: Withdraw.RemoveOperation;
|
||||
withdrawId?: never;
|
||||
} | {
|
||||
withdraw?: never;
|
||||
withdrawId?: ForeignKey<"withdraw"> | null;
|
||||
}) & ({
|
||||
pay?: Pay.CreateSingleOperation;
|
||||
payId?: never;
|
||||
} | {
|
||||
|
|
@ -207,33 +217,24 @@ export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "entity" | "enti
|
|||
} | {
|
||||
creator?: never;
|
||||
creatorId?: ForeignKey<"creator">;
|
||||
})) & ({
|
||||
withdraw?: Withdraw.CreateSingleOperation | Withdraw.UpdateOperation | Withdraw.RemoveOperation;
|
||||
entityId?: never;
|
||||
entity?: never;
|
||||
} | {
|
||||
entity?: ("withdraw" | string) | null;
|
||||
entityId?: ForeignKey<"Withdraw"> | null;
|
||||
withdraw?: never;
|
||||
}) & {
|
||||
})) & {
|
||||
[k: string]: any;
|
||||
sysAccountOper$refund?: OakOperation<"create", Omit<SysAccountOper.CreateOperationData, "refund" | "refundId">[]> | Array<OakOperation<"create", Omit<SysAccountOper.CreateOperationData, "refund" | "refundId">>>;
|
||||
accountOper$entity?: OakOperation<"create", Omit<AccountOper.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<AccountOper.CreateOperationData, "entity" | "entityId">>>;
|
||||
};
|
||||
export type UpdateOperation = OakOperation<"update" | ParticularAction | string, UpdateOperationData, Filter, Sorter>;
|
||||
export type RemoveOperationData = {} & (({
|
||||
withdraw?: Withdraw.UpdateOperation | Withdraw.RemoveOperation;
|
||||
}) & ({
|
||||
pay?: Pay.UpdateOperation | Pay.RemoveOperation;
|
||||
}) & ({
|
||||
creator?: User.UpdateOperation | User.RemoveOperation;
|
||||
})) & ({
|
||||
withdraw?: Withdraw.UpdateOperation | Withdraw.RemoveOperation;
|
||||
} | {
|
||||
[k: string]: any;
|
||||
});
|
||||
}));
|
||||
export type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
|
||||
export type Operation = CreateOperation | UpdateOperation | RemoveOperation;
|
||||
export type WithdrawIdSubQuery = Selection<WithdrawIdProjection>;
|
||||
export type PayIdSubQuery = Selection<PayIdProjection>;
|
||||
export type UserIdSubQuery = Selection<UserIdProjection>;
|
||||
export type WithdrawIdSubQuery = Selection<WithdrawIdProjection>;
|
||||
export type RefundIdSubQuery = Selection<RefundIdProjection>;
|
||||
export type EntityDef = {
|
||||
Schema: Schema;
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue