fix: 冻结条件可评估+分期规范化,定时扫描更及时
后台条件真正按罚款率/单量等评估;选项式配置所需字段规范化;Celery 改为每5分钟;小程序说明文案接口补齐。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -13,7 +13,7 @@ from rest_framework.permissions import IsAuthenticated
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.views import APIView
|
||||
|
||||
from jituan.models import FundFreezeLedger, FundUnfreezeEvent
|
||||
from jituan.models import ClubFundFreezeConfig, FundFreezeLedger, FundUnfreezeEvent
|
||||
from jituan.services.club_user import get_user_club_id
|
||||
from jituan.services.fund_freeze import (
|
||||
ROLE_DASHOU,
|
||||
@@ -109,6 +109,19 @@ class FundFreezeMineView(APIView):
|
||||
]
|
||||
total_dongjie = sum((Decimal(r['dongjie_yue']) for r in roles), Decimal('0.00'))
|
||||
total_withdrawable = sum((Decimal(r['withdrawable']) for r in roles), Decimal('0.00'))
|
||||
|
||||
# 用户可见说明:优先打手规则,否则取任意已配置角色
|
||||
display_reason = ''
|
||||
if club_id:
|
||||
cfgs = list(ClubFundFreezeConfig.query.filter(club_id=club_id, enabled=True))
|
||||
prefer = next((c for c in cfgs if c.role == ROLE_DASHOU), None) or (cfgs[0] if cfgs else None)
|
||||
if prefer and prefer.remark:
|
||||
display_reason = prefer.remark
|
||||
if not display_reason:
|
||||
any_cfg = ClubFundFreezeConfig.query.filter(club_id=club_id).exclude(remark='').first()
|
||||
if any_cfg:
|
||||
display_reason = any_cfg.remark or ''
|
||||
|
||||
return Response({
|
||||
'code': 200,
|
||||
'msg': '获取成功',
|
||||
@@ -119,6 +132,10 @@ class FundFreezeMineView(APIView):
|
||||
'total_dongjie': _money(total_dongjie),
|
||||
'total_withdrawable': _money(total_withdrawable),
|
||||
'has_freeze': total_dongjie > 0,
|
||||
'display_reason': display_reason or (
|
||||
'部分佣金暂存为冻结保障金,用于订单售后与纠纷保障;'
|
||||
'按俱乐部规则到期或达标后自动转入可提现余额,冻结中金额不可提现。'
|
||||
),
|
||||
},
|
||||
})
|
||||
|
||||
@@ -173,7 +190,11 @@ class FundFreezeMyLedgerView(APIView):
|
||||
'source_type': r.source_type,
|
||||
'source_label': SOURCE_LABEL.get(r.source_type, r.source_type or '入账'),
|
||||
'order_id': r.order_id or '',
|
||||
'freeze_reason': r.freeze_reason or '',
|
||||
'freeze_reason': r.freeze_reason or (
|
||||
(r.config_snapshot or {}).get('display_reason')
|
||||
or (r.config_snapshot or {}).get('remark')
|
||||
or ''
|
||||
),
|
||||
'current_step': r.current_step,
|
||||
})
|
||||
|
||||
@@ -246,7 +267,11 @@ class FundFreezeMyLedgerDetailView(APIView):
|
||||
'source_type': ledger.source_type,
|
||||
'source_label': SOURCE_LABEL.get(ledger.source_type, ledger.source_type or '入账'),
|
||||
'order_id': ledger.order_id or '',
|
||||
'freeze_reason': ledger.freeze_reason or '',
|
||||
'freeze_reason': ledger.freeze_reason or (
|
||||
(ledger.config_snapshot or {}).get('display_reason')
|
||||
or (ledger.config_snapshot or {}).get('remark')
|
||||
or ''
|
||||
),
|
||||
'current_step': ledger.current_step,
|
||||
'events': event_list,
|
||||
},
|
||||
|
||||
@@ -1112,10 +1112,30 @@ class TixianAssetView(APIView):
|
||||
|
||||
from jituan.services.club_user import get_user_club_id
|
||||
from jituan.services.withdraw_config import build_tixian_asset_rates
|
||||
from jituan.models import ClubFundFreezeConfig
|
||||
|
||||
club_id = get_user_club_id(user)
|
||||
data.update(build_tixian_asset_rates(club_id))
|
||||
|
||||
display_reason = ''
|
||||
try:
|
||||
if club_id:
|
||||
prefer = ClubFundFreezeConfig.query.filter(
|
||||
club_id=club_id, role='dashou', enabled=True,
|
||||
).first()
|
||||
if not prefer:
|
||||
prefer = ClubFundFreezeConfig.query.filter(
|
||||
club_id=club_id, enabled=True,
|
||||
).exclude(remark='').first()
|
||||
if prefer:
|
||||
display_reason = prefer.remark or ''
|
||||
except Exception:
|
||||
pass
|
||||
data['freeze_display_reason'] = display_reason or (
|
||||
'部分佣金暂存为冻结保障金,用于订单售后与纠纷保障;'
|
||||
'按规则解冻后自动转入可提现,冻结中不可提现。'
|
||||
)
|
||||
|
||||
return Response({
|
||||
'code': 200,
|
||||
'msg': '获取成功',
|
||||
|
||||
Reference in New Issue
Block a user