This commit is contained in:
2025-12-19 13:18:40 +08:00
parent 157cbd2602
commit 376e5abd39
4 changed files with 593 additions and 170 deletions
+12 -65
View File
@@ -372,79 +372,26 @@ class JX3Service:
return_data = self._init_return_data()
# 1. 查询魔盒获取外观名称 (jx3box_exterior)
params_search = {"keyword": Name}
search_data: Optional[Dict[str, Any]] = await self._base_request("jx3box_exterior", "GET", params=params_search)
showName = ""
searchId = None
# 获取配置中的 Token
token = self._config.get("jx3api_token", "")
if token == "":
return_data["msg"] = "系统未配置API访问Token"
return return_data
# 2. 确定外观名称和 ID
# 从 DB 查找名称和 ID
logger.info("尝试从数据库查询外观信息")
try:
sql = "SELECT showName, searchId FROM searchdata WHERE name LIKE ? OR showName LIKE ?"
sqldata = await self._db.fetch_one(sql, (f"%{Name}%", f"%{Name}%"))
if sqldata:
showName = sqldata["showName"]
searchId = sqldata["searchId"]
else:
raise ValueError("DB did not find data.")
except Exception as e:
logger.error(f"获取外观信息错误: {e}")
return_data["msg"] = "数据库未找到该外观信息,尝试从魔盒查询"
logger.info("尝试从魔盒查询外观信息")
params_search = {"keyword": Name}
search_data: Optional[Dict[str, Any]] = await self._base_request("jx3box_exterior", "GET", params=params_search)
# 从 API 获取名称
showName = search_data["list"][0].get("name", "")
# 进一步从 DB 查找 ID
try:
sql = "SELECT searchId FROM searchdata WHERE showName=?"
sqldata = await self._db.fetch_one(sql, (showName,))
searchId = sqldata["searchId"] if sqldata else None
except Exception as e:
logger.warning(f"从 DB 获取外观ID错误: {e}") # 警告而非错误,因为可能数据库同步失败
params_search = {"name": Name,"token": token}
search_data: Optional[Dict[str, Any]] = await self._base_request("jx3_wujia", "GET", params=params_search)
if not showName or not searchId:
return_data["msg"] = "无法确定外观名称或ID"
if not search_data:
return_data["msg"] = "未找到改外观"
return return_data
return_data["data"]["showName"] = showName
return_data["data"]["searchId"] = searchId
showName = search_data.get("name", "")
logger.info(showName)
# 3. 获取外观详细数据 (aijx3_GoodsDetail)
params_detail = {"goodsName": showName}
detail_data: Optional[Dict[str, Any]] = await self._base_request("aijx3_GoodsDetail", "POST", params=params_detail)
if not detail_data:
return_data["msg"] = "获取外观详细数据失败"
return return_data
# 提取外观详细数据
try:
imgs = detail_data.get("imgs", [])
return_data["data"].update({
"goodsDesc": detail_data.get("goodsDesc", "无描述"),
"publishTime": detail_data.get("publishTime", "无价格"),
"priceNum": detail_data.get("priceNum", 0),
"goodsId": detail_data.get("goodsId", "无数据"),
"imgs": imgs[0] if imgs and isinstance(imgs, list) else "",
"goodsAlias": detail_data.get("goodsAlias", "无别名"),
})
except Exception as e:
logger.error(f"提取外观详细数据失败: {e}")
return_data["msg"] = "提取外观详细数据失败"
return return_data
# 4. 查询万宝楼数据(公示和在售)
wbl_data = await self._get_wbl_data(showName)
if wbl_data:
return_data["data"]["wblgs"] = wbl_data["wblgs"]
return_data["data"]["wblzs"] = wbl_data["wblzs"]
return_data["msg"] = "获取万宝楼数据完成"
else:
logger.warning("万宝楼数据获取失败")
return_data["data"] = search_data
# 5. 加载模板
try:
+10
View File
@@ -206,5 +206,15 @@
"limit": "10",
"token":""
}
},
"jx3_wujia":{
"url":"https://www.jx3api.com/data/trade/records",
"method":"GET",
"description":"此接口用于统计指定物品的黑市价格信息,包括成交、出售、收购等详细记录。",
"params":{
"server": "梦江南",
"name": "秃盒",
"token":""
}
}
}
+261 -46
View File
@@ -2,98 +2,313 @@
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>王者荣耀 — 仇人列表</title>
<title>{{ name }} - 万宝楼行情</title>
<style>
body {
font-family: 'Microsoft YaHei', Arial, sans-serif;
font-family: "Microsoft YaHei", Arial, sans-serif;
background: #f1f2f6;
margin: 0;
padding: 20px;
}
.container {
max-width: 1000px;
max-width: 1400px;
margin: 0 auto;
text-align: center; /* ★ 让容器内标题更自然居中 */
color: #222;
text-align: center;
}
h1 {
font-size: 32px;
margin-bottom: 25px;
color: #222;
font-weight: 800;
text-align: center; /* ★ 强制居中 */
margin-bottom: 12px;
}
.goods-image {
width: 100%;
border-radius: 16px;
box-shadow: 0 6px 24px rgba(0,0,0,0.12);
margin-bottom: 14px;
}
.goods-desc {
font-size: 16px;
color: #444;
margin-bottom: 10px;
}
.meta-row {
display: flex;
justify-content: center;
gap: 40px;
font-size: 18px;
margin-bottom: 30px;
}
.meta-row .price {
color: #d93939;
font-weight: 800;
}
.table-wrapper {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 20px;
}
.table-card {
width: 100%;
}
.table-title {
font-size: 20px;
font-weight: 700;
margin-bottom: 8px;
text-align: center;
}
table {
width: 100%;
border-collapse: collapse;
background: white;
background: #ffffff;
border-radius: 12px;
overflow: hidden;
box-shadow: 0 4px 16px rgba(0,0,0,0.08);
margin-top: 10px;
text-align: left; /* 不影响表格内容 */
text-align: left;
}
thead {
background: #d93939;
color: white;
font-size: 18px;
color: #ffffff;
font-size: 16px;
}
th, td {
padding: 14px 12px;
padding: 12px 10px;
border-bottom: 1px solid #eee;
font-size: 16px;
font-size: 15px;
}
tbody tr:hover {
background: #fff2f2;
}
.text-col {
max-width: 360px;
line-height: 1.5em;
word-break: break-word;
.server-col {
font-weight: 600;
color: #333;
}
.price-col {
color: #d93939;
font-weight: 700;
}
</style>
</head>
<body>
<div class="container">
<h1>王者荣耀 — 仇人列表</h1>
<table>
<thead>
<tr>
<th>ID</th>
<th>名称</th>
<th>英雄</th>
<th>分路</th>
<th>记录者</th>
<th>时间</th>
<th>描述</th>
</tr>
</thead>
<h1>{{ name }} ({{ alias }})</h1>
<tbody>
{% for m in lists %}
<tr>
<td>{{ m.id }}</td>
<td>{{ m.name }}</td>
<td>{{ m.hero }}</td>
<td>{{ m.fenglu }}</td>
<td>{{ m.user }}</td>
<td>{{ m.time }}</td>
<td class="text-col">{{ m.text }}</td>
</tr>
{% endfor %}
</tbody>
</table>
<img src="{{ view }}" alt="{{ name }}" class="goods-image">
<p class="goods-desc">{{ desc }}</p>
<div class="meta-row">
<span>发布时间:{{ date }}</span>
<span class="price">参考价格:{{ cost }}</span>
</div>
<div class="table-wrapper">
<!-- 1 万宝楼公示 -->
<div class="table-card">
<div class="table-title">万宝楼公示</div>
<table>
<thead>
<tr>
<th>时间</th>
<th>服务器</th>
<th>价格</th>
<th>状态</th>
</tr>
</thead>
<tbody>
{% for item in list[3] %}
<tr>
<td class="server-col">{{ item.date }}</td>
<td class="server-col">{{ item.server }}</td>
<td class="price-col">{{ item.value }}</td>
<td class="server-col"> 公示 </td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<!-- 2 万宝楼在售 -->
<div class="table-card">
<div class="table-title">万宝楼在售</div>
<table>
<thead>
<tr>
<th>时间</th>
<th>服务器</th>
<th>价格</th>
<th>状态</th>
</tr>
</thead>
<tbody>
{% for item in list[4] %}
<tr>
<td class="server-col">{{ item.date }}</td>
<td class="server-col">{{ item.server }}</td>
<td class="price-col">{{ item.value }}</td>
<td class="server-col"> 在售 </td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<!-- 3 查询区服 -->
<div class="table-card">
<div class="table-title">查询区服</div>
<table>
<thead>
<tr>
<th>时间</th>
<th>服务器</th>
<th>价格</th>
<th>状态</th>
</tr>
</thead>
<tbody>
{% for item in list[5] %}
<tr>
<td class="server-col">{{ item.date }}</td>
<td class="server-col">{{ item.server }}</td>
<td class="price-col">{{ item.value }}</td>
<td class="server-col">
{% if item.source == 1 %}出售
{% elif item.source == 2 %}收购
{% elif item.source == 3 %}想出
{% elif item.source == 4 %}想收
{% elif item.source == 5 %}成交
{% elif item.source == 6 %}正出
{% else %}未知
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<!-- 4 电信区 -->
<div class="table-card">
<div class="table-title">电信区</div>
<table>
<thead>
<tr>
<th>时间</th>
<th>服务器</th>
<th>价格</th>
<th>状态</th>
</tr>
</thead>
<tbody>
{% for item in list[0] %}
<tr>
<td class="server-col">{{ item.date }}</td>
<td class="server-col">{{ item.server }}</td>
<td class="price-col">{{ item.value }}</td>
<td class="server-col">
{% if item.source == 1 %}出售
{% elif item.source == 2 %}收购
{% elif item.source == 3 %}想出
{% elif item.source == 4 %}想收
{% elif item.source == 5 %}成交
{% elif item.source == 6 %}正出
{% else %}未知
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<!-- 5 双线区 -->
<div class="table-card">
<div class="table-title">双线区</div>
<table>
<thead>
<tr>
<th>时间</th>
<th>服务器</th>
<th>价格</th>
<th>状态</th>
</tr>
</thead>
<tbody>
{% for item in list[1] %}
<tr>
<td class="server-col">{{ item.date }}</td>
<td class="server-col">{{ item.server }}</td>
<td class="price-col">{{ item.value }}</td>
<td class="server-col">
{% if item.source == 1 %}出售
{% elif item.source == 2 %}收购
{% elif item.source == 3 %}想出
{% elif item.source == 4 %}想收
{% elif item.source == 5 %}成交
{% elif item.source == 6 %}正出
{% else %}未知
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<!-- 6 无界区 -->
<div class="table-card">
<div class="table-title">无界区</div>
<table>
<thead>
<tr>
<th>时间</th>
<th>服务器</th>
<th>价格</th>
<th>状态</th>
</tr>
</thead>
<tbody>
{% for item in list[2] %}
<tr>
<td class="server-col">{{ item.date }}</td>
<td class="server-col">{{ item.server }}</td>
<td class="price-col">{{ item.value }}</td>
<td class="server-col">
{% if item.source == 1 %}出售
{% elif item.source == 2 %}收购
{% elif item.source == 3 %}想出
{% elif item.source == 4 %}想收
{% elif item.source == 5 %}成交
{% elif item.source == 6 %}正出
{% else %}未知
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
+306 -55
View File
@@ -1,65 +1,316 @@
<div style="max-width: 800px; margin: 0 auto; font-family: 'Microsoft YaHei', sans-serif; color: #000; text-align: center;">
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>{{ name }} - 万宝楼行情</title>
<!-- 商品基本信息 -->
<h1 style="margin-bottom: 5px;">{{ showName }} ({{ goodsAlias }})</h1>
<img src="{{ imgs }}" alt="{{ showName }}" style="width: 100%; max-width: 600px; margin-bottom: 8px;">
<p style="margin: 4px 0;">{{ goodsDesc }}</p>
<p style="margin: 4px 0;"><strong>发布时间:</strong> {{ publishTime.split('T')[0] if publishTime else '未知' }}</p>
<p style="margin: 4px 0;"><strong>参考价格:</strong> {{ priceNum }} 元</p>
<style>
body {
font-family: "Microsoft YaHei", Arial, sans-serif;
background: #f1f2f6;
margin: 0;
padding: 20px;
}
<!-- 双列表格 -->
<div style="display: flex; gap: 10px; margin-top: 15px; flex-wrap: wrap; justify-content: center;">
.container {
max-width: 1400px;
margin: 0 auto;
color: #222;
text-align: center;
}
<!-- 万宝楼公示 -->
<div style="flex: 1; min-width: 300px; border:1px solid #000; overflow:hidden;">
<div style="padding:4px; font-weight:bold; text-align:center;">万宝楼公示</div>
<div style="overflow-x:auto;">
<table style="width:100%; border-collapse:collapse; margin:0 auto; text-align:center; font-size:0.9em;">
<thead>
<tr>
<th style="border:1px solid #000; padding:2px;">剩余时间</th>
<th style="border:1px solid #000; padding:2px;">服务器</th>
<th style="border:1px solid #000; padding:2px;">价格</th>
</tr>
</thead>
<tbody>
{% for item in wblgs %}
<tr>
<td style="border:1px solid #000; padding:2px;">{{ item.replyTime }}</td>
<td style="border:1px solid #000; padding:2px;">{{ item.belongQf2 }}</td>
<td style="border:1px solid #000; padding:2px;">{{ item.priceNum }}元</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
h1 {
font-size: 32px;
font-weight: 800;
margin-bottom: 12px;
}
.goods-image {
width: 100%;
border-radius: 16px;
box-shadow: 0 6px 24px rgba(0,0,0,0.12);
margin-bottom: 14px;
}
.goods-desc {
font-size: 16px;
color: #444;
margin-bottom: 10px;
}
.meta-row {
display: flex;
justify-content: center;
gap: 40px;
font-size: 18px;
margin-bottom: 30px;
}
.meta-row .price {
color: #d93939;
font-weight: 800;
}
.table-wrapper {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 20px;
}
.table-card {
width: 100%;
}
.table-title {
font-size: 20px;
font-weight: 700;
margin-bottom: 8px;
text-align: center;
}
table {
width: 100%;
border-collapse: collapse;
background: #ffffff;
border-radius: 12px;
overflow: hidden;
box-shadow: 0 4px 16px rgba(0,0,0,0.08);
text-align: left;
}
thead {
background: #d93939;
color: #ffffff;
font-size: 16px;
}
th, td {
padding: 12px 10px;
border-bottom: 1px solid #eee;
font-size: 15px;
}
tbody tr:hover {
background: #fff2f2;
}
.server-col {
font-weight: 600;
}
.price-col {
color: #d93939;
font-weight: 700;
}
</style>
</head>
<body>
<div class="container">
<h1>{{ name }} ({{ alias }})</h1>
<img src="{{ view }}" alt="{{ name }}" class="goods-image">
<p class="goods-desc">{{ desc }}</p>
<div class="meta-row">
<span>发布时间:{{ date }}</span>
<span class="price">参考价格:{{ cost }} 元</span>
</div>
<div class="table-wrapper">
<!-- 1 万宝楼公示 -->
<div class="table-card">
<div class="table-title">万宝楼公示</div>
<table>
<thead>
<tr>
<th>时间</th>
<th>服务器</th>
<th>价格</th>
<th>状态</th>
</tr>
</thead>
<tbody>
{% for item in list[3] %}
<tr>
<td class="server-col">{{ item.date }}</td>
<td class="server-col">{{ item.server }}</td>
<td class="price-col">{{ item.value }}</td>
<td class="server-col"> 公示 </td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<!-- 万宝楼在售 -->
<div style="flex: 1; min-width: 300px; border:1px solid #000; overflow:hidden;">
<div style="padding:4px; font-weight:bold; text-align:center;">万宝楼在售</div>
<div style="overflow-x:auto;">
<table style="width:100%; border-collapse:collapse; margin:0 auto; text-align:center; font-size:0.9em;">
<thead>
<tr>
<th style="border:1px solid #000; padding:2px;">剩余时间</th>
<th style="border:1px solid #000; padding:2px;">服务器</th>
<th style="border:1px solid #000; padding:2px;">价格</th>
</tr>
</thead>
<tbody>
{% for item in wblzs %}
<tr>
<td style="border:1px solid #000; padding:2px;">{{ item.replyTime }}</td>
<td style="border:1px solid #000; padding:2px;">{{ item.belongQf2 }}</td>
<td style="border:1px solid #000; padding:2px;">{{ item.priceNum }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<!-- 2 万宝楼在售 -->
<div class="table-card">
<div class="table-title">万宝楼在售</div>
<table>
<thead>
<tr>
<th>时间</th>
<th>服务器</th>
<th>价格</th>
<th>状态</th>
</tr>
</thead>
<tbody>
{% for item in list[4] %}
<tr>
<td class="server-col">{{ item.date }}</td>
<td class="server-col">{{ item.server }}</td>
<td class="price-col">{{ item.value }}</td>
<td class="server-col"> 在售 </td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<!-- 3 查询区服 -->
<div class="table-card">
<div class="table-title">查询区服</div>
<table>
<thead>
<tr>
<th>时间</th>
<th>服务器</th>
<th>价格</th>
<th>状态</th>
</tr>
</thead>
<tbody>
{% for item in list[5] %}
<tr>
<td class="server-col">{{ item.date }}</td>
<td class="server-col">{{ item.server }}</td>
<td class="price-col">{{ item.value }}</td>
<td class="server-col">
{% if item.source == 1 %}出售
{% elif item.source == 2 %}收购
{% elif item.source == 3 %}想出
{% elif item.source == 4 %}想收
{% elif item.source == 5 %}成交
{% elif item.source == 6 %}正出
{% else %}未知
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<!-- 4 电信区 -->
<div class="table-card">
<div class="table-title">电信区</div>
<table>
<thead>
<tr>
<th>时间</th>
<th>服务器</th>
<th>价格</th>
<th>状态</th>
</tr>
</thead>
<tbody>
{% for item in list[0] %}
<tr>
<td class="server-col">{{ item.date }}</td>
<td class="server-col">{{ item.server }}</td>
<td class="price-col">{{ item.value }}</td>
<td class="server-col">
{% if item.source == 1 %}出售
{% elif item.source == 2 %}收购
{% elif item.source == 3 %}想出
{% elif item.source == 4 %}想收
{% elif item.source == 5 %}成交
{% elif item.source == 6 %}正出
{% else %}未知
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<!-- 5 双线区 -->
<div class="table-card">
<div class="table-title">双线区</div>
<table>
<thead>
<tr>
<th>时间</th>
<th>服务器</th>
<th>价格</th>
<th>状态</th>
</tr>
</thead>
<tbody>
{% for item in list[1] %}
<tr>
<td class="server-col">{{ item.date }}</td>
<td class="server-col">{{ item.server }}</td>
<td class="price-col">{{ item.value }}</td>
<td class="server-col">
{% if item.source == 1 %}出售
{% elif item.source == 2 %}收购
{% elif item.source == 3 %}想出
{% elif item.source == 4 %}想收
{% elif item.source == 5 %}成交
{% elif item.source == 6 %}正出
{% else %}未知
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<!-- 6 无界区 -->
<div class="table-card">
<div class="table-title">无界区</div>
<table>
<thead>
<tr>
<th>时间</th>
<th>服务器</th>
<th>价格</th>
<th>状态</th>
</tr>
</thead>
<tbody>
{% for item in list[2] %}
<tr>
<td class="server-col">{{ item.date }}</td>
<td class="server-col">{{ item.server }}</td>
<td class="price-col">{{ item.value }}</td>
<td class="server-col">
{% if item.source == 1 %}出售
{% elif item.source == 2 %}收购
{% elif item.source == 3 %}想出
{% elif item.source == 4 %}想收
{% elif item.source == 5 %}成交
{% elif item.source == 6 %}正出
{% else %}未知
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</body>
</html>