{ "cells": [ { "metadata": {}, "cell_type": "markdown", "source": "新签节点调用格式", "id": "671b10d308af2bdc" }, { "cell_type": "code", "id": "initial_id", "metadata": { "collapsed": true, "ExecuteTime": { "end_time": "2026-03-12T09:25:38.245095300Z", "start_time": "2026-03-12T09:25:36.441415900Z" } }, "source": [ "import requests\n", "url = \"https://manage-pre.f6yc.com/hive-admin/yida/updateNode\"\n", "\n", "\n", "payload = {\n", " \"nodeCode\": \"ORG_RESEARCH\",\n", " \"needTraining\": \"是\",\n", " \"impPrincipal\":\"['171408516124043808']\",\n", " \"instanceId\": \"69b269d6c193f83cc27f65e7\"\n", "}\n", "\n", "# [{\"_id\":\"69a285f3fa0d9fb1984da9bf\",\"name\":\"张乐乐\",\"username\":\"171408516124043808\",\"status\":1,\"type\":0}]\n", "\n", "response = requests.post(url, data=payload)\n", "response.json()" ], "outputs": [ { "data": { "text/plain": [ "{'code': 200, 'data': None, 'message': 'SUCCESS'}" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "execution_count": 14 }, { "metadata": {}, "cell_type": "markdown", "source": "# 续约联调", "id": "6ce335625a1c1fbb" }, { "metadata": { "ExecuteTime": { "end_time": "2026-03-26T07:12:43.283568100Z", "start_time": "2026-03-26T07:12:42.653902400Z" } }, "cell_type": "code", "source": [ "# 可以引用一些第三方库.\n", "import json\n", "import requests\n", "import time\n", "import random\n", "import time\n", "import binascii # 【修正1】添加缺失的 binascii 导入\n", "from pyDes import des, CBC, PAD_PKCS5\n", "\n", "data_id = \"69c4dc44986b303c2ef69d46\" # 数据id\n", "orgid = \"16058986391127773239\" # 门店id\n", "order_id = \"XYFWD20260326002\" # 服务单号\n", "operation_consultant_str = '[{\"_id\":\"69a285f3fa0d9fb1984da9bf\",\"name\":\"张乐乐\",\"username\":\"171408516124043808\",\"status\":1,\"type\":0}]'# 专属人员顾问\n", "\n", "url = \"https://manage-pre.f6yc.com/hive-admin/py/yida/renewal/insertRenewalFormsData\"\n", "\n", "def des_encrypt(s):\n", " \"\"\"\n", " DES 加密\n", " :param s: 原始字符串\n", " :return: 加密后字符串,16进制\n", " \"\"\"\n", " secret_key = 'HwdMBW8o'\n", " iv = secret_key\n", " k = des(secret_key, CBC, iv, pad=None, padmode=PAD_PKCS5)\n", " en = k.encrypt(s, padmode=PAD_PKCS5)\n", " return binascii.b2a_base64(en, newline=False)\n", "\n", "\n", "def des_descrypt(s):\n", " \"\"\"\n", " DES 解密\n", " :param s: 加密后的字符串,16进制\n", " :return: 解密后的字符串\n", " \"\"\"\n", " secret_key = 'HwdMBW8o'\n", " iv = secret_key\n", " k = des(secret_key, CBC, iv, pad=None, padmode=PAD_PKCS5)\n", " de = k.decrypt(binascii.a2b_base64(s), padmode=PAD_PKCS5)\n", " return de\n", "\n", "\n", "impPrincipal_list = []\n", "\n", "if operation_consultant_str:\n", " try:\n", " # 将字符串 '[{...}]' 转换为 Python 列表 [{...}]\n", " operation_list = json.loads(operation_consultant_str)\n", "\n", " # 确保解析出来的是列表\n", " if isinstance(operation_list, list):\n", " for operate in operation_list:\n", " # 确保每一项是字典且包含 username\n", " if isinstance(operate, dict) and \"username\" in operate:\n", " impPrincipal_list.append(operate[\"username\"])\n", " else:\n", " # 如果解析出来不是列表(比如是个单对象),做兼容处理\n", " if isinstance(operation_list, dict) and \"username\" in operation_list:\n", " impPrincipal_list.append(operation_list[\"username\"])\n", "\n", " except json.JSONDecodeError:\n", " # 如果解析失败,记录错误或保持列表为空\n", " print(f\"JSON 解析失败: {operation_consultant_str}\")\n", " impPrincipal_list = []\n", "else:\n", " operation_list = []\n", "\n", "impPrincipal_value=impPrincipal_list[0]\n", "\n", "t = time.time()\n", "ts = int(round(t * 1000))\n", "randint = random.randint(100000000, 999999999)\n", "req = data_id + \"|\" + orgid + \"|\" +order_id+ \"|\" + impPrincipal_value + \"_\" + str(ts) + \"_\" + str(randint)\n", "# 实例ID|门ID|服务单号|专属运营顾问\n", "str_en = des_encrypt(req)\n", "print(str_en.decode('utf-8'))\n", "req_new = str_en.decode('utf-8')\n", "payload = {\n", " 'req':req_new,\n", " 't':ts,\n", " 'r':randint\n", "}\n", "\n", "res = requests.post(url,data=payload)\n" ], "id": "fc98d87aa8b19ce2", "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Lmj1kXumBcGLR5IKAtgFDP2meGj6FgLzq7gaQ/6wDuZ3d43P0mtQCyUdQXkeC4kYxOT8w7n1xNxYhIy9PVq/xUR9emnP5CQweBFe8P3S9tRZdNFVOdipnD+xiof/q9b//C87kgUEIH7JT00nlBBkaQ==\n" ] } ], "execution_count": 2 }, { "metadata": { "ExecuteTime": { "end_time": "2026-03-13T08:12:33.285136400Z", "start_time": "2026-03-13T08:12:33.246808900Z" } }, "cell_type": "code", "source": "impPrincipal_value", "id": "8edd45ef4657d8ed", "outputs": [ { "data": { "text/plain": [ "'171408516124043808'" ] }, "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "execution_count": 26 } ], "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 }