V4.9.7 feature (#4669)
* update doc * feat: Add coupon redemption feature for team subscriptions (#4595) * feat: Add coupon redemption feature for team subscriptions - Introduced `TeamCouponSub` and `TeamCouponSchema` types - Added `redeemCoupon` API endpoint - Updated UI to include a modal for coupon redemption - Added new icon and translations for "Redeem coupon" * perf: remove field teamId * perf: use dynamic import * refactor: move to page component * perf: coupon code * perf: mcp server * perf: test * auto layout (#4634) * fix 4.9.6 (#4631) * fix debug quote list * delete next text node match * fix extract default boolean value * export latest 100 chat items * fix quote item ui * doc * fix doc * feat: auto layout * perf: auto layout * fix: auto layout null * add start node --------- Co-authored-by: heheer <heheer@sealos.io> * fix: share link (#4644) * Add workflow run duration;Get audio duration (#4645) * add duration * get audio duration * Custom config path (#4649) * feat: 通过环境变量DATA_PATH获取配置文件目录 (#4622) 通过环境变量DATA_PATH获取配置文件目录,以应对不同的部署方式的多样化需求 * feat: custom configjson path * doc --------- Co-authored-by: John Chen <sss1991@163.com> * 程序api调用场景下,如果大量调用带有图片或视频,产生的聊天记录会导致后台mongo数据库异常。这个修改给api客户端一个禁止生成聊天记录的选项,避免这个后果。 (#3964) * update special chatId * perf: vector db rename * update operationLog (#4647) * update operationLog * combine operationLogMap * solve operationI18nLogMap bug * remoce log * feat: Rerank usage (#4654) * refresh concat when update (#4655) * fix: refresh code * perf: timer lock * Fix operationLog (#4657) * perf: http streamable mcp * add alipay (#4630) * perf: subplan ui * perf: pay code * hiden bank tip * Fix: pay error (#4665) * fix quote number (#4666) * remove log --------- Co-authored-by: a.e. <49438478+I-Info@users.noreply.github.com> Co-authored-by: heheer <heheer@sealos.io> Co-authored-by: John Chen <sss1991@163.com> Co-authored-by: gaord <bengao168@msn.com> Co-authored-by: gggaaallleee <91131304+gggaaallleee@users.noreply.github.com>
This commit is contained in:
@@ -17,9 +17,11 @@ type FormType = {
|
||||
|
||||
const UpdateContactModal = ({
|
||||
onClose,
|
||||
onSuccess,
|
||||
mode
|
||||
}: {
|
||||
onClose: () => void;
|
||||
onSuccess?: (val: string) => void;
|
||||
mode: 'contact' | 'notification_account';
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
@@ -37,20 +39,22 @@ const UpdateContactModal = ({
|
||||
const verifyCode = watch('verifyCode');
|
||||
|
||||
const { runAsync: onSubmit, loading: isLoading } = useRequest2(
|
||||
(data: FormType) => {
|
||||
async (data: FormType) => {
|
||||
if (mode === 'contact') {
|
||||
return updateContact(data);
|
||||
await updateContact(data);
|
||||
} else {
|
||||
return updateNotificationAccount({
|
||||
await updateNotificationAccount({
|
||||
account: data.contact,
|
||||
verifyCode: data.verifyCode
|
||||
});
|
||||
}
|
||||
return data.contact;
|
||||
},
|
||||
{
|
||||
onSuccess() {
|
||||
onSuccess(data) {
|
||||
initUserInfo();
|
||||
onClose();
|
||||
onSuccess?.(data);
|
||||
},
|
||||
successToast: t('common:support.user.info.bind_notification_success'),
|
||||
errorToast: t('common:support.user.info.bind_notification_error')
|
||||
|
||||
@@ -1,36 +1,98 @@
|
||||
import MyModal from '@fastgpt/web/components/common/MyModal';
|
||||
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import { Box, ModalBody } from '@chakra-ui/react';
|
||||
import { checkBalancePayResult } from '@/web/support/wallet/bill/api';
|
||||
import { useToast } from '@fastgpt/web/hooks/useToast';
|
||||
import { Box, ModalBody, Flex, Button } from '@chakra-ui/react';
|
||||
import { checkBalancePayResult, putUpdatePayment } from '@/web/support/wallet/bill/api';
|
||||
import LightTip from '@fastgpt/web/components/common/LightTip';
|
||||
import QRCode from 'qrcode';
|
||||
import { useRequest2 } from '@fastgpt/web/hooks/useRequest';
|
||||
import {
|
||||
BillPayWayEnum,
|
||||
BillStatusEnum,
|
||||
QR_CODE_SIZE
|
||||
} from '@fastgpt/global/support/wallet/bill/constants';
|
||||
import { useSystemStore } from '@/web/common/system/useSystemStore';
|
||||
import Markdown from '@/components/Markdown';
|
||||
import MyIcon from '@fastgpt/web/components/common/Icon';
|
||||
import { useToast } from '@fastgpt/web/hooks/useToast';
|
||||
import { CreateBillResponse } from '@fastgpt/global/support/wallet/bill/api';
|
||||
|
||||
export type QRPayProps = {
|
||||
readPrice: number;
|
||||
codeUrl: string;
|
||||
billId: string;
|
||||
export type QRPayProps = CreateBillResponse & {
|
||||
tip?: string;
|
||||
};
|
||||
|
||||
const qrCodeSize = 168;
|
||||
|
||||
const QRCodePayModal = ({
|
||||
tip,
|
||||
readPrice,
|
||||
codeUrl,
|
||||
billId,
|
||||
payment,
|
||||
qrCode,
|
||||
iframeCode,
|
||||
markdown,
|
||||
onSuccess
|
||||
}: QRPayProps & { tip?: string; onSuccess?: () => any }) => {
|
||||
const { t } = useTranslation();
|
||||
const { toast } = useToast();
|
||||
const canvasRef = useRef<HTMLDivElement>(null);
|
||||
const toast = useToast();
|
||||
const { feConfigs } = useSystemStore();
|
||||
|
||||
const isAlipayConfigured = feConfigs.payConfig?.alipay;
|
||||
const isWxConfigured = feConfigs.payConfig?.wx;
|
||||
const isBankConfigured = feConfigs.payConfig?.bank;
|
||||
|
||||
const [payWayRenderData, setPayWayRenderData] = useState<{
|
||||
qrCode?: string;
|
||||
iframeCode?: string;
|
||||
markdown?: string;
|
||||
}>({
|
||||
qrCode,
|
||||
iframeCode,
|
||||
markdown
|
||||
});
|
||||
|
||||
const [selectedPayment, setSelectedPayment] = useState(payment);
|
||||
const { runAsync: handlePaymentChange, loading: isUpdating } = useRequest2(
|
||||
async (newPayment: BillPayWayEnum) => {
|
||||
if (newPayment === selectedPayment) {
|
||||
return;
|
||||
}
|
||||
|
||||
const response = await putUpdatePayment({ billId, payWay: newPayment });
|
||||
setPayWayRenderData(response);
|
||||
setSelectedPayment(newPayment);
|
||||
},
|
||||
{
|
||||
refreshDeps: [billId, selectedPayment]
|
||||
}
|
||||
);
|
||||
|
||||
// Check pay result
|
||||
useRequest2(() => checkBalancePayResult(billId), {
|
||||
manual: false,
|
||||
pollingInterval: 2000,
|
||||
onSuccess: ({ status, description }) => {
|
||||
if (status === BillStatusEnum.SUCCESS) {
|
||||
toast.toast({
|
||||
description: t('common:pay_success'),
|
||||
status: 'success',
|
||||
duration: 2000
|
||||
});
|
||||
onSuccess?.();
|
||||
} else {
|
||||
console.log(status, description);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// UI render
|
||||
// Draw QR code
|
||||
const drawCode = useCallback(() => {
|
||||
if (!payWayRenderData.qrCode) return;
|
||||
|
||||
const canvas = document.createElement('canvas');
|
||||
QRCode.toCanvas(canvas, codeUrl, {
|
||||
width: qrCodeSize,
|
||||
|
||||
QRCode.toCanvas(canvas, payWayRenderData.qrCode, {
|
||||
width: QR_CODE_SIZE,
|
||||
margin: 0,
|
||||
color: {
|
||||
dark: '#000000',
|
||||
@@ -41,38 +103,125 @@ const QRCodePayModal = ({
|
||||
if (canvasRef.current) {
|
||||
canvasRef.current.innerHTML = '';
|
||||
canvasRef.current.appendChild(canvas);
|
||||
} else {
|
||||
drawCode();
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error('QRCode generation error:', err);
|
||||
});
|
||||
}, [codeUrl]);
|
||||
|
||||
.catch(console.error);
|
||||
}, [payWayRenderData.qrCode]);
|
||||
useEffect(() => {
|
||||
drawCode();
|
||||
}, [drawCode]);
|
||||
|
||||
useRequest2(() => checkBalancePayResult(billId), {
|
||||
manual: false,
|
||||
pollingInterval: 2000,
|
||||
onSuccess: (res) => {
|
||||
if (res) {
|
||||
onSuccess?.();
|
||||
// Payment Button
|
||||
const getPaymentButtonStyles = (isActive: boolean) => ({
|
||||
baseStyle: {
|
||||
display: 'flex',
|
||||
padding: '13px 22px 13px 19px',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
flex: '1 0 0',
|
||||
borderRadius: '7.152px',
|
||||
border: isActive ? '1px solid #3370FF' : '1px solid #E8EBF0',
|
||||
background: '#FFF',
|
||||
_hover: {
|
||||
background: isActive ? '#FFF' : '#F7F8FA',
|
||||
border: isActive ? '1px solid #3370FF' : '1px solid #E8EBF0'
|
||||
},
|
||||
_active: {
|
||||
background: '#FFF',
|
||||
borderColor: '#3370FF'
|
||||
}
|
||||
},
|
||||
errorToast: ''
|
||||
}
|
||||
});
|
||||
const renderPaymentContent = () => {
|
||||
if (payWayRenderData.qrCode) {
|
||||
return <Box ref={canvasRef} display={'inline-block'} h={`${QR_CODE_SIZE}px`} />;
|
||||
}
|
||||
if (payWayRenderData.iframeCode) {
|
||||
return (
|
||||
<iframe
|
||||
srcDoc={payWayRenderData.iframeCode}
|
||||
style={{
|
||||
width: QR_CODE_SIZE + 5,
|
||||
height: QR_CODE_SIZE + 5,
|
||||
border: 'none',
|
||||
display: 'inline-block'
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (payWayRenderData.markdown) {
|
||||
return <Markdown source={payWayRenderData.markdown} />;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
return (
|
||||
<MyModal isOpen title={t('common:user.Pay')} iconSrc="/imgs/modal/pay.svg">
|
||||
<ModalBody textAlign={'center'} pb={10} whiteSpace={'pre-wrap'}>
|
||||
{tip && <LightTip text={tip} mb={8} textAlign={'left'} />}
|
||||
<Box ref={canvasRef} display={'inline-block'} h={`${qrCodeSize}px`}></Box>
|
||||
<Box mt={5} textAlign={'center'}>
|
||||
{t('common:pay.wechat', { price: readPrice })}
|
||||
<MyModal
|
||||
isLoading={isUpdating}
|
||||
isOpen
|
||||
title={t('common:user.Pay')}
|
||||
iconSrc="/imgs/modal/wallet.svg"
|
||||
w={'600px'}
|
||||
>
|
||||
<ModalBody textAlign={'center'} padding={['16px 24px', '32px 52px']}>
|
||||
{tip && <LightTip text={tip} mb={6} textAlign={'left'} />}
|
||||
<Box>{t('common:pay_money')}</Box>
|
||||
<Box color="primary.600" fontSize="32px" fontWeight="600" lineHeight="40px" mb={6}>
|
||||
¥{readPrice.toFixed(2)}
|
||||
</Box>
|
||||
|
||||
{renderPaymentContent()}
|
||||
|
||||
{selectedPayment !== BillPayWayEnum.bank && (
|
||||
<Box
|
||||
mt={5}
|
||||
textAlign={'center'}
|
||||
display="flex"
|
||||
alignItems="center"
|
||||
justifyContent="center"
|
||||
gap={1}
|
||||
>
|
||||
<MyIcon name={'common/info'} w={4} h={4} />
|
||||
{t('common:pay.noclose')}
|
||||
</Box>
|
||||
)}
|
||||
|
||||
<Flex justifyContent="center" gap={3} mt={6}>
|
||||
{isWxConfigured && (
|
||||
<Button
|
||||
flex={1}
|
||||
h={10}
|
||||
onClick={() => handlePaymentChange(BillPayWayEnum.wx)}
|
||||
color={'myGray.900'}
|
||||
leftIcon={<MyIcon name={'common/wechat'} />}
|
||||
sx={getPaymentButtonStyles(selectedPayment === BillPayWayEnum.wx).baseStyle}
|
||||
>
|
||||
{t('common:pay.wx_payment')}
|
||||
</Button>
|
||||
)}
|
||||
{isAlipayConfigured && (
|
||||
<Button
|
||||
flex={1}
|
||||
h={10}
|
||||
color={'myGray.900'}
|
||||
onClick={() => handlePaymentChange(BillPayWayEnum.alipay)}
|
||||
leftIcon={<MyIcon name={'common/alipay'} />}
|
||||
sx={getPaymentButtonStyles(selectedPayment === BillPayWayEnum.alipay).baseStyle}
|
||||
>
|
||||
{t('common:pay_alipay_payment')}
|
||||
</Button>
|
||||
)}
|
||||
{isBankConfigured && (
|
||||
<Button
|
||||
flex={1}
|
||||
h={10}
|
||||
color={'myGray.900'}
|
||||
onClick={() => handlePaymentChange(BillPayWayEnum.bank)}
|
||||
sx={getPaymentButtonStyles(selectedPayment === BillPayWayEnum.bank).baseStyle}
|
||||
>
|
||||
{t('common:pay_corporate_payment')}
|
||||
</Button>
|
||||
)}
|
||||
</Flex>
|
||||
</ModalBody>
|
||||
</MyModal>
|
||||
);
|
||||
|
||||
@@ -38,9 +38,9 @@ const StandardPlanContentList = ({
|
||||
permissionCustomApiKey: plan.permissionCustomApiKey,
|
||||
permissionCustomCopyright: plan.permissionCustomCopyright,
|
||||
trainingWeight: plan.trainingWeight,
|
||||
permissionReRank: plan.permissionReRank,
|
||||
totalPoints: plan.totalPoints * (mode === SubModeEnum.month ? 1 : 12),
|
||||
permissionWebsiteSync: plan.permissionWebsiteSync
|
||||
permissionWebsiteSync: plan.permissionWebsiteSync,
|
||||
permissionTeamOperationLog: plan.permissionTeamOperationLog
|
||||
};
|
||||
}, [subPlans?.standard, level, mode]);
|
||||
|
||||
@@ -113,18 +113,20 @@ const StandardPlanContentList = ({
|
||||
})}
|
||||
</Box>
|
||||
</Flex>
|
||||
{!!planContent.permissionReRank && (
|
||||
<Flex alignItems={'center'}>
|
||||
<MyIcon name={'price/right'} w={'16px'} mr={3} />
|
||||
<Box color={'myGray.600'}>{t('common:support.wallet.subscription.rerank')}</Box>
|
||||
</Flex>
|
||||
)}
|
||||
{!!planContent.permissionWebsiteSync && (
|
||||
<Flex alignItems={'center'}>
|
||||
<MyIcon name={'price/right'} w={'16px'} mr={3} />
|
||||
<Box color={'myGray.600'}>{t('common:support.wallet.subscription.web_site_sync')}</Box>
|
||||
</Flex>
|
||||
)}
|
||||
{!!planContent.permissionTeamOperationLog && (
|
||||
<Flex alignItems={'center'}>
|
||||
<MyIcon name={'price/right'} w={'16px'} mr={3} />
|
||||
<Box color={'myGray.600'}>
|
||||
{t('common:support.wallet.subscription.team_operation_log')}
|
||||
</Box>
|
||||
</Flex>
|
||||
)}
|
||||
</Grid>
|
||||
) : null;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user