feat: 提现审核按俱乐部隔离并加固打款商户号,新增小溪审核目录复制脚本
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1105,7 +1105,7 @@ def query_wechat_transfer_bill(out_bill_no, club_id=None):
|
||||
try:
|
||||
rec = TixianAutoRecord.query.filter(tixian_id=out_bill_no).first()
|
||||
if rec:
|
||||
club_id = club_id_for_tixian_yonghuid(rec.yonghuid)
|
||||
club_id = (getattr(rec, 'club_id', None) or '').strip() or club_id_for_tixian_yonghuid(rec.yonghuid)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@@ -1152,8 +1152,8 @@ def _parse_package_info(raw):
|
||||
def _apply_platform_accounting(auto_record):
|
||||
"""平台收支统计(幂等由 mark_transfer_success 外层保证只调一次)"""
|
||||
from jituan.services.szjilu_accounting import apply_szjilu_expense
|
||||
from jituan.services.wechat_pay import club_id_for_tixian_yonghuid
|
||||
payout_club = club_id_for_tixian_yonghuid(auto_record.yonghuid)
|
||||
from jituan.services.tixian_club import resolve_payout_club_id
|
||||
payout_club = resolve_payout_club_id(audit=None, jilu=auto_record, yonghuid=auto_record.yonghuid)
|
||||
update_daily_payout(auto_record.shijidaozhang, payout_club)
|
||||
apply_szjilu_expense(auto_record.shijidaozhang, payout_club)
|
||||
|
||||
|
||||
@@ -202,17 +202,12 @@ def process_audit_collect(request):
|
||||
|
||||
try:
|
||||
from users.tixian_shenhe_services import get_auto_withdraw_openid
|
||||
from jituan.services.club_user import get_user_club_id
|
||||
from jituan.services.wechat_pay import get_wechat_v3_config
|
||||
from jituan.services.tixian_club import resolve_payout_club_id
|
||||
|
||||
payout_club_id = get_user_club_id(user_main)
|
||||
payout_openid = get_auto_withdraw_openid(user_main)
|
||||
if not payout_openid:
|
||||
return Response({'code': 10, 'msg': '用户未绑定微信,无法收款'})
|
||||
wx_cfg = get_wechat_v3_config(payout_club_id)
|
||||
if not wx_cfg.get('APPID') or not wx_cfg.get('MCHID') or not wx_cfg.get('TRANSFER_SCENE_ID'):
|
||||
logger.error('微信打款配置不完整 club=%s APPID=%s MCHID=%s', payout_club_id, wx_cfg.get('APPID'), wx_cfg.get('MCHID'))
|
||||
return Response({'code': 11, 'msg': '系统配置异常,请联系客服'})
|
||||
|
||||
ctx, err = resolve_collect_context(
|
||||
yonghuid,
|
||||
@@ -228,6 +223,18 @@ def process_audit_collect(request):
|
||||
tixianjilu_id_val = ctx['jilu'].id if ctx.get('jilu') else audit.tixianjilu_id
|
||||
leixing = audit.leixing
|
||||
|
||||
# 打款商户严格跟提现单 club_id,禁止因用户迁店串到其他俱乐部商户号
|
||||
payout_club_id = resolve_payout_club_id(
|
||||
audit=audit, jilu=ctx.get('jilu'), user=user_main,
|
||||
)
|
||||
wx_cfg = get_wechat_v3_config(payout_club_id)
|
||||
if not wx_cfg.get('APPID') or not wx_cfg.get('MCHID') or not wx_cfg.get('TRANSFER_SCENE_ID'):
|
||||
logger.error(
|
||||
'微信打款配置不完整 club=%s APPID=%s MCHID=%s audit=%s',
|
||||
payout_club_id, wx_cfg.get('APPID'), wx_cfg.get('MCHID'), getattr(audit, 'id', None),
|
||||
)
|
||||
return Response({'code': 11, 'msg': '系统配置异常,请联系客服'})
|
||||
|
||||
amount_ok, amount_msg = validate_collect_amount(audit)
|
||||
if not amount_ok:
|
||||
with transaction.atomic():
|
||||
@@ -303,10 +310,9 @@ def process_audit_collect(request):
|
||||
quota_reserved = True
|
||||
|
||||
tixian_id = generate_tixian_id()
|
||||
from jituan.services.club_user import get_user_club_id
|
||||
TixianAutoRecord.query.create(
|
||||
tixian_id=tixian_id,
|
||||
club_id=get_user_club_id(user_main),
|
||||
club_id=payout_club_id,
|
||||
yonghuid=yonghuid,
|
||||
leixing=leixing,
|
||||
jine=jine,
|
||||
|
||||
@@ -2285,6 +2285,8 @@ class AddtxshView(APIView):
|
||||
|
||||
# 🔴【修改】排序改为按申请时间升序(最早申请排最前)
|
||||
queryset = Tixianjilu.query.filter(query).order_by('CreateTime')
|
||||
from jituan.services.tixian_club import filter_tixianjilu_by_request
|
||||
queryset = filter_tixianjilu_by_request(queryset, request)
|
||||
|
||||
# 🔴【修改】分页逻辑:如果是搜索模式,不分页,返回所有匹配记录
|
||||
if search_uid:
|
||||
@@ -2297,8 +2299,11 @@ class AddtxshView(APIView):
|
||||
current_count = len(records)
|
||||
has_more = (offset + current_count) < total_count
|
||||
|
||||
# 获取状态统计(统计与搜索无关,依然按筛选条件统计)
|
||||
_agg = Tixianjilu.query.filter(leixing=leixing).aggregate(
|
||||
# 获取状态统计(统计与搜索无关,依然按筛选条件统计;按俱乐部隔离)
|
||||
_status_qs = filter_tixianjilu_by_request(
|
||||
Tixianjilu.query.filter(leixing=leixing), request,
|
||||
)
|
||||
_agg = _status_qs.aggregate(
|
||||
awaiting=Count('id', filter=Q(zhuangtai=1)),
|
||||
processed=Count('id', filter=Q(zhuangtai__in=[2, 3])),
|
||||
)
|
||||
@@ -2393,6 +2398,11 @@ class AdtixianqkView(APIView):
|
||||
'data': None
|
||||
}, status=status.HTTP_404_NOT_FOUND)
|
||||
|
||||
from jituan.services.tixian_club import forbid_if_tixian_out_of_scope
|
||||
deny = forbid_if_tixian_out_of_scope(request, withdrawal)
|
||||
if deny:
|
||||
return deny
|
||||
|
||||
# 检查状态,只有待审核的可以处理
|
||||
if withdrawal.zhuangtai != 1:
|
||||
return Response({
|
||||
@@ -2418,9 +2428,10 @@ class AdtixianqkView(APIView):
|
||||
try:
|
||||
from jituan.services.szjilu_accounting import apply_szjilu_expense
|
||||
tixian_jine = withdrawal.jine
|
||||
from jituan.services.club_user import get_user_club_id
|
||||
payout_club = get_user_club_id(
|
||||
User.query.filter(UserUID=withdrawal.yonghuid).first()
|
||||
from jituan.services.tixian_club import resolve_payout_club_id
|
||||
payout_club = resolve_payout_club_id(
|
||||
jilu=withdrawal,
|
||||
user=User.query.filter(UserUID=withdrawal.yonghuid).first(),
|
||||
)
|
||||
update_daily_payout(tixian_jine, payout_club)
|
||||
apply_szjilu_expense(tixian_jine, payout_club)
|
||||
|
||||
@@ -699,14 +699,15 @@ class KefuWithdrawActionView(APIView):
|
||||
except User.DoesNotExist:
|
||||
raise ValueError(f'用户{tixian.yonghuid}不存在')
|
||||
|
||||
from jituan.services.club_user import get_user_club_id
|
||||
from jituan.services.tixian_club import resolve_payout_club_id
|
||||
|
||||
if action == 1:
|
||||
tixian.zhuangtai = 2
|
||||
try:
|
||||
from jituan.services.szjilu_accounting import apply_szjilu_expense
|
||||
update_daily_payout(tixian.jine, get_user_club_id(user))
|
||||
apply_szjilu_expense(tixian.jine, get_user_club_id(user))
|
||||
payout_club = resolve_payout_club_id(jilu=tixian, user=user)
|
||||
update_daily_payout(tixian.jine, payout_club)
|
||||
apply_szjilu_expense(tixian.jine, payout_club)
|
||||
except Exception as e:
|
||||
logger.error(f'更新收支记录失败: {e}')
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user