排行榜按收益/流水排序;小程序配置与页面资源入库可后台管理

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
XingQue
2026-06-27 01:04:04 +08:00
parent ceaca8bf4d
commit 2c4ad6e13a
15 changed files with 718 additions and 111 deletions

View File

@@ -1,10 +1,11 @@
# yonghu/views.py
# yonghu/views.py
import time
import random
import hashlib
import requests
from django.db import transaction, IntegrityError
from django.conf import settings
from utils.xcx_sys_config import wx_cfg
from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework import status
@@ -23,6 +24,7 @@ from rest_framework.permissions import AllowAny # 新增这行
from django.conf import settings
from utils.xcx_sys_config import wx_cfg
from django.utils import timezone
from django.db import transaction, IntegrityError
from django.core.exceptions import ObjectDoesNotExist
@@ -255,8 +257,8 @@ class WechatMiniProgramLoginView(APIView):
调用微信接口获取openid和unionid
"""
try:
appid = getattr(settings, 'WEIXIN_APPID', '')
secret = getattr(settings, 'WEIXIN_SECRET', '')
appid = wx_cfg.WEIXIN_APPID
secret = wx_cfg.WEIXIN_SECRET
if not appid or not secret:
raise ValueError('微信配置未设置')
@@ -386,6 +388,7 @@ from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework import status
from django.conf import settings
from utils.xcx_sys_config import wx_cfg
from .models import OfficialAccountUser
logger = logging.getLogger(__name__)
@@ -410,7 +413,7 @@ class WeixinOfficialCallbackView(APIView):
nonce = request.GET.get('nonce', '')
echostr = request.GET.get('echostr', '')
token = getattr(settings, 'WEIXIN_OFFICIAL_TOKEN', '')
token = wx_cfg.WEIXIN_OFFICIAL_TOKEN
if not token:
logger.error("服务号Token未配置")
@@ -755,8 +758,8 @@ class UserInfoUpdateView(APIView):
return token
# 从 settings 读取 AppID 和 AppSecret
appid = getattr(settings, 'WEIXIN_APPID', None)
secret = getattr(settings, 'WEIXIN_SECRET', None)
appid = wx_cfg.WEIXIN_APPID or None
secret = wx_cfg.WEIXIN_SECRET or None
if not appid or not secret:
raise ValueError(
'settings.py 中缺少 WECHAT_APPID 或 WECHAT_APPSECRET'
@@ -4684,6 +4687,7 @@ class AdcjxgView(APIView):
# 🔒 判断当前管理员是否有增加权限
from django.conf import settings
from utils.xcx_sys_config import wx_cfg
allow_increase = zhanghao in getattr(settings, 'ALLOW_INCREASE_ADMINS', [])
if user_type == 1: # 老板 - 不允许修改
@@ -6728,8 +6732,8 @@ class WechatLoginAndDashouRegisterView(APIView):
调用微信接口获取openid
"""
try:
appid = getattr(settings, 'WEIXIN_APPID', '')
secret = getattr(settings, 'WEIXIN_SECRET', '')
appid = wx_cfg.WEIXIN_APPID
secret = wx_cfg.WEIXIN_SECRET
if not appid or not secret:
raise ValueError('微信配置未设置')
@@ -9080,6 +9084,7 @@ import time
from decimal import Decimal
from django.db import transaction, IntegrityError
from django.conf import settings
from utils.xcx_sys_config import wx_cfg
from django.core.exceptions import ObjectDoesNotExist
from rest_framework.views import APIView
from rest_framework.response import Response
@@ -9386,8 +9391,8 @@ class KefuPlatformRefundView(APIView):
"https://api.weixin.qq.com/cgi-bin/token",
params={
"grant_type": "client_credential",
"appid": settings.WEIXIN_APPID,
"secret": settings.WEIXIN_SECRET,
"appid": wx_cfg.WEIXIN_APPID,
"secret": wx_cfg.WEIXIN_SECRET,
},
timeout=10,
)
@@ -9551,11 +9556,11 @@ class KefuPlatformRefundView(APIView):
:return: {'code': 0, 'msg': '成功', 'refund_id': 'xxx'} 或 {'code': 非0, 'msg': '错误信息'}
"""
# 获取配置
appid = getattr(settings, 'WEIXIN_APPID', '')
mch_id = getattr(settings, 'WEIXIN_MCHID', '')
key = getattr(settings, 'WEIXIN_SHANGHUMIYAO', '')
cert_path = getattr(settings, 'WEIXIN_CERT_PATH', '')
key_path = getattr(settings, 'WEIXIN_KEY_PATH', '')
appid = wx_cfg.WEIXIN_APPID
mch_id = wx_cfg.WEIXIN_MCHID
key = wx_cfg.WEIXIN_SHANGHUMIYAO
cert_path = wx_cfg.WEIXIN_CERT_PATH
key_path = wx_cfg.WEIXIN_KEY_PATH
if not all([appid, mch_id, key, cert_path, key_path]):
missing = [k for k, v in {'appid': appid, 'mch_id': mch_id, 'key': key, 'cert_path': cert_path, 'key_path': key_path}.items() if not v]
@@ -12651,6 +12656,7 @@ from datetime import date
import requests
from django.db import transaction, IntegrityError
from django.conf import settings
from utils.xcx_sys_config import wx_cfg
from rest_framework.views import APIView
from rest_framework import permissions, status
from rest_framework.response import Response
@@ -12679,6 +12685,7 @@ import logging
import requests
from django.db import transaction, IntegrityError
from django.conf import settings
from utils.xcx_sys_config import wx_cfg
from django.core.cache import cache
from django.utils import timezone
from rest_framework.views import APIView
@@ -12710,6 +12717,7 @@ import logging
import requests
from django.db import transaction, IntegrityError
from django.conf import settings
from utils.xcx_sys_config import wx_cfg
from django.core.cache import cache
from django.utils import timezone
from rest_framework.views import APIView
@@ -13605,8 +13613,8 @@ class WechatLoginAndGuanshiRegisterView(APIView):
def _get_wechat_openid(self, code):
try:
appid = getattr(settings, 'WEIXIN_APPID', '')
secret = getattr(settings, 'WEIXIN_SECRET', '')
appid = wx_cfg.WEIXIN_APPID
secret = wx_cfg.WEIXIN_SECRET
if not appid or not secret:
raise ValueError('微信配置未设置')
url = 'https://api.weixin.qq.com/sns/jscode2session'
@@ -14665,9 +14673,9 @@ class FaKuanPayView(APIView):
}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def generate_wechat_pay_params(self, dingdanid, jine, openid, pay_type):
APPID = settings.WEIXIN_APPID
MCHID = settings.WEIXIN_MCHID
KEY = settings.WEIXIN_SHANGHUMIYAO
APPID = wx_cfg.WEIXIN_APPID
MCHID = wx_cfg.WEIXIN_MCHID
KEY = wx_cfg.WEIXIN_SHANGHUMIYAO
if pay_type == 'fakuan':
PAY_DESCRIPTION = settings.FAKUAN_PAY_DESCRIPTION
@@ -14927,7 +14935,7 @@ class FaKuanHuitiaoView(View):
# 拼接字符串
sign_string = '&'.join([f"{key}={value}" for key, value in sorted_params if value])
sign_string += f'&key={settings.WEIXIN_SHANGHUMIYAO}'
sign_string += f'&key={wx_cfg.WEIXIN_SHANGHUMIYAO}'
# 计算签名
calculated_sign = hashlib.md5(sign_string.encode('utf-8')).hexdigest().upper()
@@ -15188,9 +15196,9 @@ class KaohePayView(APIView):
def generate_wechat_pay_params(self, dingdanid, jine, openid, attach, pay_type):
"""生成微信JSAPI支付参数"""
APPID = settings.WEIXIN_APPID
MCHID = settings.WEIXIN_MCHID
KEY = settings.WEIXIN_SHANGHUMIYAO
APPID = wx_cfg.WEIXIN_APPID
MCHID = wx_cfg.WEIXIN_MCHID
KEY = wx_cfg.WEIXIN_SHANGHUMIYAO
if pay_type == 'kaohe':
PAY_DESCRIPTION = settings.KAOHE_PAY_DESCRIPTION
@@ -15508,7 +15516,7 @@ class KaohePayCallbackView(View):
sorted_params = sorted(params.items(), key=lambda x: x[0])
sign_string = '&'.join([f"{key}={value}" for key, value in sorted_params if value])
sign_string += f'&key={settings.WEIXIN_SHANGHUMIYAO}'
sign_string += f'&key={wx_cfg.WEIXIN_SHANGHUMIYAO}'
calculated_sign = hashlib.md5(sign_string.encode('utf-8')).hexdigest().upper()
result = sign == calculated_sign