diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..35410ca --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/dingdan/views.py b/dingdan/views.py index d67d0fc..bbe3a4a 100644 --- a/dingdan/views.py +++ b/dingdan/views.py @@ -3012,7 +3012,7 @@ class ShangjiaPaifaView(APIView): commission_value_str = str(commission_value_raw).strip() if commission_value_raw is not None else '' # ----- 3. 必填校验 ----- - if not all([shangpin_type_id, huiyuan_id, dingdan_jieshao, laoban_name, jiage_str]): + if not all([shangpin_type_id, dingdan_jieshao, laoban_name, jiage_str]): logger.warning(f"参数缺失: {request.data}") return Response({'code': 400, 'msg': '缺少必填参数'}) diff --git a/houtai/models.py b/houtai/models.py index b252fb3..b2ed194 100644 --- a/houtai/models.py +++ b/houtai/models.py @@ -254,7 +254,8 @@ class TixianRiTongji(models.Model): """ riqi = models.DateField(db_index=True, verbose_name='日期') leixing = models.IntegerField( - choices=[(1, '打手'), (2, '管事'), (3, '组长')], + choices=[(1, '打手'), (2, '管事'), (3, '组长'), + (4, '考核官'), (5, '打手押金'), (6, '商家余额')], verbose_name='用户类型' ) total_amount = models.DecimalField(max_digits=12, decimal_places=2, default=0.00, verbose_name='当天提现总额(元)') diff --git a/houtai/view.py b/houtai/view.py index 8f7211b..e4bd717 100644 --- a/houtai/view.py +++ b/houtai/view.py @@ -6766,9 +6766,6 @@ class UpdateGuanliView(APIView): - - - class GetWithdrawSettingsView(APIView): """ 获取提现设置(手续费利率、每日限额、当日已提现总额) @@ -6808,18 +6805,19 @@ class GetWithdrawSettingsView(APIView): obj = TixianQuotaDefault.objects.filter(leixing=leixing).first() quota_map[leixing] = float(obj.default_quota) if obj else 20.0 - # 3. 每日总限额 (leixing=4,5,6) + # 3. 每日总限额(提现类型1~6 → 配置表4~9) total_limit_map = {} - for leixing, total_code in [(1, 4), (2, 5), (3, 6)]: - obj = TixianQuotaDefault.objects.filter(leixing=total_code).first() - total_limit_map[leixing] = float(obj.default_quota) if obj else 0.0 + for withdraw_leixing, quota_leixing in [(1, 4), (2, 5), (3, 6), (4, 7), (5, 8), (6, 9)]: + obj = TixianQuotaDefault.objects.filter(leixing=quota_leixing).first() + total_limit_map[withdraw_leixing] = float(obj.default_quota) if obj else 0.0 - # 4. 当日已提现总额 + # 4. 当日已提现总额(按提现类型 leixing 1~6) today = date.today() - today_totals = {1: 0.0, 2: 0.0, 3: 0.0} + today_totals = {i: 0.0 for i in range(1, 7)} records = TixianRiTongji.objects.filter(riqi=today) for rec in records: - today_totals[rec.leixing] = float(rec.total_amount) + if rec.leixing in today_totals: + today_totals[rec.leixing] = float(rec.total_amount) # 🆕 获取提现模式(自动1 / 手动2),默认2 from peizhi.models import WithdrawConfig # 确保导入模型 @@ -6874,8 +6872,8 @@ class UpdateWithdrawSettingsView(APIView): rate_code_map = {1: '5', 2: '6', 3: '8', 4: '9', 5: '11', 6: '10'} # 订单/押金分红(1平台订单/3商家订单/12押金管事/13商家订单管事分红) order_rate_code_map = {1: '1', 3: '3', 12: '12', 13: '13'} - # 总限额对应的 leixing 值(4,5,6) - total_code_map = {1: 4, 2: 5, 3: 6} + # 总限额:提现类型 → TixianQuotaDefault.leixing(4~9) + total_code_map = {1: 4, 2: 5, 3: 6, 4: 7, 5: 8, 6: 9} def _rate_key_present(data, role): return (str(role) in data and data[str(role)] is not None) or \ @@ -6888,14 +6886,20 @@ class UpdateWithdrawSettingsView(APIView): if perm_needed not in permissions: if _rate_key_present(rates, role) or \ (str(role) in quotas and quotas[str(role)] is not None) or \ - (str(role) in total_limits and total_limits[str(role)] is not None): + (role in quotas and quotas.get(role) is not None) or \ + (str(role) in total_limits and total_limits[str(role)] is not None) or \ + (role in total_limits and total_limits.get(role) is not None): return Response({'code': 403, 'msg': f'无权限修改{["","打手","管事","组长"][role]}相关设置(需要{perm_needed})'}) # 其他提现手续费(审核官/打手押金/商家余额):需 5500a/b/c 任一 + extra_role_names = {4: '考核官', 5: '打手押金', 6: '商家余额'} for role in [4, 5, 6]: if _rate_key_present(rates, role) and not any(p in permissions for p in ('5500a', '5500b', '5500c')): - role_names = {4: '审核官', 5: '打手押金', 6: '商家余额'} - return Response({'code': 403, 'msg': f'无权限修改{role_names[role]}提现手续费率'}) + return Response({'code': 403, 'msg': f'无权限修改{extra_role_names[role]}提现手续费率'}) + if (str(role) in total_limits and total_limits[str(role)] is not None) or \ + (role in total_limits and total_limits.get(role) is not None): + if not any(p in permissions for p in ('5500a', '5500b', '5500c')): + return Response({'code': 403, 'msg': f'无权限修改{extra_role_names[role]}总限额'}) # 订单/押金分红费率:需 5500a/b/c 任一 for role in [1, 3, 12, 13]: @@ -6948,20 +6952,19 @@ class UpdateWithdrawSettingsView(APIView): obj.default_quota = quota obj.save() - # 3. 修改每日总限额 - for role in [1, 2, 3]: - if str(role) in total_limits: - val = total_limits[str(role)] - if val is not None: - limit = Decimal(str(val)) - code = total_code_map[role] - obj, created = TixianQuotaDefault.objects.select_for_update().get_or_create( - leixing=code, - defaults={'default_quota': limit} - ) - if not created: - obj.default_quota = limit - obj.save() + # 3. 修改每日总限额(1打手/2管事/3组长/4考核官/5押金/6商家) + for role in [1, 2, 3, 4, 5, 6]: + val = total_limits.get(str(role), total_limits.get(role)) + if val is not None: + limit = Decimal(str(val)) + code = total_code_map[role] + obj, created = TixianQuotaDefault.objects.select_for_update().get_or_create( + leixing=code, + defaults={'default_quota': limit} + ) + if not created: + obj.default_quota = limit + obj.save() # 🆕 修改提现模式(有5500a/b/c任一即可) from peizhi.models import WithdrawConfig @@ -6980,8 +6983,6 @@ class UpdateWithdrawSettingsView(APIView): - - class GetZuzhangListView(APIView): """ 组长列表接口(分页 + 多条件筛选) diff --git a/peizhi/models.py b/peizhi/models.py index 103b69e..1715daf 100644 --- a/peizhi/models.py +++ b/peizhi/models.py @@ -218,7 +218,8 @@ class TixianQuotaDefault(models.Model): """ id = models.AutoField(primary_key=True) leixing = models.IntegerField( - choices=[(1, '打手'), (2, '管事')], + choices=[(1, '打手'), (2, '管事'), (3, '组长'), + (4, '考核官'), (5, '打手押金'), (6, '商家余额')], unique=True, verbose_name='用户类型' )