文件
fenleixinxi/tools/deploy_withdraw_cancel.py
MiAn 589d6aa216 feat: 新增提现详情页与撤销微信转账功能
新增分销提现单详情页面及接口,支持查看提现单据完整信息;新增后台撤销转账中提现单功能,前端添加对应操作按钮与交互逻辑;完善提现记录跳转逻辑,支持点击进入详情页,同时新增部署脚本同步线上代码。
2026-10-28 17:46:51 +08:00

90 行
3.0 KiB
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
部署最新修改到线上服务器:
- application/admin/controller/fc/Withdraw.php
- application/admin/view/fc/withdraw/edit.html
- application/api/controller/Distribution.php
- application/route.php
- public/assets/js/backend/fc/withdraw.js
"""
import os
import sys
import io
import paramiko
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace')
HOST = "8.137.181.63"
PORT = 22
USER = "root"
PASSWORD = "liyanxia@6688"
REMOTE_ROOT = "/www/wwwroot/fenleixinxi.gzyakj.com.cn"
LOCAL_ROOT = r"D:\Softwares\phpstudy_pro\WWW\fenleixinxi"
SYNC_FILES = [
"application/admin/controller/fc/Withdraw.php",
"application/admin/view/fc/withdraw/edit.html",
"application/api/controller/Distribution.php",
"application/route.php",
"public/assets/js/backend/fc/withdraw.js",
]
def ssh_exec(client, cmd):
stdin, stdout, stderr = client.exec_command(cmd)
out = stdout.read().decode("utf-8", errors="replace").strip()
err = stderr.read().decode("utf-8", errors="replace").strip()
return out, err
def main():
print("=== [1/3] 连接线上服务器 ===")
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(HOST, port=PORT, username=USER, password=PASSWORD, timeout=30)
print(f"✓ 成功连接 {HOST}")
sftp = client.open_sftp()
print("✓ SFTP 通道已建立")
print("\n=== [2/3] 上传最新修改文件 ===")
for rel_path in SYNC_FILES:
local_path = os.path.join(LOCAL_ROOT, rel_path.replace("/", "\\"))
remote_path = f"{REMOTE_ROOT}/{rel_path}"
if not os.path.exists(local_path):
print(f" ✗ 本地文件缺失: {local_path}")
continue
remote_dir = os.path.dirname(remote_path)
ssh_exec(client, f"mkdir -p '{remote_dir}'")
sftp.put(local_path, remote_path)
ssh_exec(client, f"chown www:www '{remote_path}'")
file_size = os.path.getsize(local_path)
print(f" ✓ 已同步: {rel_path} ({file_size} 字节)")
sftp.close()
print("\n=== [3/3] 清理缓存与服务自检 ===")
ssh_exec(client, f"rm -rf {REMOTE_ROOT}/runtime/temp/* {REMOTE_ROOT}/runtime/cache/*")
print("✓ 线上 ThinkPHP 运行时缓存清理完成")
# 服务健康自检
check_urls = [
("API 信息流接口", "https://fenleixinxi.gzyakj.com.cn/api/v1/home/feed"),
("API 分类接口", "https://fenleixinxi.gzyakj.com.cn/api/v1/home/categories"),
("API 提现详情接口", "https://fenleixinxi.gzyakj.com.cn/api/v1/distribution/withdraw-detail"),
("后台登录页面", "https://fenleixinxi.gzyakj.com.cn/s.php/index/login"),
]
for name, url in check_urls:
cmd = f"curl -s -o /dev/null -w '%{{http_code}}' -k '{url}'"
code, _ = ssh_exec(client, cmd)
print(f" {name}: HTTP {code}")
client.close()
print("\n✓ 最新代码已全部部署至线上服务器!")
if __name__ == "__main__":
main()