Przeglądaj źródła

用户提现相关接口

linhaohong 1 rok temu
rodzic
commit
62ab71e120

+ 84 - 2
AdminController/CloudServiceManage/AgentCustomerController.py

@@ -611,7 +611,7 @@ class AgentCustomerView(View):
 
         try:
             # 计算冻结金额
-            frozen_amount_qs = AgentAccountWithdraw.objects.filter(ac_id=ac_id)
+            frozen_amount_qs = AgentAccountWithdraw.objects.filter(ac_id=ac_id, status__in=[1,2,3])
             frozen_amount = frozen_amount_qs.aggregate(total=Sum('amount'))['total'] or Decimal('0.00')
 
             # 计算余额:已结算 - (退款+已打款)
@@ -748,7 +748,7 @@ class AgentCustomerView(View):
             total_profit = incomes_all - expense_all
 
             # 冻结余额
-            frozen_amount_qs = AgentAccountWithdraw.objects.filter(ac_id=ac_id)
+            frozen_amount_qs = AgentAccountWithdraw.objects.filter(ac_id=ac_id, status__in=[1,2,3])
             frozen_amount = frozen_amount_qs.aggregate(total=Sum('amount'))['total'] or Decimal('0.00')
 
             # 可提现余额 = 总余额 - 冻结金额
@@ -768,4 +768,86 @@ class AgentCustomerView(View):
             return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
 
 
+    def get_withdrawal_review(self, request_dict, response):
+        """
+        后台用户提现申请审核列表
+        @param request_dict: 请求参数
+        @param request_dict company_name: 公司名称
+        @param request_dict status: 审核状态
+        @param response: 响应对象
+        @return:
+        """
+        company_name = request_dict.get('company_name', None)
+        status = request_dict.get('status', None)
+        page = int(request_dict.get('page', 1))  # 默认为第一页
+        page_size = int(request_dict.get('page_size', 10))  # 默认每页10条记录
+
+        agent_account_withdraw_qs = AgentAccountWithdraw.objects.filter().order_by('updated_time')
+        if company_name:
+            agent_customer_info = AgentCustomerInfo.objects.filter(company_name=company_name).first()
+            ac_id = agent_customer_info.id
+            agent_account_withdraw_qs = agent_account_withdraw_qs.filter(ac_id=ac_id)
+
+        if status:
+            agent_account_withdraw_qs = agent_account_withdraw_qs.filter(status=status)
+
+        # 提现id 公司名 审核状态 提现金额 余额
+        paginator = Paginator(agent_account_withdraw_qs, page_size)
+        current_page = paginator.get_page(page)
+
+        review_list = []
+
+        for review in current_page:
+            ac_id = review.ac_id
+            agent_customer_info = AgentCustomerInfo.objects.filter(id=ac_id).first()
+            company_name = agent_customer_info.company_name
+            review_list.append({
+                "id": review.id,
+                "company_name": company_name,
+                "status": review.status,
+                "amount": review.amount,
+                "remark": review.remark,
+            })
 
+        response_data = {
+            'list': review_list,
+            'total': paginator.count,
+            'page': current_page.number,
+            'page_size': page_size,
+            'num_pages': paginator.num_pages,
+        }
+        return response.json(0, response_data)
+
+    def update_withdrawal_review(self, userID, request_dict, response):
+        """
+        后台提现审核
+        @param request_dict: 请求参数
+        @param request_dict id: 提现单id
+        @param request_dict status: 提现单状态
+        @param request_dict remark: 提现单备注
+        @param response: 响应对象
+        @return:
+        """
+        id = request_dict.get('id', None)
+        status = request_dict.get('status', None)
+        remark = request_dict.get('remark', "")
+
+        if not all([id, status]):
+            return response.json(444)
+
+        try:
+            agent_account_withdraw = AgentAccountWithdraw.objects.get(pk=id)
+            agent_account_withdraw.status = status
+            agent_account_withdraw.remark = remark
+            agent_account_withdraw.save()
+            if int(status) == 4:
+                AgentAccount.objects.create(ac_id=agent_account_withdraw.ac_id,
+                                            amount=agent_account_withdraw.amount,
+                                            status=3,
+                                            created_time = int(time.time()),
+                                            updated_time = int(time.time()),
+                                            remark = f"{userID}修改为已提现")
+            return response.json(0)
+
+        except Exception as e:
+            return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))