docs(sxsy80): 补充文档、合同资源与数据清理脚本

- 更新前后端 sign_contract_sxsy80.pdf
- 增加 com-sxsy80 说明、数据迁移与 SQL/执行脚本
- 增加 com-xsj33 数据迁移说明与 docs 下合同源文件

Made-with: Cursor
This commit is contained in:
apple
2026-04-26 16:50:36 +08:00
parent 3c6ec4ed73
commit e7ffbbf302
9 changed files with 299 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
-- 太原树英商贸 / yangtangyoupin 数据清理
-- 依据: docs/com-sxsy80-data-imgration.md
-- 执行前请备份数据库。建议在事务中先 SELECT 核对影响行数后再 COMMIT。
SET NAMES utf8mb4;
START TRANSACTION;
SET FOREIGN_KEY_CHECKS = 0;
-- 订单类:整表清空
TRUNCATE TABLE `wa_order`;
TRUNCATE TABLE `wa_withdraw`;
TRUNCATE TABLE `eb_store_order`;
-- 寄售商品:仅保留 created_at >= 2026-04-24 且卖家 user_id 在保留名单内
DELETE FROM `wa_merchandise`
WHERE NOT (
`created_at` >= '2026-04-24 00:00:00'
AND `user_id` IN (92566,92801,92839,93004,92637,92965,93093,93096,93116,92787,93121,93129,92884,93007,93020,93094,93099,93110,92638)
);
-- 日志类:仅保留名单内 user_id
DELETE FROM `wa_selfbonus_log`
WHERE `user_id` NOT IN (92566,92801,92839,93004,92637,92965,93093,93096,93116,92787,93121,93129,92884,93007,93020,93094,93099,93110,92638);
DELETE FROM `wa_sharebonus_log`
WHERE `user_id` NOT IN (92566,92801,92839,93004,92637,92965,93093,93096,93116,92787,93121,93129,92884,93007,93020,93094,93099,93110,92638);
DELETE FROM `wa_coupon_log`
WHERE `user_id` NOT IN (92566,92801,92839,93004,92637,92965,93093,93096,93116,92787,93121,93129,92884,93007,93020,93094,93099,93110,92638);
-- 积分记录表实际字段为 uid非 user_id
DELETE FROM `eb_user_integral_record`
WHERE `uid` NOT IN (92566,92801,92839,93004,92637,92965,93093,93096,93116,92787,93121,93129,92884,93007,93020,93094,93099,93110,92638);
-- 商城用户:保留 uid 在名单内
DELETE FROM `eb_user`
WHERE `uid` NOT IN (92566,92801,92839,93004,92637,92965,93093,93096,93116,92787,93121,93129,92884,93007,93020,93094,93099,93110,92638);
-- WA 用户:保留 id 在名单内
DELETE FROM `wa_users`
WHERE `id` NOT IN (92566,92801,92839,93004,92637,92965,93093,93096,93116,92787,93121,93129,92884,93007,93020,93094,93099,93110,92638);
SET FOREIGN_KEY_CHECKS = 1;
COMMIT;

View File

@@ -0,0 +1,88 @@
#!/usr/bin/env python3
"""执行 com-sxsy80-data-cleanup.sql。
需安装: pip install pymysql
连接信息见 docs/com-sxsy80-data-imgration.md通过环境变量传入避免把密码写进仓库
export YTYP_DB_HOST=106.14.132.80
export YTYP_DB_USER=yangtangyoupin
export YTYP_DB_PASSWORD='...'
export YTYP_DB_NAME=yangtangyoupin
python3 docs/sql/run_com_sxsy80_cleanup.py
"""
from __future__ import annotations
import os
import pathlib
import sys
import pymysql
ROOT = pathlib.Path(__file__).resolve().parents[2]
SQL_FILE = ROOT / "docs" / "sql" / "com-sxsy80-data-cleanup.sql"
def load_statements(path: pathlib.Path) -> list[str]:
text = path.read_text(encoding="utf-8")
stmts: list[str] = []
buf: list[str] = []
for line in text.splitlines():
s = line.strip()
if s.startswith("--") or not line.strip():
continue
buf.append(line)
if ";" in line:
chunk = "\n".join(buf).strip()
if chunk:
stmts.append(chunk)
buf = []
if buf:
chunk = "\n".join(buf).strip()
if chunk:
stmts.append(chunk)
return stmts
def main() -> int:
host = os.environ.get("YTYP_DB_HOST", "106.14.132.80")
user = os.environ.get("YTYP_DB_USER", "yangtangyoupin")
password = os.environ.get("YTYP_DB_PASSWORD")
database = os.environ.get("YTYP_DB_NAME", "yangtangyoupin")
if not password:
print("请设置环境变量 YTYP_DB_PASSWORD见脚本头部说明", file=sys.stderr)
return 1
if not SQL_FILE.is_file():
print("missing", SQL_FILE, file=sys.stderr)
return 1
statements = load_statements(SQL_FILE)
conn = pymysql.connect(
host=host,
user=user,
password=password,
database=database,
charset="utf8mb4",
autocommit=False,
)
try:
with conn.cursor() as cur:
for i, sql in enumerate(statements, 1):
cur.execute(sql)
head = sql.split()[0].upper()
if head == "DELETE" and cur.rowcount >= 0:
print(f"[{i}] DELETE … rowcount={cur.rowcount}")
else:
print(f"[{i}] ok")
conn.commit()
print("COMMIT ok")
except Exception as e:
conn.rollback()
print("ROLLBACK:", e, file=sys.stderr)
raise
finally:
conn.close()
return 0
if __name__ == "__main__":
raise SystemExit(main())