modified: amazon/__pycache__/approve.cpython-39.pyc

modified:   amazon/__pycache__/main.cpython-39.pyc
	modified:   amazon/__pycache__/match_action.cpython-39.pyc
	new file:   amazon/__pycache__/price_match.cpython-39.pyc
	modified:   amazon/__pycache__/tool.cpython-39.pyc
	modified:   amazon/approve.py
	new file:   amazon/asin_status.py
	modified:   amazon/main.py
	modified:   amazon/price_match.py
	new file:   "amazon/price_match_\346\227\247.py"
	modified:   amazon/tool.py
	modified:   assets/convert.js
	modified:   assets/dedupe.js
	modified:   assets/delete-brand.js
	modified:   assets/split.js
	modified:   new_web_source/convert.html
	modified:   new_web_source/dedupe.html
	modified:   new_web_source/delete-brand.html
	modified:   new_web_source/split.html
	deleted:    web_source/admin.html
	deleted:    "web_source/brand - \345\211\257\346\234\254.html"
	deleted:    "web_source/brand-\346\227\247.html"
	deleted:    web_source/brand.html
	deleted:    web_source/home.html
	deleted:    web_source/index.html
	deleted:    web_source/login.html
This commit is contained in:
铭坤
2026-04-22 00:51:41 +08:00
parent dabb278170
commit b04b05e4da
11 changed files with 2335 additions and 217 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+9
View File
@@ -1095,6 +1095,15 @@ class ApproveTask:
for retry in range(max_retries):
try:
self.log(f"尝试切换到国家 {country_name} (第 {retry + 1}/{max_retries} 次)")
if retry > 1:
# 刷新不行就重新打开店铺
self.log("重试前重新打开店铺...")
try:
driver.close_store()
time.sleep(3)
driver.open_shop(shop_name)
except Exception as e:
self.log(f"关闭重新打开店铺: {str(e)}", "WARNING")
# 如果不是第一次尝试,先刷新页面
if retry > 0:
View File
+5 -3
View File
@@ -8,6 +8,7 @@ from config import JSON_TASK_QUEUE, runing_task, runing_shop, DELETE_BRAND_API_B
from amazon.del_brand import AmazoneDriver, kill_process
from amazon.approve import ApproveTask
from amazon.match_action import MatchTak
from amazon.price_match import PriceTask
from amazon.tool import get_shop_info,show_notification
@@ -53,7 +54,8 @@ class TaskMonitor:
task_type_info = {
"product-risk-resolve-run" : "产品风险审批",
"shop-match-run" : "匹配价格"
"shop-match-run" : "匹配价格",
"price-track-run" : "跟价"
}
try:
while self.running:
@@ -119,7 +121,8 @@ class TaskMonitor:
try:
TASK_INFO = {
"产品风险审批" : ApproveTask,
"匹配价格" : MatchTak
"匹配价格" : MatchTak,
"跟价" : PriceTask
}
self.log(f"线程 {id(task_data)} 开始处理产品风险审批任务...")
# 创建ApproveTask实例并处理任务
@@ -130,7 +133,6 @@ class TaskMonitor:
except Exception as e:
self.log(f"线程 {id(task_data)} 产品风险审批任务处理异常: {traceback.format_exc()}", "ERROR")
def process_task(self, task_data: Dict[str, Any]):
"""处理单个任务
+997 -206
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+46
View File
@@ -7,6 +7,7 @@ except ImportError:
import requests
from urllib.parse import quote
import re
def show_notification(message: str, message_type: str = "error"):
@@ -112,5 +113,50 @@ def get_shop_info(shop_name: str, base_url: str = "http://8.136.19.173:18080") -
def remove_special_characters(text: str) -> str:
"""
去除字符串中的特殊字符,只保留数字、小数点和负号。
例如:'£24.55' -> '24.55'
"""
# 匹配所有允许的字符:数字、小数点、负号
# 注意:负号必须位于开头才合法,但这里只做字符保留,不做格式校验
cleaned = re.sub(r'[^0-9.-]', '', text)
return cleaned
def split_currency_values(currency_str: str) -> tuple[float, float]:
"""
将包含两个货币值的字符串拆分成两个浮点数。
参数:
currency_str (str): 格式如 "€22.64 + €0.00" 的字符串,中间以 '+' 分隔,
每部分可包含任意货币符号或前缀/后缀。
返回:
tuple[float, float]: 两个数值,顺序与字符串中的出现顺序一致。
异常:
ValueError: 如果字符串不包含正好两个部分,或者任一部分中无法提取到数值。
"""
# 按第一个 '+' 分割,最多分为两部分
parts = currency_str.split('+', 1)
if len(parts) != 2:
raise ValueError("字符串必须包含两个由 '+' 分隔的部分")
# 匹配整数或浮点数(可选负号)
number_pattern = r'-?\d+(?:\.\d+)?'
values = []
for part in parts:
# 去除首尾空格
part = part.strip()
match = re.search(number_pattern, part)
if not match:
raise ValueError(f"无法从 '{part}' 中提取数值")
values.append(float(match.group()))
return tuple(values)
if __name__ == '__main__':
cu_str = "€58.44 + €0.00 匹配"
res = split_currency_values(cu_str)
print(sum(res))