Merge branch 'dev' of gitea.51mars.com:Oak-Team/oak-pay-business into dev
This commit is contained in:
commit
0beacb0713
|
|
@ -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;
|
||||
|
|
@ -17,7 +17,7 @@ export declare function getWithdrawCreateData(params: {
|
|||
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;
|
||||
}) | (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;
|
||||
|
|
@ -31,7 +31,7 @@ export declare function getWithdrawCreateData(params: {
|
|||
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;
|
||||
}) | (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;
|
||||
|
|
@ -45,7 +45,7 @@ export declare function getWithdrawCreateData(params: {
|
|||
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;
|
||||
}) | (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;
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ const checkers = [
|
|||
},
|
||||
},
|
||||
action: 'create',
|
||||
errMsg: 'error::refund.create.hasAnotherRefunding',
|
||||
},
|
||||
{
|
||||
entity: 'refund',
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ declare const List: <T extends keyof EntityDict>(props: ReactComponentProps<Enti
|
|||
rowSelection?: any;
|
||||
hideHeader?: boolean | undefined;
|
||||
disableSerialNumber?: boolean | undefined;
|
||||
size?: "large" | "middle" | "small" | undefined;
|
||||
size?: "small" | "middle" | "large" | undefined;
|
||||
scroll?: any;
|
||||
locale?: any;
|
||||
opWidth?: number | undefined;
|
||||
|
|
@ -41,7 +41,7 @@ declare const ListPro: <T extends keyof EntityDict>(props: {
|
|||
tablePagination?: any;
|
||||
rowSelection?: any;
|
||||
disableSerialNumber?: boolean | undefined;
|
||||
size?: "large" | "middle" | "small" | undefined;
|
||||
size?: "small" | "middle" | "large" | undefined;
|
||||
scroll?: any;
|
||||
locale?: any;
|
||||
opWidth?: number | undefined;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ export declare class BackendRuntimeContext<ED extends EntityDict & BaseEntityDic
|
|||
type?: number | undefined;
|
||||
systemId?: number | undefined;
|
||||
system?: import("../oak-app-domain/System/Schema").Projection | undefined;
|
||||
config?: number | import("oak-domain/lib/types").JsonProjection<import("../oak-app-domain/Application/Schema").WebConfig | import("../oak-app-domain/Application/Schema").WechatMpConfig | import("../oak-app-domain/Application/Schema").WechatPublicConfig | import("../oak-app-domain/Application/Schema").NativeConfig> | undefined;
|
||||
config?: number | import("oak-domain/lib/types").JsonProjection<import("../oak-app-domain/Application/Schema").WechatMpConfig | import("../oak-app-domain/Application/Schema").WebConfig | import("../oak-app-domain/Application/Schema").WechatPublicConfig | import("../oak-app-domain/Application/Schema").NativeConfig> | undefined;
|
||||
style?: number | import("oak-domain/lib/types").JsonProjection<import("oak-general-business/lib/types/Style").Style> | undefined;
|
||||
domainId?: number | undefined;
|
||||
domain?: import("../oak-app-domain/Domain/Schema").Projection | undefined;
|
||||
|
|
|
|||
|
|
@ -10,8 +10,13 @@ const actionAuths = [
|
|||
deActions: ['select', 'create']
|
||||
},
|
||||
{
|
||||
id: 'user-acc-pay',
|
||||
pathId: 'user-acc-pay',
|
||||
id: 'creator-order-pay',
|
||||
pathId: 'creator-order-pay',
|
||||
deActions: ['select', 'create', 'startPaying', 'startRefunding', 'close']
|
||||
},
|
||||
{
|
||||
id: 'user-dep-acc-pay',
|
||||
pathId: 'user-dep-acc-pay',
|
||||
deActions: ['select', 'update', 'startPaying', 'startRefunding', 'close']
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -766,6 +766,11 @@ const i18ns = [
|
|||
"order": {
|
||||
"payAmountNotEnough": "支付的额度总和不足",
|
||||
"nonePay": "没有传入支付信息"
|
||||
},
|
||||
"refund": {
|
||||
"create": {
|
||||
"hasAnotherRefunding": "您有一笔退款正在进行中"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -7,10 +7,10 @@ const paths = [
|
|||
recursive: false,
|
||||
},
|
||||
{
|
||||
id: 'user-acc-pay',
|
||||
id: 'user-dep-acc-pay',
|
||||
sourceEntity: 'user',
|
||||
destEntity: 'pay',
|
||||
value: 'account.user',
|
||||
value: 'deposit.account.user',
|
||||
recursive: false,
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -16,5 +16,10 @@
|
|||
"order": {
|
||||
"payAmountNotEnough": "支付的额度总和不足",
|
||||
"nonePay": "没有传入支付信息"
|
||||
},
|
||||
"refund": {
|
||||
"create": {
|
||||
"hasAnotherRefunding": "您有一笔退款正在进行中"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,8 +34,7 @@ export const desc = {
|
|||
: {
|
||||
type: "object"
|
||||
},
|
||||
entity // 如果为true,则按照渠道taxLossRatio和refundCompensateRatio进行扣取(如果因为depositLossRatio已经大于taxLossRatio,则全额退款)
|
||||
: {
|
||||
entity: {
|
||||
type: "varchar",
|
||||
params: {
|
||||
length: 32
|
||||
|
|
|
|||
|
|
@ -208,7 +208,9 @@ async function tryCompleteAccountPay(payId, context) {
|
|||
await context.operate('pay', {
|
||||
id: await generateNewIdAsync(),
|
||||
action: 'succeedPaying',
|
||||
data: {},
|
||||
data: {
|
||||
successAt: Date.now(),
|
||||
},
|
||||
filter: {
|
||||
id: payId2,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,9 @@ async function startRefunding(context, data) {
|
|||
settled: 1,
|
||||
}
|
||||
},
|
||||
filter: {
|
||||
id: data.payId,
|
||||
}
|
||||
}, { dontCollect: true });
|
||||
const { paid, refunded, deposit, order } = pay;
|
||||
assert(paid - refunded >= data.price);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,6 @@ import { BRC } from '../types/RuntimeCxt';
|
|||
* @param context
|
||||
* @param refunds
|
||||
*/
|
||||
export declare function updateWithdrawState(context: BRC, id: string): Promise<0 | 1>;
|
||||
export declare function updateWithdrawState(context: BRC, id: string): Promise<1 | 0>;
|
||||
declare const triggers: Trigger<EntityDict, 'withdraw', BRC>[];
|
||||
export default triggers;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ export declare const mergedProjection: {
|
|||
type?: number | undefined;
|
||||
systemId?: number | undefined;
|
||||
system?: import("../oak-app-domain/System/Schema").Projection | undefined;
|
||||
config?: number | import("oak-domain/lib/types").JsonProjection<import("../oak-app-domain/Application/Schema").WebConfig | import("../oak-app-domain/Application/Schema").WechatMpConfig | import("../oak-app-domain/Application/Schema").WechatPublicConfig | import("../oak-app-domain/Application/Schema").NativeConfig> | undefined;
|
||||
config?: number | import("oak-domain/lib/types").JsonProjection<import("../oak-app-domain/Application/Schema").WechatMpConfig | import("../oak-app-domain/Application/Schema").WebConfig | import("../oak-app-domain/Application/Schema").WechatPublicConfig | import("../oak-app-domain/Application/Schema").NativeConfig> | undefined;
|
||||
style?: number | import("oak-domain/lib/types").JsonProjection<import("oak-general-business/lib/types/Style").Style> | undefined;
|
||||
domainId?: number | undefined;
|
||||
domain?: import("../oak-app-domain/Domain/Schema").Projection | undefined;
|
||||
|
|
|
|||
|
|
@ -72,7 +72,8 @@ export default class Account {
|
|||
getState(pay) {
|
||||
throw new Error("account类型的pay不应该需要查询此状态");
|
||||
}
|
||||
close(pay) {
|
||||
throw new Error("account类型的pay无法关闭");
|
||||
async close(pay) {
|
||||
// throw new Error("account类型的pay无法关闭");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ const checkers = [
|
|||
},
|
||||
},
|
||||
action: 'create',
|
||||
errMsg: 'error::refund.create.hasAnotherRefunding',
|
||||
},
|
||||
{
|
||||
entity: 'refund',
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ export declare class BackendRuntimeContext<ED extends EntityDict & BaseEntityDic
|
|||
type?: number | undefined;
|
||||
systemId?: number | undefined;
|
||||
system?: import("../oak-app-domain/System/Schema").Projection | undefined;
|
||||
config?: number | import("oak-domain/lib/types").JsonProjection<import("../oak-app-domain/Application/Schema").WebConfig | import("../oak-app-domain/Application/Schema").WechatMpConfig | import("../oak-app-domain/Application/Schema").WechatPublicConfig | import("../oak-app-domain/Application/Schema").NativeConfig> | undefined;
|
||||
config?: number | import("oak-domain/lib/types").JsonProjection<import("../oak-app-domain/Application/Schema").WechatMpConfig | import("../oak-app-domain/Application/Schema").WebConfig | import("../oak-app-domain/Application/Schema").WechatPublicConfig | import("../oak-app-domain/Application/Schema").NativeConfig> | undefined;
|
||||
style?: number | import("oak-domain/lib/types").JsonProjection<import("oak-general-business/lib/types/Style").Style> | undefined;
|
||||
domainId?: number | undefined;
|
||||
domain?: import("../oak-app-domain/Domain/Schema").Projection | undefined;
|
||||
|
|
|
|||
|
|
@ -12,8 +12,13 @@ const actionAuths = [
|
|||
deActions: ['select', 'create']
|
||||
},
|
||||
{
|
||||
id: 'user-acc-pay',
|
||||
pathId: 'user-acc-pay',
|
||||
id: 'creator-order-pay',
|
||||
pathId: 'creator-order-pay',
|
||||
deActions: ['select', 'create', 'startPaying', 'startRefunding', 'close']
|
||||
},
|
||||
{
|
||||
id: 'user-dep-acc-pay',
|
||||
pathId: 'user-dep-acc-pay',
|
||||
deActions: ['select', 'update', 'startPaying', 'startRefunding', 'close']
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -768,6 +768,11 @@ const i18ns = [
|
|||
"order": {
|
||||
"payAmountNotEnough": "支付的额度总和不足",
|
||||
"nonePay": "没有传入支付信息"
|
||||
},
|
||||
"refund": {
|
||||
"create": {
|
||||
"hasAnotherRefunding": "您有一笔退款正在进行中"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ const paths = [
|
|||
recursive: false,
|
||||
},
|
||||
{
|
||||
id: 'user-acc-pay',
|
||||
id: 'user-dep-acc-pay',
|
||||
sourceEntity: 'user',
|
||||
destEntity: 'pay',
|
||||
value: 'account.user',
|
||||
value: 'deposit.account.user',
|
||||
recursive: false,
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -16,5 +16,10 @@
|
|||
"order": {
|
||||
"payAmountNotEnough": "支付的额度总和不足",
|
||||
"nonePay": "没有传入支付信息"
|
||||
},
|
||||
"refund": {
|
||||
"create": {
|
||||
"hasAnotherRefunding": "您有一笔退款正在进行中"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,8 +37,7 @@ exports.desc = {
|
|||
: {
|
||||
type: "object"
|
||||
},
|
||||
entity // 如果为true,则按照渠道taxLossRatio和refundCompensateRatio进行扣取(如果因为depositLossRatio已经大于taxLossRatio,则全额退款)
|
||||
: {
|
||||
entity: {
|
||||
type: "varchar",
|
||||
params: {
|
||||
length: 32
|
||||
|
|
|
|||
|
|
@ -211,7 +211,9 @@ async function tryCompleteAccountPay(payId, context) {
|
|||
await context.operate('pay', {
|
||||
id: await (0, uuid_1.generateNewIdAsync)(),
|
||||
action: 'succeedPaying',
|
||||
data: {},
|
||||
data: {
|
||||
successAt: Date.now(),
|
||||
},
|
||||
filter: {
|
||||
id: payId2,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,9 @@ async function startRefunding(context, data) {
|
|||
settled: 1,
|
||||
}
|
||||
},
|
||||
filter: {
|
||||
id: data.payId,
|
||||
}
|
||||
}, { dontCollect: true });
|
||||
const { paid, refunded, deposit, order } = pay;
|
||||
(0, assert_1.default)(paid - refunded >= data.price);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ export declare const mergedProjection: {
|
|||
type?: number | undefined;
|
||||
systemId?: number | undefined;
|
||||
system?: import("../oak-app-domain/System/Schema").Projection | undefined;
|
||||
config?: number | import("oak-domain/lib/types").JsonProjection<import("../oak-app-domain/Application/Schema").WebConfig | import("../oak-app-domain/Application/Schema").WechatMpConfig | import("../oak-app-domain/Application/Schema").WechatPublicConfig | import("../oak-app-domain/Application/Schema").NativeConfig> | undefined;
|
||||
config?: number | import("oak-domain/lib/types").JsonProjection<import("../oak-app-domain/Application/Schema").WechatMpConfig | import("../oak-app-domain/Application/Schema").WebConfig | import("../oak-app-domain/Application/Schema").WechatPublicConfig | import("../oak-app-domain/Application/Schema").NativeConfig> | undefined;
|
||||
style?: number | import("oak-domain/lib/types").JsonProjection<import("oak-general-business/lib/types/Style").Style> | undefined;
|
||||
domainId?: number | undefined;
|
||||
domain?: import("../oak-app-domain/Domain/Schema").Projection | undefined;
|
||||
|
|
|
|||
|
|
@ -75,8 +75,9 @@ class Account {
|
|||
getState(pay) {
|
||||
throw new Error("account类型的pay不应该需要查询此状态");
|
||||
}
|
||||
close(pay) {
|
||||
throw new Error("account类型的pay无法关闭");
|
||||
async close(pay) {
|
||||
// throw new Error("account类型的pay无法关闭");
|
||||
return;
|
||||
}
|
||||
}
|
||||
exports.default = Account;
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ const checkers: Checker<EntityDict, 'refund', RuntimeCxt>[] = [
|
|||
},
|
||||
},
|
||||
action: 'create',
|
||||
errMsg: 'error::refund.create.hasAnotherRefunding',
|
||||
},
|
||||
{
|
||||
entity: 'refund',
|
||||
|
|
|
|||
|
|
@ -12,8 +12,13 @@ const actionAuths: ActionAuth[] = [
|
|||
deActions: ['select', 'create']
|
||||
},
|
||||
{
|
||||
id: 'user-acc-pay',
|
||||
pathId: 'user-acc-pay',
|
||||
id: 'creator-order-pay',
|
||||
pathId: 'creator-order-pay',
|
||||
deActions: ['select', 'create', 'startPaying', 'startRefunding', 'close']
|
||||
},
|
||||
{
|
||||
id: 'user-dep-acc-pay',
|
||||
pathId: 'user-dep-acc-pay',
|
||||
deActions: ['select', 'update', 'startPaying', 'startRefunding', 'close']
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -782,6 +782,11 @@ const i18ns: I18n[] = [
|
|||
"order": {
|
||||
"payAmountNotEnough": "支付的额度总和不足",
|
||||
"nonePay": "没有传入支付信息"
|
||||
},
|
||||
"refund": {
|
||||
"create": {
|
||||
"hasAnotherRefunding": "您有一笔退款正在进行中"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { CreateOperationData as Path } from '../oak-app-domain/Path/Schema';
|
||||
|
||||
const paths: Path[] = [
|
||||
const paths: Path[] = [
|
||||
{
|
||||
id: 'creator-order',
|
||||
sourceEntity: 'user',
|
||||
|
|
@ -9,12 +9,13 @@ const paths: Path[] = [
|
|||
recursive: false,
|
||||
},
|
||||
{
|
||||
id: 'user-acc-pay',
|
||||
id: 'user-dep-acc-pay',
|
||||
sourceEntity: 'user',
|
||||
destEntity: 'pay',
|
||||
value: 'account.user',
|
||||
value: 'deposit.account.user',
|
||||
recursive: false,
|
||||
},
|
||||
|
||||
{
|
||||
id: 'creator-order-pay',
|
||||
sourceEntity: 'user',
|
||||
|
|
|
|||
|
|
@ -16,5 +16,10 @@
|
|||
"order": {
|
||||
"payAmountNotEnough": "支付的额度总和不足",
|
||||
"nonePay": "没有传入支付信息"
|
||||
},
|
||||
"refund": {
|
||||
"create": {
|
||||
"hasAnotherRefunding": "您有一笔退款正在进行中"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -201,13 +201,13 @@ async function tryCompleteAccountPay(payId: string, context: BRC) {
|
|||
const { order } = pay;
|
||||
if (order) {
|
||||
const { price, iState, pay$order: pays } = order;
|
||||
|
||||
|
||||
assert(iState === 'paying');
|
||||
|
||||
|
||||
const successfulPayIds: string[] = [];
|
||||
const accountPayIds: string[] = [];
|
||||
let totalPaid = 0;
|
||||
|
||||
|
||||
pays?.forEach(
|
||||
(pay) => {
|
||||
const { iState, entity, paid, price } = pay;
|
||||
|
|
@ -224,13 +224,15 @@ async function tryCompleteAccountPay(payId: string, context: BRC) {
|
|||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
if (totalPaid === price) {
|
||||
for (const payId2 of successfulPayIds) {
|
||||
await context.operate('pay', {
|
||||
id: await generateNewIdAsync(),
|
||||
action: 'succeedPaying',
|
||||
data: {},
|
||||
data: {
|
||||
successAt: Date.now(),
|
||||
},
|
||||
filter: {
|
||||
id: payId2,
|
||||
}
|
||||
|
|
@ -251,7 +253,7 @@ async function tryCompleteAccountPay(payId: string, context: BRC) {
|
|||
}, {});
|
||||
}
|
||||
return accountPayIds.length;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -586,7 +588,7 @@ const triggers: Trigger<EntityDict, 'pay', BRC>[] = [
|
|||
|
||||
return cnt;
|
||||
},
|
||||
} as UpdateTriggerInTxn<EntityDict, 'pay', BRC>,
|
||||
} as UpdateTriggerInTxn<EntityDict, 'pay', BRC>,
|
||||
{
|
||||
name: '当pay完成支付时,计算其refundable和forbidRefundAt',
|
||||
entity: 'pay',
|
||||
|
|
@ -623,7 +625,7 @@ const triggers: Trigger<EntityDict, 'pay', BRC>[] = [
|
|||
action: ['startPaying', 'continuePaying', 'succeedPaying'],
|
||||
attributes: ['paid'],
|
||||
when: 'after',
|
||||
fn: async({ operation }, context, option) => {
|
||||
fn: async ({ operation }, context, option) => {
|
||||
const { filter } = operation;
|
||||
const ids = getRelevantIds(filter!);
|
||||
assert(ids.length === 1);
|
||||
|
|
@ -636,12 +638,12 @@ const triggers: Trigger<EntityDict, 'pay', BRC>[] = [
|
|||
name: '当有pay关闭时,如果是account类型的,将金额还给account,否则检查会否测试相关Account pay是否需要关闭',
|
||||
action: 'close',
|
||||
when: 'after',
|
||||
fn: async({ operation }, context, option) => {
|
||||
fn: async ({ operation }, context, option) => {
|
||||
const { filter } = operation;
|
||||
const ids = getRelevantIds(filter!);
|
||||
assert(ids.length === 1);
|
||||
|
||||
const [ pay ] = await context.select('pay', {
|
||||
const [pay] = await context.select('pay', {
|
||||
data: {
|
||||
id: 1,
|
||||
price: 1,
|
||||
|
|
|
|||
|
|
@ -30,6 +30,9 @@ async function startRefunding(context: BRC, data: EntityDict['refund']['CreateSi
|
|||
settled: 1,
|
||||
}
|
||||
},
|
||||
filter: {
|
||||
id: data.payId,
|
||||
}
|
||||
}, { dontCollect: true });
|
||||
|
||||
const { paid, refunded, deposit, order } = pay;
|
||||
|
|
@ -43,7 +46,7 @@ async function startRefunding(context: BRC, data: EntityDict['refund']['CreateSi
|
|||
if (order.settled) {
|
||||
// 如果已经分账,退款的钱要有明确的来源account
|
||||
const { accountOper$entity: opers } = data;
|
||||
|
||||
|
||||
assert(opers && opers instanceof Array, '订单退款一定要有相应的account来源');
|
||||
let amount = 0;
|
||||
opers.forEach(
|
||||
|
|
@ -340,7 +343,7 @@ const triggers: Trigger<EntityDict, 'refund', BRC>[] = [
|
|||
id: ids[0],
|
||||
},
|
||||
}, {});
|
||||
|
||||
|
||||
const { id, price, pay } = refund;
|
||||
const { price: payPrice, refunded, entity, entityId, applicationId } = pay!;
|
||||
|
||||
|
|
|
|||
|
|
@ -34,12 +34,13 @@ export default class Account implements PayClazz {
|
|||
return ['refuding', undefined];
|
||||
}
|
||||
decodePayNotification(params: Record<string, any>, body: any): Promise<{
|
||||
payId: string;
|
||||
iState: string | null | undefined;
|
||||
extra?: EntityDict['pay']['Update']['data'] | undefined; }> {
|
||||
payId: string;
|
||||
iState: string | null | undefined;
|
||||
extra?: EntityDict['pay']['Update']['data'] | undefined;
|
||||
}> {
|
||||
throw new Error("account类型的pay不需调用此接口");
|
||||
}
|
||||
|
||||
|
||||
async prepay(pay: EntityDict['pay']['Schema'], data: EntityDict['pay']['Update']['data'], context: BRC) {
|
||||
const { entity, entityId, price } = pay;
|
||||
assert(entity === 'account' && entityId);
|
||||
|
|
@ -77,13 +78,14 @@ export default class Account implements PayClazz {
|
|||
data.meta = {};
|
||||
data.paid = paid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getState(pay: EntityDict['pay']['Schema']): Promise<[string, EntityDict['pay']['Update']['data']]> {
|
||||
throw new Error("account类型的pay不应该需要查询此状态");
|
||||
}
|
||||
close(pay: EntityDict['pay']['Schema']): Promise<void> {
|
||||
throw new Error("account类型的pay无法关闭");
|
||||
async close(pay: EntityDict['pay']['Schema']): Promise<void> {
|
||||
// throw new Error("account类型的pay无法关闭");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue