|
@@ -86,8 +86,13 @@ class AgentCustomerView(View):
|
|
|
return self.batch_rebind_customer_packages(userID, request_dict, response)
|
|
return self.batch_rebind_customer_packages(userID, request_dict, response)
|
|
|
elif operation == 'getAgentServicePackageList':
|
|
elif operation == 'getAgentServicePackageList':
|
|
|
return self.get_agent_service_package_list(response)
|
|
return self.get_agent_service_package_list(response)
|
|
|
|
|
+
|
|
|
elif operation == 'getAgentSettleOrders':
|
|
elif operation == 'getAgentSettleOrders':
|
|
|
return self.get_agent_settle_order(userID, request_dict, response)
|
|
return self.get_agent_settle_order(userID, request_dict, response)
|
|
|
|
|
+ elif operation == 'getAgentAccountWithdraw':
|
|
|
|
|
+ return self.get_agent_account_withdraw(userID, request_dict, response)
|
|
|
|
|
+ elif operation == 'getCheckBalance':
|
|
|
|
|
+ return self.get_check_balance(userID, response)
|
|
|
elif operation == 'getDataStatistics':
|
|
elif operation == 'getDataStatistics':
|
|
|
return self.get_data_statistics(userID, response)
|
|
return self.get_data_statistics(userID, response)
|
|
|
else:
|
|
else:
|
|
@@ -531,6 +536,96 @@ class AgentCustomerView(View):
|
|
|
except Exception as e:
|
|
except Exception as e:
|
|
|
return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
|
|
|
|
|
|
|
+ def get_agent_account_withdraw(self, userID, request_dict, response):
|
|
|
|
|
+ """
|
|
|
|
|
+ 查询提现明细
|
|
|
|
|
+ @param userID: userID
|
|
|
|
|
+ @param request_dict: 请求参数
|
|
|
|
|
+ @param response: 响应对象
|
|
|
|
|
+ @return:
|
|
|
|
|
+ """
|
|
|
|
|
+ agent_customer_info = AgentCustomerInfo.objects.filter(user_id=userID).first()
|
|
|
|
|
+ if not agent_customer_info:
|
|
|
|
|
+ return response.json(104, 'Agent customer not found')
|
|
|
|
|
+
|
|
|
|
|
+ ac_id = agent_customer_info.id
|
|
|
|
|
+ try:
|
|
|
|
|
+ agent_account_withdraw_qs = AgentAccountWithdraw.objects.filter(ac_id=ac_id).order_by('-updated_time')
|
|
|
|
|
+
|
|
|
|
|
+ page = int(request_dict.get('page', 1)) # 默认为第一页
|
|
|
|
|
+ page_size = int(request_dict.get('page_size', 10)) # 默认每页10条记录
|
|
|
|
|
+
|
|
|
|
|
+ # 应用分页
|
|
|
|
|
+ paginator = Paginator(agent_account_withdraw_qs, page_size)
|
|
|
|
|
+ current_page = paginator.get_page(page)
|
|
|
|
|
+
|
|
|
|
|
+ withdraw_list = []
|
|
|
|
|
+
|
|
|
|
|
+ for withdraw in current_page:
|
|
|
|
|
+ agent_customer_card = AgentCustomerCard.objects.filter(ac_id=ac_id).first()
|
|
|
|
|
+ card_no = agent_customer_card.card_no
|
|
|
|
|
+ withdraw_list.append({
|
|
|
|
|
+ 'id': withdraw.id,
|
|
|
|
|
+ 'amount': withdraw.amount,
|
|
|
|
|
+ 'created_time': withdraw.created_time,
|
|
|
|
|
+ 'card_no': card_no,
|
|
|
|
|
+ 'status': withdraw.status,
|
|
|
|
|
+ 'remark': withdraw.remark,
|
|
|
|
|
+ 'arrival_time': withdraw.arrival_time
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ response_data = {
|
|
|
|
|
+ 'list': withdraw_list,
|
|
|
|
|
+ 'total': paginator.count,
|
|
|
|
|
+ 'page': current_page.number,
|
|
|
|
|
+ 'page_size': page_size,
|
|
|
|
|
+ 'num_pages': paginator.num_pages,
|
|
|
|
|
+ }
|
|
|
|
|
+ return response.json(0, response_data)
|
|
|
|
|
+
|
|
|
|
|
+ except Exception as e:
|
|
|
|
|
+ # 出错时返回错误信息
|
|
|
|
|
+ return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
|
|
+
|
|
|
|
|
+ def get_check_balance(self, userID, response):
|
|
|
|
|
+ """
|
|
|
|
|
+ 查询余额
|
|
|
|
|
+ @param userID: userID
|
|
|
|
|
+ @param response: 响应对象
|
|
|
|
|
+ @return:
|
|
|
|
|
+ """
|
|
|
|
|
+
|
|
|
|
|
+ agent_customer_info = AgentCustomerInfo.objects.filter(user_id=userID).first()
|
|
|
|
|
+ if not agent_customer_info:
|
|
|
|
|
+ return response.json(104, 'Agent customer not found')
|
|
|
|
|
+
|
|
|
|
|
+ ac_id = agent_customer_info.id
|
|
|
|
|
+
|
|
|
|
|
+ try:
|
|
|
|
|
+ # 计算冻结金额
|
|
|
|
|
+ frozen_amount_qs = AgentAccountWithdraw.objects.filter(ac_id=ac_id)
|
|
|
|
|
+ frozen_amount = frozen_amount_qs.aggregate(total=Sum('amount'))['total'] or Decimal('0.00')
|
|
|
|
|
+
|
|
|
|
|
+ # 计算总余额:已结算且未删除的订单的利润总和
|
|
|
|
|
+ total_profit_qs = AgentDeviceOrder.objects.filter(ac_id=ac_id, status=2, is_del=False)
|
|
|
|
|
+ total_profit = total_profit_qs.aggregate(total=Sum('profit'))['total'] or Decimal('0.00')
|
|
|
|
|
+
|
|
|
|
|
+ # 可用余额 = 总余额 - 冻结金额
|
|
|
|
|
+ available_balance = total_profit - frozen_amount
|
|
|
|
|
+
|
|
|
|
|
+ # 构造返回数据
|
|
|
|
|
+ balance_data = {
|
|
|
|
|
+ 'frozen_amount': frozen_amount, # 冻结金额
|
|
|
|
|
+ 'total_profit': total_profit, # 总余额
|
|
|
|
|
+ 'available_balance': available_balance # 可用余额
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return response.json(0, balance_data)
|
|
|
|
|
+
|
|
|
|
|
+ except Exception as e:
|
|
|
|
|
+ # 出错时返回错误信息
|
|
|
|
|
+ return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
|
|
+
|
|
|
def get_data_statistics(self, userID, response):
|
|
def get_data_statistics(self, userID, response):
|
|
|
"""
|
|
"""
|
|
|
首页总览
|
|
首页总览
|