试点修复了 config 模型的拼音字段
This commit is contained in:
@@ -415,14 +415,14 @@ def _get_personal_daily_quota(leixing, profile):
|
||||
if leixing == 1:
|
||||
if profile.kaioi_ewai_xiane and profile.ewai_xiane > 0:
|
||||
return profile.ewai_xiane
|
||||
return TixianQuotaDefault.query.get(leixing=1).default_quota
|
||||
return TixianQuotaDefault.query.get(UserType=1).default_quota
|
||||
if leixing == 2:
|
||||
if profile.kaioi_ewai_xiane and profile.ewai_xiane > 0:
|
||||
return profile.ewai_xiane
|
||||
return TixianQuotaDefault.query.get(leixing=2).default_quota
|
||||
return TixianQuotaDefault.query.get(UserType=2).default_quota
|
||||
if leixing == 3:
|
||||
try:
|
||||
default_quota = TixianQuotaDefault.query.get(leixing=3).default_quota
|
||||
default_quota = TixianQuotaDefault.query.get(UserType=3).default_quota
|
||||
except TixianQuotaDefault.DoesNotExist:
|
||||
default_quota = decimal.Decimal('0.00')
|
||||
if profile.kaioi_ewai_tixian and profile.ewai_tixian_xiane > 0:
|
||||
@@ -482,7 +482,7 @@ def _get_platform_daily_limit(leixing):
|
||||
"""
|
||||
quota_leixing = leixing + 3
|
||||
try:
|
||||
return TixianQuotaDefault.query.get(leixing=quota_leixing).default_quota
|
||||
return TixianQuotaDefault.query.get(UserType=quota_leixing).default_quota
|
||||
except TixianQuotaDefault.DoesNotExist:
|
||||
logger.warning(
|
||||
'平台每日总限额未配置 leixing=%s(读取quota_leixing=%s),按0处理禁止新增收款',
|
||||
@@ -1034,16 +1034,16 @@ def _apply_platform_accounting(auto_record):
|
||||
update_daily_payout(auto_record.shijidaozhang)
|
||||
try:
|
||||
szjilu = Szjilu.objects.select_for_update().get(id=1)
|
||||
szjilu.zongsy -= auto_record.shijidaozhang
|
||||
szjilu.zongzc += auto_record.shijidaozhang
|
||||
szjilu.jrzc += auto_record.shijidaozhang
|
||||
szjilu.TotalIncome -= auto_record.shijidaozhang
|
||||
szjilu.TotalExpense += auto_record.shijidaozhang
|
||||
szjilu.DailyExpense += auto_record.shijidaozhang
|
||||
szjilu.save()
|
||||
except Szjilu.DoesNotExist:
|
||||
Szjilu.query.create(
|
||||
id=1,
|
||||
zongsy=-auto_record.shijidaozhang,
|
||||
zongzc=auto_record.shijidaozhang,
|
||||
jrzc=auto_record.shijidaozhang,
|
||||
TotalIncome=-auto_record.shijidaozhang,
|
||||
TotalExpense=auto_record.shijidaozhang,
|
||||
DailyExpense=auto_record.shijidaozhang,
|
||||
)
|
||||
|
||||
|
||||
|
||||
104
users/views.py
104
users/views.py
@@ -413,11 +413,11 @@ class WechatMiniProgramLoginView(APIView):
|
||||
|
||||
for config in qun_configs:
|
||||
if config.id == 1:
|
||||
result['dashouqun'] = config.neirong or ''
|
||||
result['dashouqunid'] = config.qunid or ''
|
||||
result['dashouqun'] = config.GroupContent or ''
|
||||
result['dashouqunid'] = config.GroupID or ''
|
||||
elif config.id == 2:
|
||||
result['guanshiqun'] = config.neirong or ''
|
||||
result['guanshiqunid'] = config.qunid or ''
|
||||
result['guanshiqun'] = config.GroupContent or ''
|
||||
result['guanshiqunid'] = config.GroupID or ''
|
||||
|
||||
return result
|
||||
|
||||
@@ -2489,22 +2489,22 @@ class AdminFinancialDataView(APIView):
|
||||
# 方法2:如果表中可能有多条记录,需要汇总,可以使用以下方式:
|
||||
# from django.db.models Sum
|
||||
# zonghe = Szjilu.query.aggregate(
|
||||
# zongliushui=Sum('zongls'),
|
||||
# zongshouyi=Sum('zongsy'),
|
||||
# zongzhichu=Sum('zongzc'),
|
||||
# jrls=Sum('jrls'),
|
||||
# jrzc=Sum('jrzc')
|
||||
# zongliushui=Sum('TotalFlow'),
|
||||
# zongshouyi=Sum('TotalIncome'),
|
||||
# zongzhichu=Sum('TotalExpense'),
|
||||
# DailyFlow=Sum('DailyFlow'),
|
||||
# DailyExpense=Sum('DailyExpense')
|
||||
# )
|
||||
|
||||
# 准备返回数据
|
||||
if shouzhijilu:
|
||||
# 有记录的情况
|
||||
huizongshuju = {
|
||||
'zongliushui': float(shouzhijilu.zongls or 0),
|
||||
'zongshouyi': float(shouzhijilu.zongsy or 0),
|
||||
'zongzhichu': float(shouzhijilu.zongzc or 0),
|
||||
'jrls': float(shouzhijilu.jrls or 0),
|
||||
'jrzc': float(shouzhijilu.jrzc or 0)
|
||||
'zongliushui': float(shouzhijilu.TotalFlow or 0),
|
||||
'zongshouyi': float(shouzhijilu.TotalIncome or 0),
|
||||
'zongzhichu': float(shouzhijilu.TotalExpense or 0),
|
||||
'jrls': float(shouzhijilu.DailyFlow or 0),
|
||||
'jrzc': float(shouzhijilu.DailyExpense or 0)
|
||||
}
|
||||
else:
|
||||
# 没有记录的情况,返回默认值
|
||||
@@ -4643,9 +4643,9 @@ class AdtixianqkView(APIView):
|
||||
update_daily_payout(tixian_jine)
|
||||
|
||||
# 更新收支记录
|
||||
szjilu_record.zongsy -= tixian_jine # 总收益减去提现金额
|
||||
szjilu_record.zongzc += tixian_jine # 总支出加上提现金额
|
||||
szjilu_record.jrzc += tixian_jine # 今日支出加上提现金额
|
||||
szjilu_record.TotalIncome -= tixian_jine # 总收益减去提现金额
|
||||
szjilu_record.TotalExpense += tixian_jine # 总支出加上提现金额
|
||||
szjilu_record.DailyExpense += tixian_jine # 今日支出加上提现金额
|
||||
szjilu_record.update_time = timezone.now()
|
||||
szjilu_record.save()
|
||||
|
||||
@@ -4653,9 +4653,9 @@ class AdtixianqkView(APIView):
|
||||
# 如果收支记录表不存在id=1的记录,创建一个
|
||||
szjilu_record = Szjilu.query.create(
|
||||
id=1,
|
||||
zongsy=-tixian_jine if result == 2 else 0,
|
||||
zongzc=tixian_jine if result == 2 else 0,
|
||||
jrzc=tixian_jine if result == 2 else 0
|
||||
TotalIncome=-tixian_jine if result == 2 else 0,
|
||||
TotalExpense=tixian_jine if result == 2 else 0,
|
||||
DailyExpense=tixian_jine if result == 2 else 0
|
||||
)
|
||||
except Exception as e:
|
||||
# 如果更新收支记录失败,抛出异常,事务会回滚
|
||||
@@ -5506,11 +5506,11 @@ class WechatLoginAndDashouRegisterView(APIView):
|
||||
|
||||
for config in qun_configs:
|
||||
if config.id == 1:
|
||||
result['dashouqun'] = config.neirong or ''
|
||||
result['dashouqunid'] = config.qunid or ''
|
||||
result['dashouqun'] = config.GroupContent or ''
|
||||
result['dashouqunid'] = config.GroupID or ''
|
||||
elif config.id == 2:
|
||||
result['guanshiqun'] = config.neirong or ''
|
||||
result['guanshiqunid'] = config.qunid or ''
|
||||
result['guanshiqun'] = config.GroupContent or ''
|
||||
result['guanshiqunid'] = config.GroupID or ''
|
||||
|
||||
return result
|
||||
|
||||
@@ -10098,9 +10098,9 @@ class KefuWithdrawActionView(APIView):
|
||||
try:
|
||||
update_daily_payout(tixian.jine)
|
||||
szjilu, _ = Szjilu.query.get_or_create(id=1)
|
||||
szjilu.zongsy -= tixian.jine
|
||||
szjilu.zongzc += tixian.jine
|
||||
szjilu.jrzc += tixian.jine
|
||||
szjilu.TotalIncome -= tixian.jine
|
||||
szjilu.TotalExpense += tixian.jine
|
||||
szjilu.DailyExpense += tixian.jine
|
||||
szjilu.update_time = timezone.now()
|
||||
szjilu.save()
|
||||
except Exception as e:
|
||||
@@ -10663,11 +10663,11 @@ class WechatLoginAndGuanshiRegisterView(APIView):
|
||||
}
|
||||
for config in qun_configs:
|
||||
if config.id == 1:
|
||||
result['dashouqun'] = config.neirong or ''
|
||||
result['dashouqunid'] = config.qunid or ''
|
||||
result['dashouqun'] = config.GroupContent or ''
|
||||
result['dashouqunid'] = config.GroupID or ''
|
||||
elif config.id == 2:
|
||||
result['guanshiqun'] = config.neirong or ''
|
||||
result['guanshiqunid'] = config.qunid or ''
|
||||
result['guanshiqun'] = config.GroupContent or ''
|
||||
result['guanshiqunid'] = config.GroupID or ''
|
||||
return result
|
||||
except Exception as e:
|
||||
logger.error(f"获取群配置失败: {e}")
|
||||
@@ -10890,11 +10890,11 @@ class GuanshiRegisterView(APIView):
|
||||
}
|
||||
for config in qun_configs:
|
||||
if config.id == 1:
|
||||
result['dashouqun'] = config.neirong or ''
|
||||
result['dashouqunid'] = config.qunid or ''
|
||||
result['dashouqun'] = config.GroupContent or ''
|
||||
result['dashouqunid'] = config.GroupID or ''
|
||||
elif config.id == 2:
|
||||
result['guanshiqun'] = config.neirong or ''
|
||||
result['guanshiqunid'] = config.qunid or ''
|
||||
result['guanshiqun'] = config.GroupContent or ''
|
||||
result['guanshiqunid'] = config.GroupID or ''
|
||||
return result
|
||||
except Exception as e:
|
||||
logger.error(f"获取群配置失败: {e}")
|
||||
@@ -11834,18 +11834,18 @@ class FaKuanHuitiaoView(View):
|
||||
szjilu, created = Szjilu.query.get_or_create(
|
||||
id=1,
|
||||
defaults={
|
||||
'zongsy': Decimal('0.00'),
|
||||
'zongls': Decimal('0.00'),
|
||||
'zongzc': Decimal('0.00'),
|
||||
'jrzc': Decimal('0.00'),
|
||||
'jrls': Decimal('0.00')
|
||||
'TotalIncome': Decimal('0.00'),
|
||||
'TotalFlow': Decimal('0.00'),
|
||||
'TotalExpense': Decimal('0.00'),
|
||||
'DailyExpense': Decimal('0.00'),
|
||||
'DailyFlow': Decimal('0.00')
|
||||
}
|
||||
)
|
||||
|
||||
# 更新三个字段
|
||||
szjilu.zongsy += jine_decimal # 总收益
|
||||
szjilu.zongls += jine_decimal # 总流水
|
||||
szjilu.jrls += jine_decimal # 今日流水
|
||||
szjilu.TotalIncome += jine_decimal # 总收益
|
||||
szjilu.TotalFlow += jine_decimal # 总流水
|
||||
szjilu.DailyFlow += jine_decimal # 今日流水
|
||||
|
||||
szjilu.save()
|
||||
|
||||
@@ -12403,18 +12403,18 @@ class KaohePayCallbackView(View):
|
||||
szjilu, created = Szjilu.query.get_or_create(
|
||||
id=1,
|
||||
defaults={
|
||||
'zongsy': Decimal('0.00'),
|
||||
'zongls': Decimal('0.00'),
|
||||
'zongzc': Decimal('0.00'),
|
||||
'jrzc': Decimal('0.00'),
|
||||
'jrls': Decimal('0.00'),
|
||||
'TotalIncome': Decimal('0.00'),
|
||||
'TotalFlow': Decimal('0.00'),
|
||||
'TotalExpense': Decimal('0.00'),
|
||||
'DailyExpense': Decimal('0.00'),
|
||||
'DailyFlow': Decimal('0.00'),
|
||||
}
|
||||
)
|
||||
szjilu.zongsy += jine_decimal
|
||||
szjilu.zongls += jine_decimal
|
||||
szjilu.jrls += jine_decimal
|
||||
szjilu.TotalIncome += jine_decimal
|
||||
szjilu.TotalFlow += jine_decimal
|
||||
szjilu.DailyFlow += jine_decimal
|
||||
szjilu.save()
|
||||
logger.info(f"更新收支记录成功: zongsy={szjilu.zongsy}")
|
||||
logger.info(f"更新收支记录成功: zongsy={szjilu.TotalIncome}")
|
||||
except Exception as e:
|
||||
logger.error(f"更新收支记录失败: {str(e)}", exc_info=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user