feat: 客服后台可开关投诉拦截提现(按当前俱乐部)

投诉工单页对应 API:GET/POST /gongdan/admin/club-config/

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
XingQueandCursor committed 2026-07-27 00:56:43 +08:00
1 parent 2d4ba56e65
commit 389d481b72
3 files changed
+72

No files matched your search

+23
View File
@@ -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()
+2
View File
@@ -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='工单俱乐部开关'),
]
+47
View File
@@ -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))