From 389d481b72d5510d3ca41fa13063e407a8986530 Mon Sep 17 00:00:00 2001 From: XingQue Date: Mon, 27 Jul 2026 00:56:43 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=A2=E6=9C=8D=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E5=8F=AF=E5=BC=80=E5=85=B3=E6=8A=95=E8=AF=89=E6=8B=A6=E6=88=AA?= =?UTF-8?q?=E6=8F=90=E7=8E=B0=EF=BC=88=E6=8C=89=E5=BD=93=E5=89=8D=E4=BF=B1?= =?UTF-8?q?=E4=B9=90=E9=83=A8=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 投诉工单页对应 API:GET/POST /gongdan/admin/club-config/ Co-authored-by: Cursor --- gongdan/services.py | 23 ++++++++++++++++++++++ gongdan/urls.py | 2 ++ gongdan/views.py | 47 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+) diff --git a/gongdan/services.py b/gongdan/services.py index ac7dd8f..e111ff7 100644 --- a/gongdan/services.py +++ b/gongdan/services.py @@ -55,6 +55,29 @@ def ensure_club_gongdan_config(club_id: str, *, withdraw_block: bool = False) -> return row +def get_club_gongdan_config(club_id: str) -> dict: + cid = (club_id or '').strip() + if not cid: + return {'club_id': '', 'complaint_withdraw_block': False} + row = ClubGongdanConfig.query.filter(club_id=cid).first() + return { + 'club_id': cid, + 'complaint_withdraw_block': bool(row and row.complaint_withdraw_block), + } + + +def set_complaint_withdraw_block(club_id: str, enabled: bool) -> dict: + cid = (club_id or '').strip() + if not cid: + raise GongdanError('俱乐部不能为空', 'need_club') + row = ensure_club_gongdan_config(cid, withdraw_block=bool(enabled)) + enabled = bool(enabled) + if row.complaint_withdraw_block != enabled: + row.complaint_withdraw_block = enabled + row.save(update_fields=['complaint_withdraw_block', 'UpdateTime']) + return get_club_gongdan_config(cid) + + def _user_nicheng(uid: str) -> str: """展示昵称:打手 nicheng → 老板 nickname → 用户{UID}。不把 UID 当昵称展示。""" uid = (uid or '').strip() diff --git a/gongdan/urls.py b/gongdan/urls.py index e3720da..cef3362 100644 --- a/gongdan/urls.py +++ b/gongdan/urls.py @@ -16,6 +16,7 @@ from gongdan.views import ( ChongzhiRecordListView, GongdanAdminListView, GongdanAdminHandleView, + GongdanAdminClubConfigView, ) urlpatterns = [ @@ -34,4 +35,5 @@ urlpatterns = [ path('chongzhi-list/', ChongzhiRecordListView.as_view(), name='我的充值记录'), path('admin/list/', GongdanAdminListView.as_view(), name='客服工单列表'), path('admin/handle/', GongdanAdminHandleView.as_view(), name='客服处理工单'), + path('admin/club-config/', GongdanAdminClubConfigView.as_view(), name='工单俱乐部开关'), ] diff --git a/gongdan/views.py b/gongdan/views.py index af976d7..9073c9a 100644 --- a/gongdan/views.py +++ b/gongdan/views.py @@ -27,6 +27,8 @@ from gongdan.services import ( user_apply_intervene, check_complaint_blocks_withdraw, search_complaint_targets, + get_club_gongdan_config, + set_complaint_withdraw_block, ) from utils.oss_utils import upload_to_oss, validate_image @@ -479,3 +481,48 @@ class GongdanAdminHandleView(APIView): except Exception as e: logger.error('处理工单失败: %s', e, exc_info=True) return _err('处理失败', http=500) + + +class GongdanAdminClubConfigView(APIView): + """ + 当前俱乐部工单开关。 + GET/POST /gongdan/admin/club-config/ + 字段:complaint_withdraw_block(未结清投诉/牵连时禁止提现) + """ + permission_classes = [IsAuthenticated] + + def _club_id(self, request): + try: + from jituan.services.club_context import resolve_club_id_from_request + return (resolve_club_id_from_request(request) or '').strip() + except Exception: + return (getattr(request.user, 'ClubID', None) or getattr(request.user, 'club_id', None) or '').strip() + + def get(self, request): + kefu, perms, err = _require_kefu_perm(request, PERM_VIEW, PERM_HANDLE) + if err: + return err + club_id = self._club_id(request) + if not club_id: + return _err('请先选择俱乐部') + return _ok(get_club_gongdan_config(club_id)) + + def post(self, request): + kefu, perms, err = _require_kefu_perm(request, PERM_HANDLE) + if err: + return err + club_id = self._club_id(request) + if not club_id: + return _err('请先选择俱乐部') + raw = request.data.get('complaint_withdraw_block') + if raw is None: + return _err('缺少 complaint_withdraw_block') + if isinstance(raw, str): + enabled = raw.strip().lower() in ('1', 'true', 'yes', 'on') + else: + enabled = bool(raw) + try: + data = set_complaint_withdraw_block(club_id, enabled) + return _ok(data, '已保存') + except GongdanError as e: + return _err(str(e))