feat: 提现自动过审按身份勾选(打手/管事/组长等)

This commit is contained in:
XingQue
2026-08-01 20:55:41 +08:00
parent 5a8029e30c
commit 6f635659eb
4 changed files with 104 additions and 22 deletions

View File

@@ -0,0 +1,42 @@
# 自动过审由「总开关」改为「按提现身份勾选」
from django.db import migrations, models
def forwards_bool_to_leixings(apps, schema_editor):
ClubWithdrawConfig = apps.get_model('jituan', 'ClubWithdrawConfig')
# 若旧开关已开:默认放开全部身份,避免线上行为突然变严
all_leixings = [1, 2, 3, 4, 5, 6]
for row in ClubWithdrawConfig.objects.all():
if getattr(row, 'auto_pass_audit', False):
row.auto_pass_leixings = list(all_leixings)
else:
row.auto_pass_leixings = []
row.save(update_fields=['auto_pass_leixings'])
def backwards_leixings_to_bool(apps, schema_editor):
ClubWithdrawConfig = apps.get_model('jituan', 'ClubWithdrawConfig')
for row in ClubWithdrawConfig.objects.all():
row.auto_pass_audit = bool(row.auto_pass_leixings)
row.save(update_fields=['auto_pass_audit'])
class Migration(migrations.Migration):
dependencies = [
('jituan', '0024_club_withdraw_auto_pass_audit'),
]
operations = [
migrations.AddField(
model_name='clubwithdrawconfig',
name='auto_pass_leixings',
field=models.JSONField(blank=True, default=list, verbose_name='自动过审身份'),
),
migrations.RunPython(forwards_bool_to_leixings, backwards_leixings_to_bool),
migrations.RemoveField(
model_name='clubwithdrawconfig',
name='auto_pass_audit',
),
]

View File

@@ -290,8 +290,9 @@ class ClubLilubiao(QModel):
class ClubWithdrawConfig(QModel):
club_id = models.CharField(max_length=16, primary_key=True)
mode = models.IntegerField(default=1, verbose_name='1自动2手动')
# True=自动提现申请后直接待收款(6),跳过人工审;校验逻辑不变
auto_pass_audit = models.BooleanField(default=False, verbose_name='自动过审')
# 可免审的提现身份 leixing 列表,如 [1,2]=打手佣金+管事;空=全部仍需人工审
# 1打手佣金 2管事 3组长 4考核官 5打手押金 6商家余额
auto_pass_leixings = models.JSONField(default=list, blank=True, verbose_name='自动过审身份')
CreateTime = models.DateTimeField(auto_now_add=True)
UpdateTime = models.DateTimeField(auto_now=True)

View File

@@ -129,13 +129,48 @@ def get_withdraw_mode(club_id):
return 2
def get_auto_pass_audit(club_id):
"""自动过审True 时 zddksh 申请通过校验后直接落待收款(6)。默认 False。"""
AUTO_PASS_LEIXING_CHOICES = (1, 2, 3, 4, 5, 6)
def _normalize_auto_pass_leixings(raw):
"""规范化为去重后的 int 列表,仅允许 1~6。"""
if raw is None:
return []
if isinstance(raw, bool):
# 兼容旧客户端误传 true不当作全开
return []
if not isinstance(raw, (list, tuple, set)):
return []
out = []
seen = set()
for x in raw:
try:
v = int(x)
except (TypeError, ValueError):
continue
if v in AUTO_PASS_LEIXING_CHOICES and v not in seen:
seen.add(v)
out.append(v)
return out
def get_auto_pass_leixings(club_id):
"""返回该俱乐部配置的免审身份列表(空=全部需人工审)。"""
club_id = _normalize_club_id(club_id)
try:
return bool(ClubWithdrawConfig.query.get(club_id=club_id).auto_pass_audit)
row = ClubWithdrawConfig.query.get(club_id=club_id)
return _normalize_auto_pass_leixings(getattr(row, 'auto_pass_leixings', None))
except ClubWithdrawConfig.DoesNotExist:
return []
def is_auto_pass_leixing(club_id, leixing):
"""该身份在本俱乐部是否自动过审(校验仍走原流程,仅落库状态不同)。"""
try:
lx = int(leixing)
except (TypeError, ValueError):
return False
return lx in get_auto_pass_leixings(club_id)
def get_personal_daily_quota(club_id, leixing, profile):
@@ -226,7 +261,7 @@ def build_withdraw_settings_payload(request):
'club_id': club_id,
'scope': resolve_club_scope(request),
'withdraw_mode': get_withdraw_mode(club_id),
'auto_pass_audit': get_auto_pass_audit(club_id),
'auto_pass_leixings': get_auto_pass_leixings(club_id),
'rates': rate_map,
'order_rates': order_rate_map,
'penalty_bonus_rates': get_penalty_bonus_rates_map(club_id),
@@ -328,31 +363,35 @@ def apply_withdraw_settings_update(request, permissions):
_set_quota(club_id, total_code_map[role], Decimal(str(val)))
withdraw_mode = request.data.get('withdraw_mode')
auto_pass_audit = request.data.get('auto_pass_audit')
if withdraw_mode is not None or auto_pass_audit is not None:
auto_pass_leixings = request.data.get('auto_pass_leixings', None)
# 兼容旧字段true → 全开false → 全关;列表 → 按身份
if auto_pass_leixings is None and 'auto_pass_audit' in request.data:
old = request.data.get('auto_pass_audit')
if old in (True, 1, '1', 'true', 'True'):
auto_pass_leixings = list(AUTO_PASS_LEIXING_CHOICES)
elif old in (False, 0, '0', 'false', 'False'):
auto_pass_leixings = []
if withdraw_mode is not None or auto_pass_leixings is not None:
if not any(p in permissions for p in ('5500a', '5500b', '5500c')):
return Response({'code': 403, 'msg': '无权限修改提现模式'})
defaults = {}
if withdraw_mode is not None:
defaults['mode'] = int(withdraw_mode)
if auto_pass_audit is not None:
defaults['auto_pass_audit'] = bool(
auto_pass_audit in (True, 1, '1', 'true', 'True')
)
if auto_pass_leixings is not None:
defaults['auto_pass_leixings'] = _normalize_auto_pass_leixings(auto_pass_leixings)
row, created = ClubWithdrawConfig.query.get_or_create(
club_id=club_id,
defaults=defaults or {'mode': 2, 'auto_pass_audit': False},
defaults=defaults or {'mode': 2, 'auto_pass_leixings': []},
)
if not created:
update_fields = ['UpdateTime']
if withdraw_mode is not None:
row.mode = int(withdraw_mode)
update_fields.append('mode')
if auto_pass_audit is not None:
row.auto_pass_audit = bool(
auto_pass_audit in (True, 1, '1', 'true', 'True')
)
update_fields.append('auto_pass_audit')
if auto_pass_leixings is not None:
row.auto_pass_leixings = _normalize_auto_pass_leixings(auto_pass_leixings)
update_fields.append('auto_pass_leixings')
row.save(update_fields=update_fields)
return Response({'code': 0, 'msg': '设置修改成功'})

View File

@@ -1758,9 +1758,9 @@ def create_audit_application(user_main, leixing, jine):
nicheng = deduct_balance(user_main, leixing, jine) or nicheng
club_id = club_id_for_tixian_yonghuid(yonghuid)
# 自动过审:校验已全部通过后,直接待收款(6);默认仍为审核中(1)。不改任何校验。
from jituan.services.withdraw_config import get_auto_pass_audit
init_status = 6 if get_auto_pass_audit(club_id) else 1
# 自动过审(按身份):校验已全部通过后,该 leixing 在配置内则直接待收款(6)。不改任何校验。
from jituan.services.withdraw_config import is_auto_pass_leixing
init_status = 6 if is_auto_pass_leixing(club_id, leixing) else 1
audit_kwargs = {
'shenhe_danhao': shenhe_danhao,
@@ -1808,6 +1808,6 @@ def create_audit_application(user_main, leixing, jine):
'current_rate': str(feilv.quantize(decimal.Decimal('0.0001'))),
'leixing': leixing,
'zhuangtai': init_status,
'auto_pass_audit': init_status == 6,
'auto_passed': init_status == 6,
})
return response_data