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;
onSetPays: (pays: Partial<EntityDict['pay']['CreateOperationData']>[]) => void;
accountTips: string;
autoStartPay: boolean;
}>) => React.ReactElement;
export default _default;

View File

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

View File

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