Commit 924ec0e0 authored by Bill's avatar Bill

fix: 修改结算支付订单相同导致服务支付

parent f41c8893
import React, { useState } from 'react';
import React, { useEffect, useState } from 'react';
import { Button, Input, message, Modal } from 'antd';
import styles from './index.less'
import useCountDown from '@/utils/hooks';
......@@ -13,11 +13,13 @@ interface Iprops {
// onResendCode: () => void,
/** 商户订单号 */
tradeCode: string
onClose?: () => void
onClose?: () => void,
/** 时间戳随机码 */
randomCode: string
}
const GetCodeModal: React.FC<Iprops> = (props: Iprops) => {
const { title = '验证码', onOk, visible, tradeCode, onClose } = props;
const { title = '验证码', onOk, visible, tradeCode, onClose, randomCode } = props;
const [code, setCode] = useState<string>("");
const { text, isActive, start } = useCountDown({
maxTime: 60,
......@@ -35,13 +37,19 @@ const GetCodeModal: React.FC<Iprops> = (props: Iprops) => {
onOk?.(code)
}
useEffect(() => {
if (visible) {
start();
}
}, [visible])
const handleChange = (e) => {
setCode(e.target.value);
}
const handleSendCode = async () => {
const { code, data } = await getPayEAccountAllInPayReSendPayCode({
tradeCode: tradeCode
tradeCode: `${tradeCode}-${randomCode}`
})
if (code === 1000) {
start();
......@@ -70,7 +78,7 @@ const GetCodeModal: React.FC<Iprops> = (props: Iprops) => {
</div>
<Button disabled={isActive} onClick={handleSendCode}>{text}</Button>
</div>
<div className={styles.tips}>已将验证码发送到您尾号为2800的手机号</div>
{/* <div className={styles.tips}>已将验证码发送到您尾号为2800的手机号</div> */}
</div>
</Modal>
)
......
......@@ -54,6 +54,11 @@ const SettlementList = () => {
const [files, setFiles] = useState([]);
const [qrcodeUrl, setQrcodeUrl] = useState<string>("");
const [currentUniversalPay, setCurrentUniversalPay] = useState<UniversalPay | null>(null);
/**
* 时间戳做随机码,
* 这里有个场景就是当我付款时,点微信支付等,然后取消了付款,再次点付款(微信支付),此时通联那边会认为这个支付订单会重复了,所以需要虚构一个随机码去标识一下
* */
const [randomCode, setRandomCode] = useState<string>("");
/** 轮询请求支付状态 */
const { cycleCancel, cycleStart, result } = useCycleRequest({ offsetTime: 3, endCount: 10 });
......@@ -163,14 +168,16 @@ const SettlementList = () => {
const channel = params.payChannel;
try {
setUniversalPayLoading(true)
// TODO 加一个随机数
const { data, code, message: msg } = await postSettleAccountsMemberSettlementCommunicationPay({
id: itemInfo.id,
payChannelType: params.payChannel,
})
}, {ctlType: 'none'})
if (code !== 1000) {
message.error(msg);
return;
}
setRandomCode("" + new Date().valueOf());
setCurrentUniversalPay(channel as UniversalPay);
if ([UNIVERSAL_PAY_WECHAT, UNIVERSAL_PAY_ALIPAY].includes(channel)) {
message.loading({
......@@ -201,13 +208,14 @@ const SettlementList = () => {
/** 轮询接口 */
useEffect(() => {
if (modals.qrcodeModal) {
cycleStart(postSettleAccountsMemberSettlementCommunicationPayResult, { settlementNo: itemInfo.settlementNo });
cycleStart(postSettleAccountsMemberSettlementCommunicationPayResult, { settlementNo: `${itemInfo.settlementNo}-${randomCode}` });
}
}, [modals])
useEffect(() => {
if (result && result.code === 1000 && result.data ) {
message.success('支付成功')
handleClose('qrcodeModal');
cycleCancel();
formActions.submit();
}
......@@ -304,7 +312,7 @@ const SettlementList = () => {
onOk={handleCompleteSmsCode}
tradeCode={itemInfo?.settlementNo}
onClose={() => handleClose('smsCodeModal')}
randomCode={randomCode}
/>
</PageHeaderWrapper>
)
......
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