第一次提交:小程序前端最新版本
This commit is contained in:
8
a_long_dianjing/__init__.py
Normal file
8
a_long_dianjing/__init__.py
Normal file
@@ -0,0 +1,8 @@
|
||||
"""
|
||||
阿龙电竞 - Django项目初始化
|
||||
确保Celery在Django启动时自动加载
|
||||
"""
|
||||
|
||||
from .celery import app as celery_app
|
||||
|
||||
__all__ = ('celery_app',)
|
||||
BIN
a_long_dianjing/__pycache__/__init__.cpython-312.pyc
Normal file
BIN
a_long_dianjing/__pycache__/__init__.cpython-312.pyc
Normal file
Binary file not shown.
BIN
a_long_dianjing/__pycache__/__init__.cpython-313.pyc
Normal file
BIN
a_long_dianjing/__pycache__/__init__.cpython-313.pyc
Normal file
Binary file not shown.
BIN
a_long_dianjing/__pycache__/celery.cpython-312.pyc
Normal file
BIN
a_long_dianjing/__pycache__/celery.cpython-312.pyc
Normal file
Binary file not shown.
BIN
a_long_dianjing/__pycache__/celery.cpython-313.pyc
Normal file
BIN
a_long_dianjing/__pycache__/celery.cpython-313.pyc
Normal file
Binary file not shown.
BIN
a_long_dianjing/__pycache__/settings.cpython-313.pyc
Normal file
BIN
a_long_dianjing/__pycache__/settings.cpython-313.pyc
Normal file
Binary file not shown.
BIN
a_long_dianjing/__pycache__/urls.cpython-313.pyc
Normal file
BIN
a_long_dianjing/__pycache__/urls.cpython-313.pyc
Normal file
Binary file not shown.
BIN
a_long_dianjing/__pycache__/wsgi.cpython-313.pyc
Normal file
BIN
a_long_dianjing/__pycache__/wsgi.cpython-313.pyc
Normal file
Binary file not shown.
16
a_long_dianjing/asgi.py
Normal file
16
a_long_dianjing/asgi.py
Normal file
@@ -0,0 +1,16 @@
|
||||
"""
|
||||
ASGI config for a_long_dianjing project.
|
||||
|
||||
It exposes the ASGI callable as a module-level variable named ``application``.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/6.0/howto/deployment/asgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.core.asgi import get_asgi_application
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'a_long_dianjing.settings')
|
||||
|
||||
application = get_asgi_application()
|
||||
115
a_long_dianjing/celery.py
Normal file
115
a_long_dianjing/celery.py
Normal file
@@ -0,0 +1,115 @@
|
||||
"""
|
||||
阿龙电竞 - Celery定时任务主配置
|
||||
生产环境就绪版本,支持精确延时任务和周期性任务
|
||||
"""
|
||||
|
||||
import os
|
||||
from celery import Celery
|
||||
from celery.schedules import crontab
|
||||
|
||||
# 设置Django默认设置模块
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'a_long_dianjing.settings')
|
||||
|
||||
# 创建Celery应用实例
|
||||
app = Celery('a_long_dianjing')
|
||||
|
||||
# 从Django settings中加载Celery配置(CELERY_前缀)
|
||||
app.config_from_object('django.conf:settings', namespace='CELERY')
|
||||
|
||||
# 自动发现所有已注册app中的tasks.py文件
|
||||
app.autodiscover_tasks()
|
||||
|
||||
# 配置周期性任务(Celery Beat Schedule)
|
||||
app.conf.beat_schedule = {
|
||||
# 🔥 核心任务:订单调度器(每2分钟运行)
|
||||
'dispatch_pending_orders': {
|
||||
'task': 'dingdan.tasks.dispatch_pending_orders',
|
||||
'schedule': crontab(minute='*/2'),
|
||||
'options': {'queue': 'order_tasks', 'priority': 5},
|
||||
},
|
||||
|
||||
# 🔥 补偿检查任务(每5分钟运行)
|
||||
'check_order_expire_task': {
|
||||
'task': 'dingdan.tasks.check_order_expire_task',
|
||||
'schedule': crontab(minute='*/5'),
|
||||
'options': {'queue': 'order_tasks', 'priority': 3},
|
||||
},
|
||||
# 1. 每日凌晨0点执行 - 清零任务
|
||||
'daily_reset_task': {
|
||||
'task': 'yonghu.tasks.daily_reset_task',
|
||||
'schedule': crontab(hour=0, minute=0), # 每天0点
|
||||
'options': {
|
||||
'queue': 'periodic_tasks',
|
||||
'priority': 5
|
||||
},
|
||||
'args': (),
|
||||
'kwargs': {}
|
||||
},
|
||||
|
||||
# 2. 每月1日凌晨0点执行 - 月度清零任务
|
||||
'monthly_reset_task': {
|
||||
'task': 'yonghu.tasks.monthly_reset_task',
|
||||
'schedule': crontab(hour=0, minute=0, day_of_month=1), # 每月1日0点
|
||||
'options': {
|
||||
'queue': 'periodic_tasks',
|
||||
'priority': 5
|
||||
},
|
||||
'args': (),
|
||||
'kwargs': {}
|
||||
},
|
||||
|
||||
# 3. 每5分钟检查一次待处理订单 - 作为补偿机制
|
||||
'check_order_expire_task': {
|
||||
'task': 'dingdan.tasks.check_order_expire_task',
|
||||
'schedule': crontab(minute='*/5'), # 每5分钟
|
||||
'options': {
|
||||
'queue': 'order_tasks',
|
||||
'priority': 3
|
||||
},
|
||||
'args': (),
|
||||
'kwargs': {}
|
||||
},
|
||||
|
||||
# 4. 每天凌晨0点5分清理收支记录
|
||||
'daily_sz_reset_task': {
|
||||
'task': 'peizhi.tasks.daily_sz_reset_task',
|
||||
'schedule': crontab(hour=0, minute=5), # 每天0点5分
|
||||
'options': {
|
||||
'queue': 'periodic_tasks',
|
||||
'priority': 4
|
||||
},
|
||||
'args': (),
|
||||
'kwargs': {}
|
||||
}
|
||||
}
|
||||
|
||||
# 时区设置
|
||||
app.conf.timezone = 'Asia/Shanghai'
|
||||
app.conf.enable_utc = True
|
||||
|
||||
# 队列路由配置
|
||||
app.conf.task_routes = {
|
||||
'dingdan.tasks.*': {'queue': 'order_tasks'},
|
||||
'yonghu.tasks.*': {'queue': 'periodic_tasks'},
|
||||
'peizhi.tasks.*': {'queue': 'periodic_tasks'},
|
||||
}
|
||||
|
||||
# 任务序列化
|
||||
app.conf.accept_content = ['json']
|
||||
app.conf.task_serializer = 'json'
|
||||
app.conf.result_serializer = 'json'
|
||||
|
||||
# 任务超时设置
|
||||
app.conf.task_time_limit = 300 # 任务最大执行时间300秒
|
||||
app.conf.task_soft_time_limit = 240 # 软超时240秒
|
||||
|
||||
# Worker并发设置
|
||||
app.conf.worker_concurrency = 4
|
||||
app.conf.worker_prefetch_multiplier = 1
|
||||
|
||||
# 任务确认设置
|
||||
app.conf.task_acks_late = True
|
||||
app.conf.worker_disable_rate_limits = True
|
||||
|
||||
# 结果过期时间
|
||||
app.conf.result_expires = 3600 # 任务结果保留1小时
|
||||
114
a_long_dianjing/management/commands/sync_cross_order_status.py
Normal file
114
a_long_dianjing/management/commands/sync_cross_order_status.py
Normal file
@@ -0,0 +1,114 @@
|
||||
import time
|
||||
import requests
|
||||
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.conf import settings
|
||||
from dingdan.models import Dingdan
|
||||
from peizhi.models import Club # 你的俱乐部模型,请确认类名
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = '同步我方派单跨平台订单状态(仅进行中订单,失败直接跳过,不重试)'
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument('--concurrency', type=int, default=3, help='并发数(默认3)')
|
||||
parser.add_argument('--batch', type=int, default=0, help='处理前N单(0=全部)')
|
||||
|
||||
def handle(self, *args, **options):
|
||||
concurrency = options['concurrency']
|
||||
batch = options['batch']
|
||||
|
||||
# 查询待同步订单
|
||||
orders = Dingdan.objects.filter(
|
||||
zhuangtai=2,
|
||||
dispatch_type=1,
|
||||
is_cross=1,
|
||||
partner_club_id__isnull=False,
|
||||
partner_order_id__isnull=False
|
||||
).only('dingdan_id', 'partner_order_id', 'partner_club_id', 'zhuangtai')
|
||||
|
||||
total = orders.count()
|
||||
self.stdout.write(f'待处理订单总数: {total}')
|
||||
if batch > 0:
|
||||
orders = orders[:batch]
|
||||
self.stdout.write(f'本次仅处理前 {batch} 单')
|
||||
|
||||
SYNC_TOKEN = getattr(settings, 'CROSS_PLATFORM_SYNC_TOKEN', 'xK9mP2vL8qW5rT7y')
|
||||
session = requests.Session()
|
||||
session.headers.update({'Content-Type': 'application/json'})
|
||||
|
||||
# 预加载域名映射
|
||||
domain_map = {}
|
||||
for club in Club.objects.all():
|
||||
if club.partner_club_id and club.partner_domain:
|
||||
domain_map[club.partner_club_id] = club.partner_domain
|
||||
|
||||
updated = success = skip = fail = 0
|
||||
start = time.time()
|
||||
|
||||
def process_one(order):
|
||||
# 获取对方域名
|
||||
domain = domain_map.get(order.partner_club_id)
|
||||
if not domain:
|
||||
try:
|
||||
club = Club.objects.filter(partner_club_id=order.partner_club_id).first()
|
||||
if club and club.partner_domain:
|
||||
domain = club.partner_domain
|
||||
domain_map[order.partner_club_id] = domain
|
||||
except Exception:
|
||||
pass
|
||||
if not domain:
|
||||
return ('skip', '无域名')
|
||||
|
||||
url = domain.rstrip('/') + '/houtai/kptxwztjb'
|
||||
payload = {
|
||||
'token': SYNC_TOKEN,
|
||||
'partner_order_id': order.partner_order_id,
|
||||
'our_order_id': order.dingdan_id,
|
||||
'club_id': order.partner_club_id
|
||||
}
|
||||
|
||||
try:
|
||||
resp = session.post(url, json=payload, timeout=5)
|
||||
if resp.status_code == 200:
|
||||
data = resp.json()
|
||||
if data.get('code') == 0:
|
||||
st = data['data']['status']
|
||||
if st in (5, 8):
|
||||
order.zhuangtai = st
|
||||
order.save(update_fields=['zhuangtai'])
|
||||
return ('updated', st)
|
||||
return ('success', st)
|
||||
else:
|
||||
return ('skip', data.get('msg', '对方业务错误'))
|
||||
else:
|
||||
# 429、404、500 等全部跳过
|
||||
return ('skip', f'HTTP {resp.status_code}')
|
||||
except requests.exceptions.Timeout:
|
||||
return ('skip', '超时')
|
||||
except Exception as e:
|
||||
return ('skip', str(e))
|
||||
|
||||
# 并发执行
|
||||
with ThreadPoolExecutor(max_workers=concurrency) as executor:
|
||||
future_map = {executor.submit(process_one, o): o for o in orders}
|
||||
for future in as_completed(future_map):
|
||||
order = future_map[future]
|
||||
try:
|
||||
res, detail = future.result()
|
||||
if res == 'updated':
|
||||
updated += 1
|
||||
success += 1
|
||||
self.stdout.write(f'✅ 更新: {order.dingdan_id} -> {detail}')
|
||||
elif res == 'success':
|
||||
success += 1
|
||||
else:
|
||||
skip += 1
|
||||
# 跳过的订单静默处理,不打印,以免刷屏
|
||||
except Exception as e:
|
||||
skip += 1
|
||||
|
||||
elapsed = time.time() - start
|
||||
self.stdout.write(self.style.SUCCESS(
|
||||
f'完成: 成功{success}(更新{updated}), 跳过{skip}, 耗时{elapsed:.1f}s'
|
||||
))
|
||||
461
a_long_dianjing/settings.py
Normal file
461
a_long_dianjing/settings.py
Normal file
@@ -0,0 +1,461 @@
|
||||
"""
|
||||
Django settings for a_long_dianjing project.
|
||||
开发环境配置 - 参照旧项目结构精简
|
||||
"""
|
||||
from pathlib import Path
|
||||
from datetime import timedelta
|
||||
import os
|
||||
|
||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
|
||||
# Quick-start development settings - unsuitable for production
|
||||
SECRET_KEY = '' # 开发环境可暂用,生产必须改
|
||||
DEBUG = True # 开发环境为 True
|
||||
ALLOWED_HOSTS = ['localhost', '127.0.0.1'] # 根据开发前端地址可添加
|
||||
|
||||
# Application definition
|
||||
INSTALLED_APPS = [
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
# 第三方应用 (根据 requirements.txt 已安装的)
|
||||
'rest_framework',
|
||||
'rest_framework_simplejwt',
|
||||
'corsheaders',
|
||||
'django_celery_results',
|
||||
# 你的自定义应用 (按已创建的拼音命名)
|
||||
'celery',
|
||||
'yonghu',
|
||||
'dingdan',
|
||||
'shangpin',
|
||||
'peizhi',
|
||||
'houtai',
|
||||
# 'games', # 【待确认】你提到 games 还没创建,暂不添加
|
||||
'utils',
|
||||
'shangdian',
|
||||
'dengji',
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
'corsheaders.middleware.CorsMiddleware', # 跨域中间件放最前
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware', # 默认开启,如API无需可注释
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
# 'guanapi.middleware.OpLogMiddleware', # 【待确认】这是旧项目的自定义中间件,新项目需要吗?
|
||||
]
|
||||
|
||||
ROOT_URLCONF = 'a_long_dianjing.urls'
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [BASE_DIR / 'templates'],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
'django.template.context_processors.request',
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
WSGI_APPLICATION = 'a_long_dianjing.wsgi.application'
|
||||
|
||||
# Database
|
||||
# 根据你提供的信息配置 (本地开发,端口3307)
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.mysql',
|
||||
'NAME': 'a_long_dianjing', # 你创建的数据库名
|
||||
'USER': 'root', # 你的本地MySQL用户名
|
||||
'PASSWORD': 'root', # 你的本地MySQL密码
|
||||
'HOST': 'localhost',
|
||||
'PORT': '3307', # 注意端口是3307
|
||||
'OPTIONS': {
|
||||
'charset': 'utf8mb4',
|
||||
'init_command': "SET time_zone='+08:00'", # 保持与旧项目一致
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Password validation
|
||||
AUTH_PASSWORD_VALIDATORS = [
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
||||
},
|
||||
]
|
||||
|
||||
# Internationalization
|
||||
LANGUAGE_CODE = 'zh-Hans' # 使用中文
|
||||
TIME_ZONE = 'Asia/Shanghai'
|
||||
USE_I18N = True
|
||||
USE_TZ = False # 保持与旧项目一致,不使用UTC时区
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
STATIC_URL = 'static/'
|
||||
# 开发环境静态文件目录,可参照旧项目添加 MEDIA 配置
|
||||
# MEDIA_URL = 'media/'
|
||||
# MEDIA_ROOT = BASE_DIR / 'media'
|
||||
|
||||
# Default primary key field type
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||
|
||||
# ==================== 以下为第三方库及自定义配置 ====================
|
||||
# settings.py
|
||||
# 修改SIMPLE_JWT配置
|
||||
SIMPLE_JWT = {
|
||||
'ACCESS_TOKEN_LIFETIME': timedelta(days=36500),
|
||||
'REFRESH_TOKEN_LIFETIME': timedelta(days=36500),
|
||||
'ROTATE_REFRESH_TOKENS': False,
|
||||
'BLACKLIST_AFTER_ROTATION': False,
|
||||
'UPDATE_LAST_LOGIN': False,
|
||||
'ALGORITHM': 'HS256',
|
||||
'SIGNING_KEY': SECRET_KEY,
|
||||
'VERIFYING_KEY': None,
|
||||
'AUDIENCE': None,
|
||||
'ISSUER': None,
|
||||
'JWK_URL': None,
|
||||
'LEEWAY': 0,
|
||||
'AUTH_HEADER_TYPES': ('Bearer',),
|
||||
'AUTH_HEADER_NAME': 'HTTP_AUTHORIZATION',
|
||||
# 修改这里:使用yonghuid而不是id
|
||||
'USER_ID_FIELD': 'yonghuid',
|
||||
'USER_ID_CLAIM': 'yonghuid',
|
||||
'USER_AUTHENTICATION_RULE': 'rest_framework_simplejwt.authentication.default_user_authentication_rule',
|
||||
'AUTH_TOKEN_CLASSES': ('rest_framework_simplejwt.tokens.AccessToken',),
|
||||
'TOKEN_TYPE_CLAIM': 'token_type',
|
||||
'TOKEN_USER_CLASS': 'rest_framework_simplejwt.models.TokenUser',
|
||||
'JTI_CLAIM': 'jti',
|
||||
}
|
||||
|
||||
# 添加自定义认证后端
|
||||
AUTHENTICATION_BACKENDS = [
|
||||
'django.contrib.auth.backends.ModelBackend',
|
||||
]
|
||||
|
||||
# 必须指定用户模型(即使它不继承AbstractBaseUser)
|
||||
AUTH_USER_MODEL = 'yonghu.UserMain'
|
||||
|
||||
# DRF配置(也非常简单)
|
||||
REST_FRAMEWORK = {
|
||||
'DEFAULT_AUTHENTICATION_CLASSES': (
|
||||
'rest_framework_simplejwt.authentication.JWTAuthentication',
|
||||
),
|
||||
'DEFAULT_PERMISSION_CLASSES': (
|
||||
'rest_framework.permissions.IsAuthenticated',
|
||||
),
|
||||
'DEFAULT_THROTTLE_CLASSES': [
|
||||
'rest_framework.throttling.AnonRateThrottle', # 匿名用户限制
|
||||
'rest_framework.throttling.UserRateThrottle', # 登录用户限制
|
||||
],
|
||||
'DEFAULT_THROTTLE_RATES': {
|
||||
'anon': '100/minute', # 匿名用户每分钟100次
|
||||
'user': '1000/minute', # 登录用户每分钟1000次
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# CORS settings
|
||||
CORS_ALLOWED_ORIGINS = [
|
||||
"http://localhost:8080", # 假设前端开发服务器地址
|
||||
"http://127.0.0.1:8080",
|
||||
"http://localhost:5174",
|
||||
]
|
||||
CORS_ALLOW_CREDENTIALS = True
|
||||
CORS_ALLOW_METHODS = (
|
||||
"GET",
|
||||
"POST",
|
||||
"PUT",
|
||||
"PATCH",
|
||||
"DELETE",
|
||||
"OPTIONS",
|
||||
)
|
||||
CORS_ALLOW_HEADERS = [
|
||||
"accept",
|
||||
"accept-encoding",
|
||||
"authorization",
|
||||
"content-type",
|
||||
"dnt",
|
||||
"origin",
|
||||
"user-agent",
|
||||
"x-csrftoken",
|
||||
"x-requested-with",
|
||||
]
|
||||
|
||||
# 【待确认】自定义用户模型,你需要在 yonghu/models.py 中创建 class Yonghu
|
||||
#AUTH_USER_MODEL = 'yonghu.Yonghu'
|
||||
|
||||
|
||||
# ==================== 跨平台订单互通配置 ====================
|
||||
# 接口认证令牌(双方约定,用于简单验证)
|
||||
CROSS_PLATFORM_TOKEN = 'jdjdjshwjqk'
|
||||
|
||||
# 对方平台接口基础URL(需根据实际部署修改)
|
||||
PARTNER_BASE_URL = 'https://partner.com/api'
|
||||
|
||||
# 对方平台各接口路径(可根据实际情况调整,但双方需保持一致)
|
||||
PARTNER_SYNC_ORDER_URL = '/dingdan/partner_sync_order' # 接收派单
|
||||
PARTNER_CHECK_CLAIM_URL = '/dingdan/partner_check_claim' # 抢单询问
|
||||
PARTNER_NOTIFY_CLAIM_URL = '/dingdan/partner_notify_claim' # 抢单成功通知
|
||||
PARTNER_REFUND_NOTIFY_URL = '/dingdan/partner_refund_notify' # 退款通知
|
||||
|
||||
# 我方代表对方发单的商家ID(需在数据库中存在,且具有商家扩展表)
|
||||
AGENT_SHANGJIA_ID = '9106027'
|
||||
|
||||
# 用于验证的会员ID(根据业务约定)
|
||||
CROSS_PLATFORM_MEMBER_ID = 'vip_2025'
|
||||
|
||||
# 默认游戏类型ID(当对方未传递时使用)
|
||||
CROSS_PLATFORM_GAME_TYPE_ID = 1
|
||||
|
||||
# 允许跨平台的商家ID列表(白名单)
|
||||
CROSS_PLATFORM_WHITELIST = ['5438898']
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# OSS配置
|
||||
|
||||
|
||||
COS_SECRET_ID =''
|
||||
COS_SECRET_KEY =''
|
||||
COS_BUCKET = ''
|
||||
COS_APPID = '' # 你的腾讯云APPID(julebu-1361527063中的数字部分)
|
||||
|
||||
|
||||
COS_REGION = 'ap-shanghai'
|
||||
|
||||
|
||||
COS_SCHEME = 'https' # 使用HTTPS
|
||||
COS_DOMAIN = f'https://{COS_BUCKET}.cos.{COS_REGION}.myqcloud.com'
|
||||
# settings.py - 在COS配置部分添加
|
||||
#COS_APPID = '1361527063' # 你的腾讯云APPID(julebu-1361527063中的数字部分)
|
||||
COS_STS_DURATION = 7200 # STS临时凭证有效期(秒)
|
||||
|
||||
# ==================== 业务相关配置 (值先空着,结构可保留) ====================
|
||||
|
||||
|
||||
|
||||
# 微信虚拟支付配置
|
||||
VP_OFFER_ID = '你的offer_id' # 虚拟支付应用ID
|
||||
VP_APPKEY = '你的现网AppKey' # 正式环境密钥
|
||||
VP_APPKEY_SANDBOX = '你的沙箱AppKey' # 沙箱环境密钥
|
||||
VP_ENV = 1 # 1=沙箱(测试), 0=正式(上线改这里)
|
||||
|
||||
|
||||
# 微信小程序配置 (开发环境可先留空或使用测试号)
|
||||
|
||||
WEIXIN_APPID = '' # 你的小程序APPID
|
||||
WEIXIN_SECRET = ''
|
||||
|
||||
|
||||
|
||||
|
||||
WEIXIN_MCHID = '' # 商户号,支付功能需要
|
||||
|
||||
|
||||
WEIXIN_SHANGHUMIYAO = ''# 商户密钥,支付功能需要
|
||||
# 🆕【新增】服务号配置
|
||||
WEIXIN_OFFICIAL_APPID = '' # 服务号APPID
|
||||
WEIXIN_OFFICIAL_SECRET = '填写你的服务号APPSECRET' # 服务号SECRET
|
||||
WEIXIN_OFFICIAL_TOKEN = '填写你的Token' # 服务号Token
|
||||
WEIXIN_OFFICIAL_ENCODING_AES_KEY = '填写你的EncodingAESKey' # 可选
|
||||
WEIXIN_TEMPLATE_ID = '' # 模板ID
|
||||
|
||||
|
||||
# 罚款缴纳微信支付配置
|
||||
FAKUAN_PAY_DESCRIPTION = '罚款缴纳' # 支付描述
|
||||
FAKUAN_PAY_NOTIFY_URL = 'https://www.abas.asia/hqhd/yonghu/fk_huitiao' # 微信支付回调地址(根据实际域名调整)
|
||||
|
||||
# 🆕【新增】模板消息配置
|
||||
WEIXIN_TEMPLATE_MAX_PER_MINUTE = 950 # 每分钟最大发送量(留50缓冲)
|
||||
WEIXIN_TEMPLATE_BATCH_SIZE = 100 # 每批发送数量
|
||||
|
||||
WEIXIN_NOTIFY_URL = 'http:api' # 支付回调地址,如:http://你的域名/api/pay/callback/
|
||||
# settings.py 或相应配置文件中
|
||||
WEIXIN_PAY_DESCRIPTION = "网络服务" # 支付描述
|
||||
# 押金充值相关配置
|
||||
YAJIN_PAY_DESCRIPTION = "打手押金充值" # 押金支付描述
|
||||
YAJIN_PAY_NOTIFY_URL = "http://你的域名/api/shangpin/yajinhuitiao/" # 押金支付回调地址
|
||||
|
||||
# 积分充值相关配置
|
||||
JIFEN_PAY_DESCRIPTION = "打手积分补充" # 积分支付描述
|
||||
JIFEN_PAY_NOTIFY_URL = "http://你的域名/api/shangpin/jifenhuitiao/" # 积分支付回调地址
|
||||
|
||||
# 会员充值相关配置
|
||||
HUIYUAN_PAY_DESCRIPTION = "打手会员充值" # 会员支付描述
|
||||
HUIYUAN_PAY_NOTIFY_URL = "http://你的域名/api/shangpin/huiyuanhuitiao/" # 会员支付回调地址
|
||||
|
||||
|
||||
# 考核支付配置
|
||||
KAOHE_PAY_DESCRIPTION = '考核金牌-缴纳考核费'
|
||||
KAOHE_PAY_NOTIFY_URL = 'https://您的域名/hqhd/yonghu/kh_huitiao' # 替换为实际回调地址
|
||||
KAOHE_PAY_DEFAULT_FEE = 5.00 # 未配置费用时的默认金额
|
||||
|
||||
|
||||
# settings.py
|
||||
SHANGJIA_CZ_PREFIX = "CzSJ" # 商家充值订单前缀
|
||||
SHANGJIA_CZ_PAY_DESCRIPTION = "阿龙电竞-商家余额充值"
|
||||
SHANGJIA_CZ_PAY_NOTIFY_URL = "https://yourdomain.com/shangpin/sjhuitiao"
|
||||
SHANGJIA_CZ_MIN_AMOUNT = 1
|
||||
SHANGJIA_CZ_MAX_AMOUNT = 10000
|
||||
|
||||
# 订单ID前缀配置
|
||||
ORDER_PREFIX = {
|
||||
'yajin': 'CzYJ', # 押金订单前缀
|
||||
'jifen': 'CzJF', # 积分订单前缀
|
||||
'huiyuan': 'CzHY', # 会员订单前缀
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# 腾讯云即时通讯 (IM) - 开发环境可暂不配置
|
||||
TENCENT_IM_CONFIG = {
|
||||
'SDK_APP_ID': 0, # 整数
|
||||
'SECRET_KEY': '',
|
||||
}
|
||||
|
||||
# 阿里云短信 - 开发环境可暂不配置
|
||||
ALIYUN_SMS_CONFIG = {
|
||||
'ACCESS_KEY_ID': '',
|
||||
'ACCESS_KEY_SECRET': '',
|
||||
'SIGN_NAME': '',
|
||||
'TEMPLATE_CODE': '',
|
||||
'REGION_ID': 'cn-hangzhou',
|
||||
}
|
||||
|
||||
# HashID (用于加密ID,旧项目有,新项目需要吗?)
|
||||
# HASHID_FIELD_SALT = 'a_long_dianjing_2025_salt' # 【待确认】请设置你的盐值
|
||||
|
||||
|
||||
# settings.py 尾部添加
|
||||
# settings.py
|
||||
# settings.py
|
||||
# settings.py 中添加配置
|
||||
GOEASY_APPKEY = '' # 你的AppKey
|
||||
GOEASY_SECRET = '' # 从GoEasy控制台获取
|
||||
GOEASY_REST_URL = 'https://rest-hz.goeasy.io/v2/im/message' # 正式环境
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# settings.py
|
||||
# H5静态页面域名配置
|
||||
H5_DOMAIN = 'https://h5.yourdomain.com' # 生产环境
|
||||
# H5_DOMAIN = 'https://test-h5.yourdomain.com' # 测试环境
|
||||
|
||||
|
||||
|
||||
|
||||
# 特殊管事ID列表(yonghuid),这些管事的首次分红金额从 UserGuanshi.fenhong_yici 字段获取
|
||||
SPECIAL_GUANSHI_IDS = [
|
||||
'1000001',
|
||||
'1000002',
|
||||
# ... 按需添加
|
||||
]
|
||||
|
||||
# ========== 管理员批量链接白名单 ==========
|
||||
ADMIN_BATCH_LINK_ALLOWED_PHONES = [
|
||||
'13800138000',
|
||||
'13912345678',
|
||||
]
|
||||
|
||||
BATCH_LINK_DEFAULT_COUNT = 100
|
||||
BATCH_LINK_MAX_COUNT = 200
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# settings.py
|
||||
|
||||
# settings.py
|
||||
WECHAT_PAY_V3_CONFIG = {
|
||||
'MCHID': '', # 商户号
|
||||
'APPID': '', # 小程序APPID
|
||||
'API_V3_KEY': '', # APIv3密钥(32字节)
|
||||
'PRIVATE_KEY_PATH': '/opt/1panel/apps/openresty/openresty/www/sites/119.28.221.247.1199/huizhifuzhengshu/apiclient_key.pem', # 商户私钥文件路径
|
||||
'CERT_SERIAL_NO': '', # 商户证书序列号
|
||||
'PLATFORM_CERT_DIR': '/opt/1panel/apps/openresty/openresty/www/sites/119.28.221.247.1199/huizhifuzhengshu/pub_key.pem', # 存放微信平台证书公钥的目录(文件名:序列号.pem)
|
||||
'NOTIFY_URL': 'https://ios808.top/hqhd/yonghu/tixiancallback', # 回调地址
|
||||
'TRANSFER_SCENE_ID': '', # 替换为你的实际场景ID
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
CROSS_PLATFORM_SYNC_TOKEN = 'xK9mP2vL8qW5rT7y'
|
||||
|
||||
# 提现收款链路日志(输出到 stderr,gunicorn/1panel 可抓取)
|
||||
LOGGING = {
|
||||
'version': 1,
|
||||
'disable_existing_loggers': False,
|
||||
'handlers': {
|
||||
'tixian_shenhe_console': {
|
||||
'class': 'logging.StreamHandler',
|
||||
'formatter': 'verbose',
|
||||
},
|
||||
},
|
||||
'formatters': {
|
||||
'verbose': {
|
||||
'format': '[{asctime}] {levelname} {name} {message}',
|
||||
'style': '{',
|
||||
},
|
||||
},
|
||||
'loggers': {
|
||||
'yonghu.tixian_shenhe': {
|
||||
'handlers': ['tixian_shenhe_console'],
|
||||
'level': 'INFO',
|
||||
'propagate': False,
|
||||
},
|
||||
},
|
||||
}
|
||||
60
a_long_dianjing/urls.py
Normal file
60
a_long_dianjing/urls.py
Normal file
@@ -0,0 +1,60 @@
|
||||
"""
|
||||
URL configuration for a_long_dianjing project.
|
||||
|
||||
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||
https://docs.djangoproject.com/en/6.0/topics/http/urls/
|
||||
Examples:
|
||||
Function views
|
||||
1. Add an import: from my_app import views
|
||||
2. Add a URL to urlpatterns: path('', views.home, name='home')
|
||||
Class-based views
|
||||
1. Add an import: from other_app.views import Home
|
||||
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
||||
Including another URLconf
|
||||
1. Import the include() function: from django.urls import include, path
|
||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||
"""
|
||||
'''from django.contrib import admin
|
||||
from django.urls import path
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
]'''
|
||||
|
||||
# a_long_dianjing/urls.py
|
||||
"""
|
||||
项目根路由配置 - 按照生产环境格式,连接所有APP路由
|
||||
注意:本项目使用MinIO模拟OSS,文件上传不经过Django MEDIA_URL,所以不需要static(settings.MEDIA_URL)配置
|
||||
"""
|
||||
|
||||
from django.contrib import admin
|
||||
from django.urls import path, include
|
||||
|
||||
urlpatterns = [
|
||||
# Django管理后台
|
||||
path('admin/', admin.site.urls),
|
||||
|
||||
# 用户相关路由
|
||||
path('yonghu/', include('yonghu.urls')),
|
||||
|
||||
# 订单相关路由
|
||||
path('dingdan/', include('dingdan.urls')),
|
||||
|
||||
# 商品/陪玩服务相关路由
|
||||
path('shangpin/', include('shangpin.urls')),
|
||||
|
||||
|
||||
# 配置相关路由(系统配置)
|
||||
path('peizhi/', include('peizhi.urls')),
|
||||
|
||||
path('houtai/', include('houtai.urls')),
|
||||
path('shangdian/', include('shangdian.urls')),
|
||||
path('dengji/', include('dengji.urls')),
|
||||
|
||||
]
|
||||
|
||||
# 重要说明:
|
||||
# 1. 本项目使用MinIO(模拟OSS)作为对象存储,文件上传通过MinIO的S3接口直接处理
|
||||
# 2. 文件存储不经过Django的MEDIA_URL,所以不需要配置 static(settings.MEDIA_URL, ...)
|
||||
# 3. 未来迁移到腾讯云COS/阿里云OSS时,也通过django-storages直接处理,不经过Django静态文件服务
|
||||
# 4. 所有文件访问将通过MinIO/COS的CDN域名直接访问,不需要Django路由转发
|
||||
16
a_long_dianjing/wsgi.py
Normal file
16
a_long_dianjing/wsgi.py
Normal file
@@ -0,0 +1,16 @@
|
||||
"""
|
||||
WSGI config for a_long_dianjing project.
|
||||
|
||||
It exposes the WSGI callable as a module-level variable named ``application``.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/6.0/howto/deployment/wsgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'a_long_dianjing.settings')
|
||||
|
||||
application = get_wsgi_application()
|
||||
Reference in New Issue
Block a user