order/pay增加了autoStartPay参数

This commit is contained in:
lxy 2025-02-26 17:51:51 +08:00
parent 1e35bec400
commit 44c1e1164a
3 changed files with 12 additions and 5 deletions

View File

@ -4,5 +4,6 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps<
accountAvailMax: number; accountAvailMax: number;
onSetPays: (pays: Partial<EntityDict['pay']['CreateOperationData']>[]) => void; onSetPays: (pays: Partial<EntityDict['pay']['CreateOperationData']>[]) => void;
accountTips: string; accountTips: string;
autoStartPay: boolean;
}>) => React.ReactElement; }>) => React.ReactElement;
export default _default; export default _default;

View File

@ -24,10 +24,11 @@ export default OakComponent({
}, },
isList: false, isList: false,
properties: { properties: {
accountId: '', // 是否可以使用帐户中的余额抵扣 accountId: '',
accountAvailMax: 0, // 本次交易可以使用的帐户中的Avail max值调用者自己保证此数值的一致性不要扣成负数 accountAvailMax: 0,
onSetPays: (pays) => undefined, onSetPays: (pays) => undefined,
accountTips: '', // 使用余额支付的提示说明 accountTips: '',
autoStartPay: false,
}, },
formData({ data }) { formData({ data }) {
const payChannels = features.pay.getPayChannels('pay'); const payChannels = features.pay.getPayChannels('pay');
@ -118,7 +119,7 @@ export default OakComponent({
}, () => this.tryCreatePays()); }, () => this.tryCreatePays());
}, },
tryCreatePays() { tryCreatePays() {
const { accountId } = this.props; const { accountId, autoStartPay } = this.props;
const { useAccount, accountPrice, channel, meta, order } = this.state; const { useAccount, accountPrice, channel, meta, order } = this.state;
const pays = []; const pays = [];
let rest = order.price - order.paid; let rest = order.price - order.paid;
@ -129,6 +130,7 @@ export default OakComponent({
entity: 'account', entity: 'account',
entityId: accountId, entityId: accountId,
price: accountPrice, price: accountPrice,
autoStart: !!autoStartPay,
}); });
rest = rest - accountPrice; rest = rest - accountPrice;
} }
@ -140,6 +142,7 @@ export default OakComponent({
entityId: channel.entityId, entityId: channel.entityId,
meta, meta,
price: rest, price: rest,
autoStart: !!autoStartPay,
}); });
rest = 0; rest = 0;
} }

View File

@ -31,6 +31,7 @@ export default OakComponent({
accountAvailMax: 0, // 本次交易可以使用的帐户中的Avail max值调用者自己保证此数值的一致性不要扣成负数 accountAvailMax: 0, // 本次交易可以使用的帐户中的Avail max值调用者自己保证此数值的一致性不要扣成负数
onSetPays: (pays: Partial<EntityDict['pay']['CreateOperationData']>[]) => undefined as void, onSetPays: (pays: Partial<EntityDict['pay']['CreateOperationData']>[]) => undefined as void,
accountTips: '', // 使用余额支付的提示说明 accountTips: '', // 使用余额支付的提示说明
autoStartPay: false,
}, },
formData({ data }) { formData({ data }) {
const payChannels = features.pay.getPayChannels('pay'); const payChannels = features.pay.getPayChannels('pay');
@ -121,7 +122,7 @@ export default OakComponent({
}, () => this.tryCreatePays()); }, () => this.tryCreatePays());
}, },
tryCreatePays() { tryCreatePays() {
const { accountId } = this.props; const { accountId, autoStartPay } = this.props;
const { useAccount, accountPrice, channel, meta, order } = this.state; const { useAccount, accountPrice, channel, meta, order } = this.state;
const pays: Partial<EntityDict['pay']['CreateOperationData']>[] = []; const pays: Partial<EntityDict['pay']['CreateOperationData']>[] = [];
let rest = order!.price! - order!.paid!; let rest = order!.price! - order!.paid!;
@ -133,6 +134,7 @@ export default OakComponent({
entity: 'account', entity: 'account',
entityId: accountId, entityId: accountId,
price: accountPrice, price: accountPrice,
autoStart: !!autoStartPay,
}); });
rest = rest - accountPrice; rest = rest - accountPrice;
} }
@ -144,6 +146,7 @@ export default OakComponent({
entityId: channel.entityId, entityId: channel.entityId,
meta, meta,
price: rest, price: rest,
autoStart: !!autoStartPay,
}); });
rest = 0; rest = 0;
} }