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