Commit df3affc3 authored by XieZhiXiong's avatar XieZhiXiong
parents 239fba41 bf4237fe
import { postSettleAccountsMemberSettlementCommunicationPayResult } from '@/services/SettleV2Api';
import React, { useEffect, useRef, useState } from 'react';
type Options = {
/** 间隔秒 */
offsetTime: number
/** 达到多少次就停止 */
endCount: number,
}
const useCycleRequest = (options: Options) => {
const { offsetTime = 3, endCount = 10 } = options || {}
const times = useRef(0);
const interval = useRef<null | ReturnType<typeof setInterval>>(null);
const [result, setResult] = useState(null);
const start = (fn: (params) => Promise<any>, params) => {
interval.current = setInterval(async () => {
// const res = await postSettleAccountsMemberSettlementCommunicationPayResult();
const res = await fn(params);
setResult(res);
times.current += 1;
if (times.current > endCount) {
cancel();
}
}, offsetTime * 1000)
}
const cancel = () => {
if (interval.current) {
clearInterval(interval.current)
}
}
useEffect(() => {
return () => {
cancel()
}
}, [])
return { cycleStart: start, cycleCancel: cancel, result }
}
export default useCycleRequest;
......@@ -12,6 +12,8 @@ import { useCallback } from 'react';
import { GetSettleAccountsMemberSettlementPagePayableSettlementResponseDetail } from '@/services/SettleV2Api';
import { ColumnsType } from 'antd/lib/table';
import { getIntl } from 'umi';
import { getPayAllInPayGetUserInfo } from '@/services/PayV2Api';
import { message } from 'antd';
const intl = getIntl();
const format = "YYYY-MM-DD HH:mm:ss"
const URL_MAP = {
......@@ -23,6 +25,19 @@ const URL_MAP = {
const STATUS_COLOR = ["default", "warning", "primary", "danger", "success"];
/** 通联支付 个人会员 */
const USER_MEMBER_TYPE = 2
/** 通联支付企业会员 */
const ENTERPRISE_MERBER_TYPE =3
/** 通联支付 未认证提示 */
const UNVERIFY_TIPS = {
[USER_MEMBER_TYPE]: '该会员未进行通联实名认证,暂不可收款',
[ENTERPRISE_MERBER_TYPE]: '该会员暂未完成企业信息审核,暂不可收款;',
}
type ModalsType = {
/** 查看付款 */
viewPay: boolean,
......@@ -67,9 +82,21 @@ function useHandleSettlementList() {
})
}, [])
const handleAction = (record: GetSettleAccountsMemberSettlementPagePayableSettlementResponseDetail, key: keyof ModalsType) => {
const handleAction = async (record: GetSettleAccountsMemberSettlementPagePayableSettlementResponseDetail, key: keyof ModalsType) => {
setItemInfo(record);
console.log("key", key);
if (key === 'universalPay') {
const { code, data, message: msg } = await getPayAllInPayGetUserInfo();
if (code !== 1000) {
message.error(msg);
return;
}
if (!(data.memberType === USER_MEMBER_TYPE && data.isIdentityChecked === 1 || data.memberType === ENTERPRISE_MERBER_TYPE && data.status === 2)) {
message.error(UNVERIFY_TIPS[data.memberType])
return;
}
}
handleOpen(key);
/** 通联支付 */
// if (record.payWay === 2 && record.status === COMPLETED) {
......
......@@ -15,7 +15,7 @@ import { fetchOptions } from '../../common'
import UploadVoucherModal from '../../components/UploadVoucherModal';
import Voucher from '../../components/Voucher';
import useSetSearchValueInTable from '@/hooks/useSetSearchValueInTable';
import { getSettleAccountsCommonGetSettlementOrderType, getSettleAccountsCommonGetSettlementStatus, getSettleAccountsMemberSettlementGetPayablePayProve, getSettleAccountsMemberSettlementPagePayableSettlement, GetSettleAccountsMemberSettlementPagePayableSettlementRequest, postSettleAccountsMemberSettlementCommunicationPay, postSettleAccountsMemberSettlementPay } from '@/services/SettleV2Api';
import { getSettleAccountsCommonGetSettlementOrderType, getSettleAccountsCommonGetSettlementStatus, getSettleAccountsMemberSettlementGetPayablePayProve, getSettleAccountsMemberSettlementPagePayableSettlement, GetSettleAccountsMemberSettlementPagePayableSettlementRequest, postSettleAccountsMemberSettlementCommunicationPay, postSettleAccountsMemberSettlementCommunicationPayResult, postSettleAccountsMemberSettlementPay } from '@/services/SettleV2Api';
import { postReportSettlementMemberManualSettlement } from '@/services/ReportV2Api';
import OtherPayModal from '../components/OtherPayModal';
import useHandleSettlementList from './hooks/useHandleSettlementList';
......@@ -24,6 +24,7 @@ import { UNIVERSAL_PAY_ALIPAY, UNIVERSAL_PAY_BALANCE, UNIVERSAL_PAY_QUICK, UNIVE
import GetCodeModal from '../components/GetCodeModal';
import { postPayEAccountAllInPayConfirmPay } from '@/services/PayV2Api';
import QrcodeModal from '../components/QrcodeModal';
import useCycleRequest from './hooks/useCycleRequest';
const { onFieldValueChange$ } = FormEffectHooks
const { RangePicker } = DatePicker;
......@@ -54,6 +55,9 @@ const SettlementList = () => {
const [qrcodeUrl, setQrcodeUrl] = useState<string>("");
const [currentUniversalPay, setCurrentUniversalPay] = useState<UniversalPay | null>(null);
/** 轮询请求支付状态 */
const { cycleCancel, cycleStart, result } = useCycleRequest({ offsetTime: 3, endCount: 10 });
const universalPayInfo1 = useMemo(() => ({
name: itemInfo?.settlementName,
amount: itemInfo?.amount,
......@@ -151,6 +155,7 @@ const SettlementList = () => {
return;
}
handleClose('smsCodeModal');
formActions.submit();
}
/** 通联支付, 付款 */
......@@ -196,10 +201,18 @@ const SettlementList = () => {
/** 轮询接口 */
useEffect(() => {
if (modals.qrcodeModal) {
cycleStart(postSettleAccountsMemberSettlementCommunicationPayResult, { settlementNo: itemInfo.settlementNo });
}
}, [modals])
useEffect(() => {
if (result && result.code === 1000 && result.data ) {
message.success('支付成功')
cycleCancel();
formActions.submit();
}
}, [result])
/**
* 搜索
*/
......
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