修复登陆积分和每日签到积分记录保存和联系我们数据问题

This commit is contained in:
2026-06-26 12:22:50 +08:00
parent 24fac8fc1b
commit af932cce33
5 changed files with 45 additions and 19 deletions
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -28,7 +28,7 @@
}
})();
</script>
<script type="module" crossorigin src="/assets/index-DHcd1Fwz.js"></script>
<script type="module" crossorigin src="/assets/index-BLuHlLoF.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-D7ShJUt4.css">
</head>
<body>
@@ -7,14 +7,14 @@ import { formatDate } from '../utils/formatDate';
interface ContactRequest {
id: string;
user_id: string;
userId: string;
phone: string;
company_name: string;
companyName: string;
industry: string;
name: string;
message: string | null;
is_handled: boolean;
created_at: string;
isHandled: boolean;
createdAt: string;
}
const AdminContactRequests: React.FC = () => {
@@ -99,8 +99,8 @@ const AdminContactRequests: React.FC = () => {
},
{
title: '公司名称',
dataIndex: 'company_name',
key: 'company_name',
dataIndex: 'companyName',
key: 'companyName',
width: 150,
ellipsis: true,
},
@@ -112,8 +112,8 @@ const AdminContactRequests: React.FC = () => {
},
{
title: '状态',
dataIndex: 'is_handled',
key: 'is_handled',
dataIndex: 'isHandled',
key: 'isHandled',
width: 80,
render: (isHandled: boolean) => (
<Tag color={isHandled ? 'green' : 'orange'}>
@@ -123,8 +123,8 @@ const AdminContactRequests: React.FC = () => {
},
{
title: '提交时间',
dataIndex: 'created_at',
key: 'created_at',
dataIndex: 'createdAt',
key: 'createdAt',
width: 160,
render: (date: string) => formatDate(date),
},
@@ -137,7 +137,7 @@ const AdminContactRequests: React.FC = () => {
<Button type="link" size="small" icon={<EyeOutlined />} onClick={() => handleViewDetail(record)}>
</Button>
{!record.is_handled && (
{!record.isHandled && (
<Button type="link" size="small" icon={<CheckOutlined />} onClick={() => handleMarkHandled(record.id)}>
</Button>
@@ -220,19 +220,19 @@ const AdminContactRequests: React.FC = () => {
<div style={{ marginBottom: 16 }}>
<Typography.Title level={4} style={{ marginBottom: 16 }}>
{selectedItem.name}
<Tag color={selectedItem.is_handled ? 'green' : 'orange'} style={{ marginLeft: 12 }}>
{selectedItem.is_handled ? '已处理' : '待处理'}
<Tag color={selectedItem.isHandled ? 'green' : 'orange'} style={{ marginLeft: 12 }}>
{selectedItem.isHandled ? '已处理' : '待处理'}
</Tag>
</Typography.Title>
<div style={{ display: 'grid', gridTemplateColumns: '120px 1fr', gap: 12 }}>
<Typography.Text style={{ color: '#64748b' }}></Typography.Text>
<Typography.Text>{selectedItem.phone}</Typography.Text>
<Typography.Text style={{ color: '#64748b' }}></Typography.Text>
<Typography.Text>{selectedItem.company_name}</Typography.Text>
<Typography.Text>{selectedItem.companyName}</Typography.Text>
<Typography.Text style={{ color: '#64748b' }}></Typography.Text>
<Typography.Text>{selectedItem.industry}</Typography.Text>
<Typography.Text style={{ color: '#64748b' }}></Typography.Text>
<Typography.Text>{formatDate(selectedItem.created_at)}</Typography.Text>
<Typography.Text>{formatDate(selectedItem.createdAt)}</Typography.Text>
{selectedItem.message && (
<>
<Typography.Text style={{ color: '#64748b' }}></Typography.Text>
@@ -242,7 +242,7 @@ const AdminContactRequests: React.FC = () => {
</div>
</div>
<div style={{ display: 'flex', gap: 12 }}>
{!selectedItem.is_handled && (
{!selectedItem.isHandled && (
<Button
type="primary"
onClick={() => {
+26
View File
@@ -10,6 +10,7 @@ from app.dependencies import (
get_current_user_allow_password_pending,
get_db,
)
from app.models.credit_record import CreditRecord
from app.models.system_config import SystemConfig
from app.models.user import User
from app.schemas.auth import (
@@ -86,6 +87,20 @@ async def _get_register_credits(db: AsyncSession) -> int:
return int(value) if value else 100
async def _add_register_credit_record(db: AsyncSession, user: User, credits: int) -> None:
if credits <= 0:
return
record = CreditRecord(
id=generate_id(),
user_id=user.id,
type="recharge",
amount=credits,
balance_after=user.credits,
description=f"注册赠送 {credits} 积分",
)
db.add(record)
async def _handle_daily_login_credits(db: AsyncSession, user: User) -> None:
enabled_result = await db.execute(
select(SystemConfig.value).where(SystemConfig.key == "user_login_credits_enabled").limit(1)
@@ -108,6 +123,16 @@ async def _handle_daily_login_credits(db: AsyncSession, user: User) -> None:
return
user.credits += credits
record = CreditRecord(
id=generate_id(),
user_id=user.id,
type="recharge",
amount=credits,
balance_after=user.credits,
description=f"每日登录赠送 {credits} 积分",
)
db.add(record)
@router.post(
@@ -204,6 +229,7 @@ async def register(req: RegisterRequest, db: AsyncSession = Depends(get_db)):
db.add(user)
await db.flush()
await _add_register_credit_record(db, user, register_credits)
await _assign_default_frontend_menus(db, user)
user.credits = round(user.credits, 2)
+1 -1
View File
@@ -33,7 +33,7 @@ async def create_contact_request(
if daily_count >= 1:
raise HTTPException(
status_code=status.HTTP_429_TOO_MANY_REQUESTS,
detail="每个账号每天只能提交一次联系请求"
detail="每个账号每天只能提交一次联系我们"
)
contact_request = ContactRequest(