{
 "cells": [
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-07-22T07:49:06.123094Z",
     "start_time": "2025-07-22T07:49:05.680068Z"
    }
   },
   "cell_type": "code",
   "source": [
    "# -*- coding: utf-8 -*-\n",
    "import pandas as pd\n",
    "import datetime\n",
    "from config import Config\n",
    "from api import API\n",
    "import pymysql  # 使用 pymysql 替代 mysql.connector\n",
    "from back_ground_module import CommonModule\n",
    "import os\n",
    "import mysql.connector\n",
    "import pandas as pd\n",
    "import json\n",
    "import numpy as np\n",
    "import mysql.connector\n",
    "from mysql.connector import Error\n",
    "\n",
    "start_time = datetime.datetime.now()\n",
    "api_instance = API()\n",
    "common_module = CommonModule()\n",
    "\n",
    "# 保存为CSV文件\n",
    "output_dir = \"output\"  # 设置输出目录\n",
    "\n",
    "# 创建输出目录（如果不存在）\n",
    "os.makedirs(output_dir, exist_ok=True)\n",
    "payload = {\"api_key\": \"673d8427549d00c3d753c530\",\n",
    "           \"entry_id\": \"67c80eb3d2af9b9821928f45\",\n",
    "           }\n",
    "dealer_service = api_instance.entry_data_list(payload, replace=True)\n",
    "dealer_service_data = dealer_service.get(\"data\")\n",
    "\n",
    "\n",
    "df.to_csv(os.path.join(output_dir, \"dealer_service.csv\"), index=False)"
   ],
   "id": "f1f5b6de5c2a10c4",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "已获取 26 条数据\n",
      "进行了替换\n",
      "{'_widget_1742197585104': '购买的产品名称', '_widget_1741164213155': '经销商名称', '_widget_1741164213151': '经销商简称', '_widget_1741165503706': '负责人姓名', '_widget_1741165503711': '负责人手机号', '_widget_1741165503710': '经销商可使用的群数量', '_widget_1741164213149': '订单编码', '_widget_1741164213159': '订单支付时间', '_widget_1741164213152': '商户门店ID', '_widget_1741164213171': '开通时间', '_widget_1741164213172': '详细地址', '_widget_1741165503708': '联系电话', '_widget_1741165503709': '系统到期时间', '_widget_1741165503714': '开通状态', '_widget_1741165503716': '销售负责人', '_widget_1741165503718': '运营顾问', '_widget_1741165503719': '运营专家', '_widget_1741165503717': '区域经理', '_widget_1741165503721': '业务人员', '_widget_1742200372555': '是否设置经营范围', '_widget_1742268351775': '不设置经营范围原因', '_widget_1742200372553': '是否建群', '_widget_1742268351776': '不建群原因', '_widget_1742200372634': '是否设置备货清单', '_widget_1742268351778': '不设置备货清单原因', '_widget_1742260928184': '是否设置报价', '_widget_1742268351777': '不设置报价原因', '_widget_1742200372559': '是否上货', '_widget_1742268351779': '不上货原因', '_widget_1749717287367': '是否培训系统使用', '_widget_1749717287369': '不培训系统使用原因', '_widget_1749717287373': '是否补货', '_widget_1749717287375': '不补货原因', '_widget_1742200372561': '是否进行滞销回抽+盘点介绍', '_widget_1742268351780': '不进行滞销回抽+盘点介绍原因', '_widget_1743148999298': '服务是否满意', '_widget_1743148999308': '服务不满意原因', '_widget_1743148999300': '产品是否满意', '_widget_1743148999309': '产品不满意原因', '_widget_1743148999310': '上传评价图片', '_widget_1743500862664': '审核备注', '_widget_1753162835213': '完成日期时间', '_widget_1753163217437': '流水号'}\n"
     ]
    }
   ],
   "execution_count": 8
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-07-22T07:44:03.849700Z",
     "start_time": "2025-07-22T07:44:03.839664Z"
    }
   },
   "cell_type": "code",
   "source": [
    "df  = pd.DataFrame(dealer_service_data)\n",
    "df.to_csv(os.path.join(output_dir, \"dealer_service.csv\"), index=False)"
   ],
   "id": "8445dd23da7aeeb6",
   "outputs": [],
   "execution_count": 3
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
