80 lines
3.8 KiB
JavaScript
80 lines
3.8 KiB
JavaScript
import { ToYuan, ThousandCont } from "oak-domain/lib/utils/money";
|
|
import dayJs from 'dayjs';
|
|
export default OakComponent({
|
|
properties: {
|
|
withdraw: {},
|
|
create: false,
|
|
},
|
|
formData({ features }) {
|
|
const { withdraw, create } = this.props;
|
|
const { refund$entity: refundData, withdrawTransfer$withdraw: transferData } = withdraw;
|
|
const refundData2 = (refundData)?.map((refund) => {
|
|
const { meta, price, loss, iState, $$updateAt$$, reason } = refund;
|
|
const { lossExplanation, channel } = meta;
|
|
return {
|
|
type: this.t('method.v.refund'),
|
|
typeColor: 'yellow',
|
|
iState: !create && this.t(`refund:v.iState.${iState}`),
|
|
iStateColor: this.features.style.getColor('refund', 'iState', iState),
|
|
lossExp: lossExplanation && this.t(lossExplanation),
|
|
channel: this.t(channel),
|
|
priceYuan: ThousandCont(ToYuan(price), 2),
|
|
lossYuan: ThousandCont(ToYuan(loss), 2),
|
|
finalYuan: ThousandCont(ToYuan(price - loss), 2),
|
|
updateAt: !create && dayJs($$updateAt$$).format('YYYY-MM-DD HH:mm'),
|
|
reason,
|
|
};
|
|
}) || [];
|
|
const transferData2 = transferData?.map((transfer) => {
|
|
const { price, loss, iState, meta, withdrawAccountId, withdrawAccount, $$updateAt$$, reason } = transfer;
|
|
let withdrawChannel = withdrawAccount?.channel;
|
|
if (!withdrawChannel && withdrawAccountId) {
|
|
const [account] = features.cache.get('withdrawAccount', {
|
|
data: {
|
|
id: 1,
|
|
channel: {
|
|
id: 1,
|
|
entity: 1,
|
|
offlineAccount: {
|
|
id: 1,
|
|
type: 1,
|
|
}
|
|
},
|
|
},
|
|
filter: {
|
|
id: withdrawAccountId,
|
|
}
|
|
});
|
|
withdrawChannel = account?.channel;
|
|
}
|
|
const channel = withdrawChannel &&
|
|
(withdrawChannel.entity === 'offlineAccount' ?
|
|
this.t(`withdraw::channel.offlineAccount.${withdrawChannel.offlineAccount?.type}`) :
|
|
this.t(`withdraw::channel.${withdrawChannel.entity}`));
|
|
const { lossExplanation } = meta;
|
|
return {
|
|
type: this.t('method.v.transfer'),
|
|
typeColor: 'skyblue',
|
|
iState: !create && this.t(`withdrawTransfer:v.iState.${iState}`),
|
|
iStateColor: this.features.style.getColor('withdrawTransfer', 'iState', iState),
|
|
lossExp: lossExplanation && this.t(lossExplanation),
|
|
channel,
|
|
priceYuan: ThousandCont(ToYuan(price), 2),
|
|
lossYuan: ThousandCont(ToYuan(loss), 2),
|
|
finalYuan: ThousandCont(ToYuan(price - loss), 2),
|
|
updateAt: !create && dayJs($$updateAt$$).format('YYYY-MM-DD HH:mm'),
|
|
reason,
|
|
};
|
|
}) || [];
|
|
const withdrawExactPrice = ['successful', 'partiallySuccessful', 'failed'].includes(withdraw.iState) ? withdraw.dealPrice - withdraw.dealLoss : withdraw.price - withdraw.loss;
|
|
return {
|
|
createAtStr: dayJs(withdraw.$$createAt$$).format('YYYY-MM-DD HH:mm'),
|
|
withdrawExactPrice: ThousandCont(ToYuan(withdrawExactPrice), 2),
|
|
itemData: refundData2.concat(transferData2),
|
|
step: create ? 0 : withdraw.iState === 'withdrawing' ? 1 : 2,
|
|
// failed: data?.iState === 'failed',
|
|
iState: withdraw.iState,
|
|
};
|
|
}
|
|
});
|