加入了 GVSDSDK 模块,进行了 QModel 兼容层的尝试,生产环境可用
This commit is contained in:
@@ -13,6 +13,8 @@ from django.db.models import F
|
||||
from datetime import date
|
||||
from decimal import Decimal
|
||||
|
||||
from gvsdsdk.fluent import db, func, FQ
|
||||
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -39,7 +41,7 @@ def _record_abnormal(account_id, request, attempt_type, detail=''):
|
||||
request_params = json.dumps(request.query_params.dict(), ensure_ascii=False) if request.query_params else ''
|
||||
request_body = request.body.decode('utf-8', errors='ignore')[:5000]
|
||||
|
||||
AbnormalUserLog.objects.create(
|
||||
AbnormalUserLog.query.create(
|
||||
account_id=account_id,
|
||||
ip_address=real_ip,
|
||||
real_ip=real_ip,
|
||||
@@ -96,9 +98,9 @@ def verify_kefu_permission(request, username_from_frontend=None):
|
||||
|
||||
# ---------- 4. 获取用户的所有权限(通过角色) ----------
|
||||
# 步骤1:获取用户的所有角色ID
|
||||
role_ids = UserRole.objects.filter(account_id=current_user.phone).values_list('role_id', flat=True)
|
||||
role_ids = UserRole.query.filter(account_id=current_user.phone).values_list('role_id', flat=True)
|
||||
# 步骤2:通过角色ID获取权限编码
|
||||
permissions = list(Permission.objects.filter(
|
||||
permissions = list(Permission.query.filter(
|
||||
rolepermission__role_id__in=role_ids
|
||||
).values_list('perm_code', flat=True).distinct())
|
||||
|
||||
@@ -156,7 +158,7 @@ def update_dashou_daily_by_action(yonghuid, amount, action):
|
||||
return # 无效行为
|
||||
|
||||
if update_fields:
|
||||
DashouRiTongji.objects.filter(id=stat.id).update(**update_fields)
|
||||
DashouRiTongji.query.filter(id=stat.id).update(**update_fields)
|
||||
|
||||
|
||||
def update_shangjia_daily(yonghuid, amount, action):
|
||||
@@ -212,7 +214,7 @@ def update_shangjia_daily(yonghuid, amount, action):
|
||||
return
|
||||
|
||||
# 执行原子更新
|
||||
ShangjiaRiTongji.objects.filter(id=stat.id).update(**update_fields)
|
||||
ShangjiaRiTongji.query.filter(id=stat.id).update(**update_fields)
|
||||
|
||||
|
||||
|
||||
@@ -242,7 +244,7 @@ def update_guanshi_daily_by_action(yonghuid, action, amount=Decimal('0.00')):
|
||||
stat.yaoqing_dashou_shu = 1
|
||||
stat.save()
|
||||
else:
|
||||
GuanshiRiTongji.objects.filter(id=stat.id).update(
|
||||
GuanshiRiTongji.query.filter(id=stat.id).update(
|
||||
yaoqing_dashou_shu=F('yaoqing_dashou_shu') + 1
|
||||
)
|
||||
|
||||
@@ -255,7 +257,7 @@ def update_guanshi_daily_by_action(yonghuid, action, amount=Decimal('0.00')):
|
||||
stat.shouru_zonge = amount
|
||||
stat.save()
|
||||
else:
|
||||
GuanshiRiTongji.objects.filter(id=stat.id).update(
|
||||
GuanshiRiTongji.query.filter(id=stat.id).update(
|
||||
chongzhi_dashou_shu=F('chongzhi_dashou_shu') + 1,
|
||||
shouru_zonge=F('shouru_zonge') + amount
|
||||
)
|
||||
@@ -268,7 +270,7 @@ def update_guanshi_daily_by_action(yonghuid, action, amount=Decimal('0.00')):
|
||||
stat.shouru_zonge = amount
|
||||
stat.save()
|
||||
else:
|
||||
GuanshiRiTongji.objects.filter(id=stat.id).update(
|
||||
GuanshiRiTongji.query.filter(id=stat.id).update(
|
||||
shouru_zonge=F('shouru_zonge') + amount
|
||||
)
|
||||
|
||||
@@ -328,7 +330,7 @@ def update_guanshi_daily_by_action(yonghuid, action, amount=Decimal('0.00')):
|
||||
if action == 2:
|
||||
update_fields['shouru_zonge'] = F('shouru_zonge') + amount
|
||||
|
||||
GuanshiRiTongji.objects.filter(id=stat.id).update(**update_fields)'''
|
||||
GuanshiRiTongji.query.filter(id=stat.id).update(**update_fields)'''
|
||||
|
||||
def update_guanshi_xufei_daily(yonghuid, xufei_jine=Decimal('0.00')):
|
||||
"""
|
||||
@@ -348,7 +350,7 @@ def update_guanshi_xufei_daily(yonghuid, xufei_jine=Decimal('0.00')):
|
||||
}
|
||||
)
|
||||
if not created:
|
||||
GuanshiXufeiRiTongji.objects.filter(id=stat.id).update(
|
||||
GuanshiXufeiRiTongji.query.filter(id=stat.id).update(
|
||||
xufei_zongshu=F('xufei_zongshu') + 1,
|
||||
xufei_shouyi=F('xufei_shouyi') + xufei_jine
|
||||
)
|
||||
@@ -392,13 +394,13 @@ def update_zuzhang_daily_by_action(yonghuid, action, amount=Decimal('0.00')):
|
||||
else:
|
||||
# 已存在记录,使用 F 表达式原子累加
|
||||
if action == 1:
|
||||
ZuzhangRiTongji.objects.filter(id=stat.id).update(
|
||||
ZuzhangRiTongji.query.filter(id=stat.id).update(
|
||||
yaoqing_guanshi_shu=F('yaoqing_guanshi_shu') + 1
|
||||
)
|
||||
elif action == 2:
|
||||
amount = Decimal(str(amount)) if amount else Decimal('0.00')
|
||||
if amount > 0:
|
||||
ZuzhangRiTongji.objects.filter(id=stat.id).update(
|
||||
ZuzhangRiTongji.query.filter(id=stat.id).update(
|
||||
shouru_zonge=F('shouru_zonge') + amount,
|
||||
fenyong_jine=F('fenyong_jine') + amount
|
||||
)
|
||||
@@ -419,7 +421,7 @@ def update_tixian_daily_stat(leixing, amount):
|
||||
defaults={'total_amount': amount}
|
||||
)
|
||||
if not created:
|
||||
TixianRiTongji.objects.filter(id=stat.id).update(
|
||||
TixianRiTongji.query.filter(id=stat.id).update(
|
||||
total_amount=F('total_amount') + amount
|
||||
)
|
||||
|
||||
@@ -461,7 +463,7 @@ def _get_fadan_permission_config():
|
||||
perm_map = dict(_DEFAULT_FADAN_PERM_TO_SHENFEN)
|
||||
generic_codes = list(_FADAN_GENERIC_PERMS)
|
||||
try:
|
||||
rows = Permission.objects.filter(
|
||||
rows = Permission.query.filter(
|
||||
Q(perm_name__icontains='罚款') | Q(perm_name__icontains='罚单')
|
||||
).values('perm_code', 'perm_name')
|
||||
for row in rows:
|
||||
|
||||
Reference in New Issue
Block a user