This commit is contained in:
@@ -89,14 +89,19 @@ class ActivityViewSet(viewsets.ReadOnlyModelViewSet):
|
|||||||
order = pending_order
|
order = pending_order
|
||||||
# Update info if needed? Maybe not.
|
# Update info if needed? Maybe not.
|
||||||
else:
|
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(
|
order = Order.objects.create(
|
||||||
wechat_user=user,
|
wechat_user=user,
|
||||||
activity=activity,
|
activity=activity,
|
||||||
total_price=activity.price,
|
total_price=activity.price,
|
||||||
status='pending',
|
status='pending',
|
||||||
quantity=1,
|
quantity=1,
|
||||||
customer_name=signup_info.get('name') or user.nickname or 'Activity User',
|
customer_name=contact_name,
|
||||||
phone_number=signup_info.get('phone') or user.phone_number or '',
|
phone_number=contact_phone,
|
||||||
|
shipping_address=activity.location or '线下活动', # 使用活动地点作为发货地址
|
||||||
)
|
)
|
||||||
|
|
||||||
# Generate Pay Code
|
# Generate Pay Code
|
||||||
@@ -109,7 +114,7 @@ class ActivityViewSet(viewsets.ReadOnlyModelViewSet):
|
|||||||
return Response({'error': f'支付配置错误: {error_msg}'}, status=500)
|
return Response({'error': f'支付配置错误: {error_msg}'}, status=500)
|
||||||
|
|
||||||
code, message = wxpay.pay(
|
code, message = wxpay.pay(
|
||||||
description=f"报名: {activity.title}",
|
description=f"报名活动: {activity.title}",
|
||||||
out_trade_no=out_trade_no,
|
out_trade_no=out_trade_no,
|
||||||
amount={
|
amount={
|
||||||
'total': int(activity.price * 100),
|
'total': int(activity.price * 100),
|
||||||
|
|||||||
@@ -100,8 +100,8 @@ DATABASES = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# 从环境变量获取数据库配置 (Docker 环境会自动注入这些变量)
|
# 从环境变量获取数据库配置 (Docker 环境会自动注入这些变量)
|
||||||
# DB_HOST = os.environ.get('DB_HOST', '121.43.104.161')
|
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', '6.6.6.66')
|
||||||
if DB_HOST:
|
if DB_HOST:
|
||||||
DATABASES['default'] = {
|
DATABASES['default'] = {
|
||||||
'ENGINE': 'django.db.backends.postgresql',
|
'ENGINE': 'django.db.backends.postgresql',
|
||||||
@@ -109,8 +109,8 @@ if DB_HOST:
|
|||||||
'USER': os.environ.get('DB_USER', 'market'),
|
'USER': os.environ.get('DB_USER', 'market'),
|
||||||
'PASSWORD': os.environ.get('DB_PASSWORD', '123market'),
|
'PASSWORD': os.environ.get('DB_PASSWORD', '123market'),
|
||||||
'HOST': DB_HOST,
|
'HOST': DB_HOST,
|
||||||
#'PORT': os.environ.get('DB_PORT', '6433'),
|
'PORT': os.environ.get('DB_PORT', '6433'),
|
||||||
'PORT': os.environ.get('DB_PORT', '5432'),
|
#'PORT': os.environ.get('DB_PORT', '5432'),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -93,10 +93,15 @@ const ActivityDetail = () => {
|
|||||||
const signUpMutation = useMutation({
|
const signUpMutation = useMutation({
|
||||||
mutationFn: (values) => signUpActivity(id, { signup_info: values || {} }),
|
mutationFn: (values) => signUpActivity(id, { signup_info: values || {} }),
|
||||||
onSuccess: (data) => {
|
onSuccess: (data) => {
|
||||||
|
// 检查是否需要支付
|
||||||
if (data.payment_required) {
|
if (data.payment_required) {
|
||||||
setPaymentInfo(data);
|
setPaymentInfo(data);
|
||||||
setPaymentModalVisible(true);
|
// 先关闭报名表单,确保层级正确
|
||||||
setSignupFormVisible(false);
|
setSignupFormVisible(false);
|
||||||
|
// 延迟一点点时间打开支付弹窗,避免状态更新冲突
|
||||||
|
setTimeout(() => {
|
||||||
|
setPaymentModalVisible(true);
|
||||||
|
}, 100);
|
||||||
message.info(data.message || '请扫码支付');
|
message.info(data.message || '请扫码支付');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -471,12 +476,15 @@ const ActivityDetail = () => {
|
|||||||
footer={null}
|
footer={null}
|
||||||
destroyOnHidden
|
destroyOnHidden
|
||||||
width={360}
|
width={360}
|
||||||
|
zIndex={1001} // 确保层级高于其他弹窗
|
||||||
>
|
>
|
||||||
<div style={{ textAlign: 'center', padding: '20px 0' }}>
|
<div style={{ textAlign: 'center', padding: '20px 0' }}>
|
||||||
{paymentInfo?.code_url ? (
|
{paymentInfo?.code_url ? (
|
||||||
<>
|
<>
|
||||||
<QRCodeSVG value={paymentInfo.code_url} size={200} />
|
<div style={{ background: '#fff', padding: 10, display: 'inline-block' }}>
|
||||||
<p style={{ marginTop: 20, fontSize: 16, fontWeight: 'bold' }}>¥{paymentInfo.price}</p>
|
<QRCodeSVG value={paymentInfo.code_url} size={200} />
|
||||||
|
</div>
|
||||||
|
<p style={{ marginTop: 20, fontSize: 18, fontWeight: 'bold' }}>¥{paymentInfo.price}</p>
|
||||||
<p style={{ color: '#666' }}>请使用微信扫一扫支付</p>
|
<p style={{ color: '#666' }}>请使用微信扫一扫支付</p>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
Reference in New Issue
Block a user