Commit 41afa775 authored by XieZhiXiong's avatar XieZhiXiong

fix: 修复授信相关bug

parent b75f1e10
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2020-09-29 15:04:46
* @LastEditors: XieZhiXiong
* @LastEditTime: 2020-10-26 18:54:44
* @LastEditTime: 2020-12-15 18:20:12
* @Description: 外部流转记录
*/
import React from 'react';
......@@ -45,7 +45,7 @@ const OuterCirculationRecord: React.FC<OuterCirculationRecordProps> = ({
title: '状态',
dataIndex: 'status',
align: 'center',
render: text => <StatusTag type={text} title={CREDIT_OUTER_STATUS[text]} />
render: text => <StatusTag type={CREDIT_OUTER_STATUS_TAG_MAP[text]} title={CREDIT_OUTER_STATUS[text]} />
},
{
title: '操作',
......
......@@ -104,8 +104,8 @@ const QuotaFormQuery: React.FC = () => {
const { startTime, endTime, ...rest } = params;
return new Promise((resolve, reject) => {
PublicApi.getPayCreditApplyPageCreditApply({
startTime: startTime ? moment(startTime).format('YYYY-MM-DD') : null,
endTime: startTime ? moment(startTime).format('YYYY-MM-DD') : null,
startTime: startTime ? moment(+startTime).format('YYYY-MM-DD') : null,
endTime: endTime ? moment(+endTime).format('YYYY-MM-DD') : null,
...rest,
})
.then(res => {
......
......@@ -30,12 +30,12 @@ const BillInfo: React.FC<BillInfoProps> = ({
const [voucherVisible, setVoucherVisible] = useState(false);
const handleCheckVoucher = record => {
if (!Array.isArray(record)) {
setCurrentVoucher([]);
} else {
const voucher = record.map(item => normalizeFiledata(item.proveUrl));
setCurrentVoucher(voucher);
if (!Array.isArray(record) || !record.length) {
return;
}
const voucher = record.map(item => normalizeFiledata(item.proveUrl));
setCurrentVoucher(voucher);
setVoucherVisible(true);
};
......
......@@ -21,6 +21,7 @@ import NiceForm from '@/components/NiceForm';
import { repaymentModalSchema, uploadVoucherModalSchema } from './schema';
import { createEffects } from './effects/repayment';
import TradeRecord, { RecordParams, RecordRes } from '../TradeRecord';
import WxPayModal from '../WxPayModal';
import styles from './index.less';
const repaymentFormActions = createFormActions();
......@@ -125,6 +126,11 @@ interface IntroduceRowState {
};
repaymentSubmitLoading: boolean;
uploadVoucherSubmitLoading: boolean;
wxPayVisible: boolean;
wxPayUrl: string;
wxPayPrice: number;
};
class IntroduceRow extends React.Component<IntroduceRowProps, IntroduceRowState> {
......@@ -151,11 +157,19 @@ class IntroduceRow extends React.Component<IntroduceRowProps, IntroduceRowState>
},
repaymentSubmitLoading: false,
uploadVoucherSubmitLoading: false,
wxPayVisible: false,
wxPayUrl: '',
wxPayPrice: 0,
};
}
tradeRecordRef = null;
/**
* 还款记录id
*/
payRecordId = '';
// 获取账单详情
getBillDetail = id => {
const { fetchBillDetail } = this.props;
......@@ -179,7 +193,7 @@ class IntroduceRow extends React.Component<IntroduceRowProps, IntroduceRowState>
return;
}
PublicApi.getSettleAccountsCorporateAccountConfig({
memberId: payee,
memberId: `${payee}`,
}).then(res => {
if (res.code === 1000) {
this.setState({
......@@ -218,12 +232,12 @@ class IntroduceRow extends React.Component<IntroduceRowProps, IntroduceRowState>
this.setState({ visibleRecord: e.target.checked });
};
handleRepayment = () => {
this.setState({ visibleRepayment: true });
handleRepayment = flag => {
this.setState({ visibleRepayment: !!flag });
};
handleRepaymentSubmit = values => {
const { tradeType } = values;
const { tradeType, tradeChannel } = values;
const { billId } = this.state;
switch (tradeType) {
......@@ -234,8 +248,22 @@ class IntroduceRow extends React.Component<IntroduceRowProps, IntroduceRowState>
billId,
...values,
}).then(res => {
if (res.code === 1000) {
this.setState({ visibleRepayment: false });
if (res.code !== 1000) {
return;
}
message.destroy();
this.setState({ visibleRepayment: false });
switch (tradeChannel) {
// 微信支付
case 1: {
this.setState({
wxPayPrice: values.repayQuota,
wxPayUrl: res.data.payQRCode,
});
this.payRecordId = `${res.data.recordId}`;
this.handleWxPayVisible(true);
}
}
}).finally(() => {
this.setState({ repaymentSubmitLoading: false });
......@@ -280,6 +308,7 @@ class IntroduceRow extends React.Component<IntroduceRowProps, IntroduceRowState>
if (res.code === 1000) {
this.setState({ visibleRepayment: false });
this.setState({ visibleUploadVoucher: false });
this.getBillDetail(this.state.billId);
}
}).finally(() => {
this.setState({ uploadVoucherSubmitLoading: false });
......@@ -320,6 +349,43 @@ class IntroduceRow extends React.Component<IntroduceRowProps, IntroduceRowState>
});
};
handleWxPayVisible = flag => {
this.setState({ wxPayVisible: !!flag });
};
handleCheckResult = (): Promise<{ success: Boolean }> => {
return new Promise((resolve, reject) => {
PublicApi.getPayCreditApplyGetCreditRepayResult({
recordId: `${this.payRecordId}`,
}).then(res => {
if (res.code !== 1000) {
resolve({ success: false });
} else {
// 3 - 确认到账
if (res.data.status === 3) {
resolve({ success: true })
} else {
resolve({ success: false });
}
}
}).catch(err => {
reject(err);
});
});
};
handleWxPaySuccess = () => {
message.success('支付成功');
this.handleWxPayVisible(false);
this.getBillDetail(this.state.billId);
};
handleWxPayFail= () => {
message.success('支付失败,请重试 或 选择其他支付方式');
this.handleWxPayVisible(false);
this.handleRepayment(true);
};
render() {
const {
quotaData = [],
......@@ -336,8 +402,20 @@ class IntroduceRow extends React.Component<IntroduceRowProps, IntroduceRowState>
visibleUploadVoucher,
repaymentSubmitLoading,
uploadVoucherSubmitLoading,
wxPayVisible,
wxPayUrl,
wxPayPrice,
} = this.state;
const WxPayModalPros = {
url: wxPayUrl,
visible: wxPayVisible,
price: wxPayPrice,
onCancel: () => this.handleWxPayVisible(false),
onCheckResult: this.handleCheckResult,
onSuccess: this.handleWxPaySuccess,
};
return (
<>
<Row
......@@ -443,7 +521,7 @@ class IntroduceRow extends React.Component<IntroduceRowProps, IntroduceRowState>
</div>
</div>
<div className={styles['repayment-right']}>
<Button type="primary" onClick={this.handleRepayment}>立即还款</Button>
<Button type="primary" onClick={() => this.handleRepayment(true)}>立即还款</Button>
</div>
</div>
</Col>
......@@ -559,6 +637,10 @@ class IntroduceRow extends React.Component<IntroduceRowProps, IntroduceRowState>
onSubmit={this.handleUploadVoucherSubmit}
/>
</Modal>
<WxPayModal
{...WxPayModalPros}
/>
</>
);
};
......
......@@ -131,12 +131,12 @@ class TradeRecord extends React.Component<TradeRecordProps, TradeRecordState> {
};
handleCheckVoucher = record => {
if (!Array.isArray(record)) {
this.setState({ currentVoucher: [] });
} else {
const voucher = record.map(item => normalizeFiledata(item.proveUrl));
this.setState({ currentVoucher: voucher });
if (!Array.isArray(record) || !record.length) {
return;
}
const voucher = record.map(item => normalizeFiledata(item.proveUrl));
this.setState({ currentVoucher: voucher });
this.setState({ voucherVisible: true });
};
......
.common_title {
font-size: 14px;
color: #303133;
line-height: 14px;
display: flex;
align-items: center;
&_icon {
color: #909399;
margin-left: 6px;
cursor: pointer;
margin-right: 5px;
&>img {
width: 20px;
height: 20px;
}
}
& > span {
font-weight: 500;
}
&_amount {
margin-left: auto;
color: #606266;
& > span {
color: #D32F2F;
font-size: 20px;
margin: 0 5px;
}
}
&_btn {
margin-left: auto;
cursor: pointer;
&:hover {
opacity: .8;
}
}
}
.wechat_payway {
position: relative;
display: flex;
flex-direction: column;
align-items: center;
&_title {
color: #909399;
font-size: 12px;
padding-top: 16px;
padding-bottom: 20px;
}
&_imgbox {
width: 200px;
height: 200px;
border: 1px solid rgba(245, 245, 245, 1);
& > img {
height: 100%;
width: 100%;
}
}
&_needpay {
color: #606266;
font-size: 12px;
margin-top: 28px;
& > span {
color: #D32F2F;
font-size: 20px;
margin: 0 5px;
}
}
}
\ No newline at end of file
/*
* @Author: XieZhiXiong
* @Date: 2020-12-16 11:07:13
* @LastEditors: XieZhiXiong
* @LastEditTime: 2020-12-16 15:09:21
* @Description: 微信支付弹窗
*/
import React, { useState, useEffect, useRef } from 'react';
import { Modal, Upload } from 'antd';
import QRCode from 'qrcode';
import { priceFormat } from '@/utils/numberFomat';
import WechatIcon from '@/assets/imgs/wechat_icon.png';
import styles from './index.less';
interface WxPayModalProps {
/**
* 需要生成 二维码的 地址
*/
url: string;
/**
* 支付金额
*/
price: number;
/**
* 是否可见
*/
visible: boolean;
/**
* 弹窗取消事件
*/
onCancel: () => void;
/**
* 轮训查询支付结果事件
*/
onCheckResult: () => Promise<{ success: Boolean }>;
/**
* 轮训查询支付结果成功
*/
onSuccess?: () => void;
/**
* 轮训查询支付结果失败
*/
onFail?: () => void;
};
const WxPayModal: React.FC<WxPayModalProps> = ({
url,
price,
visible,
onCancel,
onCheckResult,
onSuccess,
onFail,
}) => {
const [qrCode, setQrCode] = useState<string>('');
const getQRCode = async params => {
if (!params) {
return;
}
// 生成二维码
const res = await QRCode.toDataURL(params);
setQrCode(res);
};
let timer = useRef(null);
// 最多请求3600次,2000毫秒一次,二维码过期两小时
let count = 0;
const handleCheckResult = () => {
if (!onCheckResult) {
return;
}
count++;
if (count > 3600) {
return;
}
onCheckResult().then(res => {
if (!res.success) {
timer.current = setTimeout(() => {
handleCheckResult();
}, 2000);
console.log('timer', timer)
} else {
clearTimeout(timer.current);
timer = null;
if (onSuccess) {
onSuccess();
}
}
});
};
useEffect(() => {
getQRCode(url);
if (url) {
handleCheckResult();
}
return () => {
if (timer.current) {
clearTimeout(timer.current);
timer.current = null;
}
};
}, [url]);
useEffect(() => {
if (!visible) {
console.log('隐藏咯')
console.log('timer', timer.current)
if (timer.current) {
clearTimeout(timer.current);
timer.current = null;
}
}
}, [visible]);
const handleCancel = () => {
if (onCancel) {
onCancel();
}
};
return (
<Modal
title={(
<div className={styles.common_title}>
<div className={styles.common_title_icon}><img src={WechatIcon} /></div>
<span>微信支付</span>
</div>
)}
width={576}
visible={visible}
onCancel={handleCancel}
footer={null}
maskClosable={false}
destroyOnClose
>
<div className={styles.wechat_payway}>
<p className={styles.wechat_payway_title}>使用微信扫一扫下方二维码</p>
<div className={styles.wechat_payway_imgbox}>
{qrCode && <img src={qrCode} />}
</div>
<div className={styles.wechat_payway_needpay}>
<label>当前需支付:</label>
<span>{priceFormat(price)}</span>
<label>RMB</label>
</div>
</div>
</Modal>
);
};
export default WxPayModal;
\ No newline at end of file
......@@ -98,7 +98,7 @@ const QuotaMenage: React.FC = () => {
render: (text, record) => (
<Progress
type="circle"
percent={Math.floor(record.useQuota / record.quota) * 100}
percent={record.useQuota / record.quota * 100}
strokeColor="#41CC9E"
strokeWidth={12}
width={40}
......
......@@ -197,7 +197,7 @@ const QuotaPrSubmit: React.FC = () => {
return new Promise((resolve, reject) => {
PublicApi.getPayCreditApplyPageWaitSubmitCreditApply({
startTime: startTime ? moment(+startTime).format('YYYY-MM-DD') : null,
endTime: startTime ? moment(+startTime).format('YYYY-MM-DD') : null,
endTime: endTime ? moment(+endTime).format('YYYY-MM-DD') : null,
...rest,
})
.then(res => {
......
......@@ -106,8 +106,8 @@ const QuotaFormQuery: React.FC = () => {
const { startTime, endTime, ...rest } = params;
return new Promise((resolve, reject) => {
PublicApi.getPayCreditHandlePageCreditChildApply({
startTime: startTime ? moment(startTime).format('YYYY-MM-DD') : null,
endTime: startTime ? moment(startTime).format('YYYY-MM-DD') : null,
startTime: startTime ? moment(+startTime).format('YYYY-MM-DD') : null,
endTime: endTime ? moment(+endTime).format('YYYY-MM-DD') : null,
...rest,
})
.then(res => {
......
......@@ -150,7 +150,7 @@ const QuotaMenage: React.FC = () => {
render: (text, record) => (
<Progress
type="circle"
percent={Math.floor(record.useQuota / record.quota) * 100}
percent={record.useQuota / record.quota* 100}
strokeColor="#41CC9E"
strokeWidth={12}
width={40}
......@@ -267,7 +267,7 @@ const QuotaMenage: React.FC = () => {
);
setColumns(newColumns);
return {
status: statusList.map(item => ({ label: item.name, value: item.status })).filter(item => item.value),
rePayStatus: repayStatusList.map(item => ({ label: item.name, value: item.status })).filter(item => item.value),
......@@ -276,6 +276,27 @@ const QuotaMenage: React.FC = () => {
return {};
};
// 初始化高级筛选会员选项
const fetchSearchMemberItems = async () => {
const res = await PublicApi.getMemberManagePageitems();
if (res.code === 1000) {
const { data = {} }: any = res;
const {
memberTypes = [],
roles = [],
levels = [],
} = data;
return {
memberTypeName: memberTypes.map(item => ({ label: item.memberTypeName, value: item.memberTypeId })),
memberRoleName: roles.map(item => ({ label: item.roleName, value: item.roleId })),
memberLevelName: levels.map(item => ({ label: item.levelTag, value: item.level })),
};
}
return {};
};
const handleSentMsg = () => {
setCollectionModalVisible(false);
setSuccessModalVisible(true);
......@@ -303,9 +324,13 @@ const QuotaMenage: React.FC = () => {
FORM_FILTER_PATH,
);
useAsyncInitSelect(
['innerStatus', 'outerStatus'],
['rePayStatus', 'status'],
fetchSearchItems,
);
useAsyncInitSelect(
['memberLevelName', 'memberTypeName', 'memberRoleName'],
fetchSearchMemberItems,
);
}}
schema={listSearchSchema}
/>
......
......@@ -125,8 +125,8 @@ const QuotaPr1: React.FC = () => {
const { startTime, endTime, applyType = 0, ...rest } = params;
return new Promise((resolve, reject) => {
PublicApi.getPayCreditHandlePageCreditChildWaitVerifyApplyStepOne({
startTime: startTime ? moment(startTime).format('YYYY-MM-DD') : null,
endTime: startTime ? moment(startTime).format('YYYY-MM-DD') : null,
startTime: startTime ? moment(+startTime).format('YYYY-MM-DD') : null,
endTime: endTime ? moment(+endTime).format('YYYY-MM-DD') : null,
applyType,
...rest,
})
......
......@@ -125,8 +125,8 @@ const QuotaPr1: React.FC = () => {
const { startTime, endTime, applyType = 0, ...rest } = params;
return new Promise((resolve, reject) => {
PublicApi.getPayCreditHandlePageCreditChildWaitVerifyApplyStepTwo({
startTime: startTime ? moment(startTime).format('YYYY-MM-DD') : null,
endTime: startTime ? moment(startTime).format('YYYY-MM-DD') : null,
startTime: startTime ? moment(+startTime).format('YYYY-MM-DD') : null,
endTime: endTime ? moment(+endTime).format('YYYY-MM-DD') : null,
applyType,
...rest,
})
......
......@@ -125,8 +125,8 @@ const QuotaPr3: React.FC = () => {
const { startTime, endTime, applyType = 0, ...rest } = params;
return new Promise((resolve, reject) => {
PublicApi.getPayCreditHandlePageCreditChildWaitVerifyApplyStepThree({
startTime: startTime ? moment(startTime).format('YYYY-MM-DD') : null,
endTime: startTime ? moment(startTime).format('YYYY-MM-DD') : null,
startTime: startTime ? moment(+startTime).format('YYYY-MM-DD') : null,
endTime: endTime ? moment(+endTime).format('YYYY-MM-DD') : null,
applyType,
...rest,
})
......
......@@ -125,8 +125,8 @@ const QuotaPrConfirm: React.FC = () => {
const { startTime, endTime, applyType = 0, ...rest } = params;
return new Promise((resolve, reject) => {
PublicApi.getPayCreditHandlePageCreditChildWaitConfirmVerifyApply({
startTime: startTime ? moment(startTime).format('YYYY-MM-DD') : null,
endTime: startTime ? moment(startTime).format('YYYY-MM-DD') : null,
startTime: startTime ? moment(+startTime).format('YYYY-MM-DD') : null,
endTime: endTime ? moment(+endTime).format('YYYY-MM-DD') : null,
applyType,
...rest,
})
......
......@@ -125,8 +125,8 @@ const QuotaPrSubmit: React.FC = () => {
const { startTime, endTime, applyType = 0, ...rest } = params;
return new Promise((resolve, reject) => {
PublicApi.getPayCreditHandlePageCreditChildWaitSubmitApply({
startTime: startTime ? moment(startTime).format('YYYY-MM-DD') : null,
endTime: startTime ? moment(startTime).format('YYYY-MM-DD') : null,
startTime: startTime ? moment(+startTime).format('YYYY-MM-DD') : null,
endTime: endTime ? moment(+endTime).format('YYYY-MM-DD') : null,
applyType,
...rest,
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment