diff --git a/backend/community/views.py b/backend/community/views.py index 93ad050..aea131f 100644 --- a/backend/community/views.py +++ b/backend/community/views.py @@ -89,14 +89,19 @@ class ActivityViewSet(viewsets.ReadOnlyModelViewSet): order = pending_order # Update info if needed? Maybe not. else: + # 优先从报名信息获取联系方式 + contact_name = signup_info.get('name') or signup_info.get('participant_name') or user.nickname or 'Activity User' + contact_phone = signup_info.get('phone') or user.phone_number or '' + order = Order.objects.create( wechat_user=user, activity=activity, total_price=activity.price, status='pending', quantity=1, - customer_name=signup_info.get('name') or user.nickname or 'Activity User', - phone_number=signup_info.get('phone') or user.phone_number or '', + customer_name=contact_name, + phone_number=contact_phone, + shipping_address=activity.location or '线下活动', # 使用活动地点作为发货地址 ) # Generate Pay Code @@ -109,7 +114,7 @@ class ActivityViewSet(viewsets.ReadOnlyModelViewSet): return Response({'error': f'支付配置错误: {error_msg}'}, status=500) code, message = wxpay.pay( - description=f"报名: {activity.title}", + description=f"报名活动: {activity.title}", out_trade_no=out_trade_no, amount={ 'total': int(activity.price * 100), diff --git a/backend/config/settings.py b/backend/config/settings.py index 1bb69af..0b5b667 100644 --- a/backend/config/settings.py +++ b/backend/config/settings.py @@ -100,8 +100,8 @@ DATABASES = { } # 从环境变量获取数据库配置 (Docker 环境会自动注入这些变量) -# DB_HOST = os.environ.get('DB_HOST', '121.43.104.161') -DB_HOST = os.environ.get('DB_HOST', '6.6.6.66') +DB_HOST = os.environ.get('DB_HOST', '121.43.104.161') +# DB_HOST = os.environ.get('DB_HOST', '6.6.6.66') if DB_HOST: DATABASES['default'] = { 'ENGINE': 'django.db.backends.postgresql', @@ -109,8 +109,8 @@ if DB_HOST: 'USER': os.environ.get('DB_USER', 'market'), 'PASSWORD': os.environ.get('DB_PASSWORD', '123market'), 'HOST': DB_HOST, - #'PORT': os.environ.get('DB_PORT', '6433'), - 'PORT': os.environ.get('DB_PORT', '5432'), + 'PORT': os.environ.get('DB_PORT', '6433'), + #'PORT': os.environ.get('DB_PORT', '5432'), } diff --git a/frontend/src/pages/activity/Detail.jsx b/frontend/src/pages/activity/Detail.jsx index ae2f49f..8f1ae86 100644 --- a/frontend/src/pages/activity/Detail.jsx +++ b/frontend/src/pages/activity/Detail.jsx @@ -93,10 +93,15 @@ const ActivityDetail = () => { const signUpMutation = useMutation({ mutationFn: (values) => signUpActivity(id, { signup_info: values || {} }), onSuccess: (data) => { + // 检查是否需要支付 if (data.payment_required) { setPaymentInfo(data); - setPaymentModalVisible(true); + // 先关闭报名表单,确保层级正确 setSignupFormVisible(false); + // 延迟一点点时间打开支付弹窗,避免状态更新冲突 + setTimeout(() => { + setPaymentModalVisible(true); + }, 100); message.info(data.message || '请扫码支付'); return; } @@ -471,12 +476,15 @@ const ActivityDetail = () => { footer={null} destroyOnHidden width={360} + zIndex={1001} // 确保层级高于其他弹窗 >
{paymentInfo?.code_url ? ( <> - -

¥{paymentInfo.price}

+
+ +
+

¥{paymentInfo.price}

请使用微信扫一扫支付

) : (