From 6f635659eb9f244487481838996d2ee9972b14bb Mon Sep 17 00:00:00 2001 From: XingQue Date: Sat, 1 Aug 2026 20:55:41 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=8F=90=E7=8E=B0=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E8=BF=87=E5=AE=A1=E6=8C=89=E8=BA=AB=E4=BB=BD=E5=8B=BE=E9=80=89?= =?UTF-8?q?=EF=BC=88=E6=89=93=E6=89=8B/=E7=AE=A1=E4=BA=8B/=E7=BB=84?= =?UTF-8?q?=E9=95=BF=E7=AD=89=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../0025_club_withdraw_auto_pass_leixings.py | 42 +++++++++++ jituan/models.py | 5 +- jituan/services/withdraw_config.py | 71 ++++++++++++++----- users/tixian_shenhe_services.py | 8 +-- 4 files changed, 104 insertions(+), 22 deletions(-) create mode 100644 jituan/migrations/0025_club_withdraw_auto_pass_leixings.py diff --git a/jituan/migrations/0025_club_withdraw_auto_pass_leixings.py b/jituan/migrations/0025_club_withdraw_auto_pass_leixings.py new file mode 100644 index 0000000..39dd67b --- /dev/null +++ b/jituan/migrations/0025_club_withdraw_auto_pass_leixings.py @@ -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', + ), + ] diff --git a/jituan/models.py b/jituan/models.py index a6beac0..64174d3 100644 --- a/jituan/models.py +++ b/jituan/models.py @@ -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) diff --git a/jituan/services/withdraw_config.py b/jituan/services/withdraw_config.py index 78faa10..45de28a 100644 --- a/jituan/services/withdraw_config.py +++ b/jituan/services/withdraw_config.py @@ -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': '设置修改成功'}) diff --git a/users/tixian_shenhe_services.py b/users/tixian_shenhe_services.py index 0136b55..54be461 100644 --- a/users/tixian_shenhe_services.py +++ b/users/tixian_shenhe_services.py @@ -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