feat: 新增师傅入驻审核与接单状态联动功能
- 新增师傅资质审核模块及权限 - 未审核通过的师傅默认禁用接单状态 - 新增售后退款申诉功能与相关界面 - 新增用户钱包管理及充值功能 - 更新服务定价矩阵相关数据库结构 - 修复微信支付证书验证问题
这个提交包含在:
37
scripts/add_audit_rule.py
普通文件
37
scripts/add_audit_rule.py
普通文件
@@ -0,0 +1,37 @@
|
||||
import pymysql
|
||||
import paramiko
|
||||
import time
|
||||
|
||||
now = int(time.time())
|
||||
|
||||
def insert_rule(conn, is_remote=False):
|
||||
cur = conn.cursor()
|
||||
cur.execute("SELECT id FROM fa_auth_rule WHERE name = 'master/audit'")
|
||||
row = cur.fetchone()
|
||||
if not row:
|
||||
sql = f"INSERT INTO fa_auth_rule (pid, name, title, icon, `condition`, remark, ismenu, createtime, updatetime, weigh, status) VALUES (125, 'master/audit', '审核', 'fa fa-check-square-o', '', '师傅入驻资质审核', 0, {now}, {now}, 0, 'normal')"
|
||||
cur.execute(sql)
|
||||
rule_id = cur.lastrowid
|
||||
print(f"[{'Remote' if is_remote else 'Local'}] Inserted master/audit rule id: {rule_id}")
|
||||
else:
|
||||
print(f"[{'Remote' if is_remote else 'Local'}] master/audit rule already exists, id: {row[0]}")
|
||||
conn.commit()
|
||||
|
||||
# Local
|
||||
conn_local = pymysql.connect(host='127.0.0.1', user='yjyf', password='4bRz2NYz6pDhsCk4', database='yjyf', port=3306)
|
||||
insert_rule(conn_local, False)
|
||||
conn_local.close()
|
||||
|
||||
# Remote
|
||||
ssh = paramiko.SSHClient()
|
||||
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
ssh.connect('8.137.181.63', port=22, username='root', password='liyanxia@6688', timeout=10)
|
||||
stdin, stdout, stderr = ssh.exec_command(f'mysql -uyjyf -pyjyf yjyf -e "SELECT id FROM fa_auth_rule WHERE name = \'master/audit\';"')
|
||||
out = stdout.read().decode('utf-8', errors='ignore')
|
||||
if 'master/audit' not in out and not any(line.strip().isdigit() for line in out.splitlines()):
|
||||
cmd = f'mysql -uyjyf -pyjyf yjyf -e "INSERT INTO fa_auth_rule (pid, name, title, icon, \\`condition\\`, remark, ismenu, createtime, updatetime, weigh, status) VALUES (125, \'master/audit\', \'审核\', \'fa fa-check-square-o\', \'\', \'师傅入驻资质审核\', 0, {now}, {now}, 0, \'normal\');"'
|
||||
ssh.exec_command(cmd)
|
||||
print("[Remote] Inserted master/audit rule")
|
||||
else:
|
||||
print("[Remote] master/audit rule already exists")
|
||||
ssh.close()
|
||||
37
scripts/deploy_audit_files.py
普通文件
37
scripts/deploy_audit_files.py
普通文件
@@ -0,0 +1,37 @@
|
||||
import paramiko
|
||||
import os
|
||||
|
||||
files_to_sync = [
|
||||
('server/application/admin/controller/Master.php', '/www/wwwroot/yjyf.gzyakj.com.cn/application/admin/controller/Master.php'),
|
||||
('server/application/admin/view/master/index.html', '/www/wwwroot/yjyf.gzyakj.com.cn/application/admin/view/master/index.html'),
|
||||
('server/application/admin/view/master/audit.html', '/www/wwwroot/yjyf.gzyakj.com.cn/application/admin/view/master/audit.html'),
|
||||
('server/application/admin/view/master/detail.html', '/www/wwwroot/yjyf.gzyakj.com.cn/application/admin/view/master/detail.html'),
|
||||
('server/public/assets/js/backend/master.js', '/www/wwwroot/yjyf.gzyakj.com.cn/public/assets/js/backend/master.js'),
|
||||
('server/application/api/controller/Master.php', '/www/wwwroot/yjyf.gzyakj.com.cn/application/api/controller/Master.php'),
|
||||
]
|
||||
|
||||
print("Connecting to 8.137.181.63...")
|
||||
ssh = paramiko.SSHClient()
|
||||
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
ssh.connect('8.137.181.63', port=22, username='root', password='liyanxia@6688', timeout=10)
|
||||
sftp = ssh.open_sftp()
|
||||
|
||||
for local_path, remote_path in files_to_sync:
|
||||
local_abs = os.path.abspath(local_path)
|
||||
if not os.path.exists(local_abs):
|
||||
print(f"Error: {local_abs} not found!")
|
||||
continue
|
||||
# ensure remote dir
|
||||
remote_dir = os.path.dirname(remote_path).replace('\\', '/')
|
||||
ssh.exec_command(f'mkdir -p {remote_dir}')
|
||||
sftp.put(local_abs, remote_path)
|
||||
print(f"Synced: {local_path} -> {remote_path}")
|
||||
|
||||
sftp.close()
|
||||
|
||||
# 清理 remote runtime 缓存
|
||||
ssh.exec_command('rm -rf /www/wwwroot/yjyf.gzyakj.com.cn/runtime/cache/*')
|
||||
ssh.exec_command('rm -rf /www/wwwroot/yjyf.gzyakj.com.cn/runtime/temp/*')
|
||||
ssh.exec_command('chown -R www:www /www/wwwroot/yjyf.gzyakj.com.cn')
|
||||
print("Cache cleared and permissions fixed.")
|
||||
ssh.close()
|
||||
8
scripts/inspect_master.py
普通文件
8
scripts/inspect_master.py
普通文件
@@ -0,0 +1,8 @@
|
||||
import pymysql
|
||||
|
||||
conn = pymysql.connect(host='127.0.0.1', user='yjyf', password='4bRz2NYz6pDhsCk4', database='yjyf', port=3306)
|
||||
cur = conn.cursor(pymysql.cursors.DictCursor)
|
||||
cur.execute("SELECT id, pid, name, title, ismenu FROM fa_auth_rule WHERE name LIKE '%master%'")
|
||||
rules = cur.fetchall()
|
||||
for r in rules:
|
||||
print(r)
|
||||
54
scripts/run_phase26_migration.py
普通文件
54
scripts/run_phase26_migration.py
普通文件
@@ -0,0 +1,54 @@
|
||||
import pymysql
|
||||
import paramiko
|
||||
|
||||
sql_commands = [
|
||||
"ALTER TABLE `fa_master` MODIFY COLUMN `work_status` enum('off','on') NOT NULL DEFAULT 'off' COMMENT '接单出工状态:off=暂停,on=听单接单中';",
|
||||
"UPDATE `fa_master` SET `work_status` = 'off' WHERE `verify_status` != 'pass';",
|
||||
]
|
||||
|
||||
alter_audittime = "ALTER TABLE `fa_master` ADD COLUMN `audittime` bigint(16) NULL DEFAULT NULL COMMENT '审核完成时间戳' AFTER `audit_msg`;"
|
||||
alter_admin_id = "ALTER TABLE `fa_master` ADD COLUMN `audit_admin_id` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '审核管理员ID' AFTER `audittime`;"
|
||||
|
||||
print("1. Migrating Local DB...")
|
||||
conn = pymysql.connect(host='127.0.0.1', user='yjyf', password='4bRz2NYz6pDhsCk4', database='yjyf', port=3306)
|
||||
cur = conn.cursor()
|
||||
for sql in sql_commands:
|
||||
cur.execute(sql)
|
||||
print("Executed:", sql[:50])
|
||||
|
||||
# check columns
|
||||
cur.execute("SHOW COLUMNS FROM `fa_master` LIKE 'audittime'")
|
||||
if not cur.fetchall():
|
||||
cur.execute(alter_audittime)
|
||||
print("Added audittime")
|
||||
cur.execute("SHOW COLUMNS FROM `fa_master` LIKE 'audit_admin_id'")
|
||||
if not cur.fetchall():
|
||||
cur.execute(alter_admin_id)
|
||||
print("Added audit_admin_id")
|
||||
conn.commit()
|
||||
|
||||
cur.execute("SELECT id, realname, mobile, work_status, verify_status FROM fa_master WHERE verify_status != 'pass'")
|
||||
print("Local non-pass masters now:", cur.fetchall())
|
||||
conn.close()
|
||||
|
||||
print("2. Migrating Remote DB (8.137.181.63)...")
|
||||
try:
|
||||
ssh = paramiko.SSHClient()
|
||||
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
ssh.connect('8.137.181.63', port=22, username='root', password='liyanxia@6688', timeout=10)
|
||||
|
||||
stdin, stdout, stderr = ssh.exec_command("mysql -uyjyf -pyjyf yjyf -e \"UPDATE fa_master SET work_status = 'off' WHERE verify_status != 'pass';\"")
|
||||
err = stderr.read().decode('utf-8', errors='ignore')
|
||||
if err:
|
||||
print("Update err:", err)
|
||||
|
||||
stdin, stdout, stderr = ssh.exec_command("mysql -uyjyf -pyjyf yjyf -e \"ALTER TABLE fa_master MODIFY COLUMN work_status enum('off','on') NOT NULL DEFAULT 'off';\"")
|
||||
err = stderr.read().decode('utf-8', errors='ignore')
|
||||
if err:
|
||||
print("Alter err:", err)
|
||||
|
||||
stdin, stdout, stderr = ssh.exec_command("mysql -uyjyf -pyjyf yjyf -e \"SELECT id, realname, mobile, work_status, verify_status FROM fa_master WHERE verify_status != 'pass';\"")
|
||||
print("Remote non-pass masters now:\n" + stdout.read().decode('utf-8', errors='ignore'))
|
||||
ssh.close()
|
||||
except Exception as e:
|
||||
print("SSH migration error:", e)
|
||||
20
scripts/test_master_audit_api.py
普通文件
20
scripts/test_master_audit_api.py
普通文件
@@ -0,0 +1,20 @@
|
||||
import pymysql
|
||||
|
||||
conn = pymysql.connect(host='127.0.0.1', user='yjyf', password='4bRz2NYz6pDhsCk4', database='yjyf', port=3306)
|
||||
cur = conn.cursor(pymysql.cursors.DictCursor)
|
||||
|
||||
# 验证未审核师傅的状态
|
||||
cur.execute("SELECT id, realname, mobile, work_status, verify_status FROM fa_master WHERE verify_status = 'pending'")
|
||||
rows = cur.fetchall()
|
||||
print("Pending masters:")
|
||||
for r in rows:
|
||||
print(r)
|
||||
assert r['work_status'] == 'off', "待审核师傅出工状态必须是 off!"
|
||||
|
||||
# 验证 auth_rule 表中的 master/audit
|
||||
cur.execute("SELECT * FROM fa_auth_rule WHERE name = 'master/audit'")
|
||||
rule = cur.fetchone()
|
||||
print("Auth rule master/audit:", rule)
|
||||
assert rule is not None, "必须存在 master/audit 权限规则!"
|
||||
|
||||
print("All tests passed!")
|
||||
在新工单中引用
屏蔽一个用户