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

new file:   amazon/__pycache__/asin_status.cpython-39.pyc
	modified:   amazon/__pycache__/main.cpython-39.pyc
	modified:   amazon/__pycache__/match_action.cpython-39.pyc
	modified:   amazon/__pycache__/price_match.cpython-39.pyc
	modified:   amazon/approve.py
	modified:   amazon/asin_status.py
	modified:   amazon/main.py
	modified:   amazon/match_action.py
	modified:   amazon/price_match.py
	modified:   web_source/brand.html
	modified:   web_source/templates_backup/brand.html
This commit is contained in:
铭坤
2026-04-24 23:00:59 +08:00
parent 0caf62c3d2
commit e695fd5184
10 changed files with 770 additions and 35 deletions

View File

@@ -46,18 +46,30 @@ def calculate_target_price(
# 不是自己的购物车:直接将紫鸟的总和作为"第一名"价格,强制抛入阶梯跟价逻辑
return calculate_standard_competitor_pricing(my_price, total_price)
# # 第一名是自己, 第二名 Amazon US 卖家 的情况
shop_name_1 = front_end_data.get("top_sellers")[0].get("shop_name")
shop_name_2 = front_end_data.get("top_sellers")[1].get("shop_name") if len(front_end_data.get("top_sellers")) >=2 else ""
if shop_name_1 == current_shop_name and "Amazon" in shop_name_2:
price_2 = float(front_end_data.get("top_sellers")[1].get("price")) # 实际第二名价格
diff = abs(my_price - price_2)
if diff < 5:
return price_2 -3
elif 5.0 < diff <= 8.0:
return price_2 -3
# --- Step 3: 常规核心分流逻辑 (如果没有紫鸟后台数据) ---
# 分支 A第一名是 Amazon US 卖家 (特殊强敌优先)
price_1 = float(front_end_data.get("top_sellers")[0].get("price")) # 实际第一名价格
if "Amazon." in cart_seller:
diff = abs(my_price - price_1)
if diff <= 5.0 or my_price > price_1:
return price_1 - 5.0
if diff <= 5.0 :
return None
elif 5.0 < diff <= 8.0:
return price_1 - 3.0
elif 8.0 < diff <= 12.0:
return None # 跳过,不跟价
elif diff > 8.0:
return price_1 - 6 # 跳过,不跟价
# 分支 B不是 Amazon US且目前是自己的购物车
@@ -78,7 +90,6 @@ def calculate_target_price(
else:
return None
# 分支 C不是 Amazon US也不是自己的购物车
else:
# 正常情况下的普通跟价,调用阶梯逻辑
@@ -104,9 +115,10 @@ def calculate_standard_competitor_pricing(my_current_price, target_competitor_pr
return base_target - 1.0
elif 1.5 <= diff <= 2.5:
return base_target - 1.0
elif diff > 2.5:
return my_current_price # 差距过大,跳过不跟价
elif 2.5 < diff <= 3 :
return None # 差距过大,跳过不跟价
elif diff > 3:
return base_target
@@ -586,18 +598,16 @@ class AmzonePriceMatch(AmamzonBase):
# 如果紫鸟里当前价格低于最低价则删除,否则跳过
if mode == "status" and miniprice_info.get(asin):
backend_price = float(miniprice_info.get(asin))
if float(current_price) < backend_price:
if float(current_price) <= backend_price:
# yield (asin, {
# "statu": "删除(当前价格低于最低价)",
# "deleteSkipAsin": True,
# "removeAsin": asin,
# })
yield (asin, {
"statu": "删除(当前价格低于最低价)",
"deleteSkipAsin": True,
"removeAsin": asin,
})
continue
else:
yield (asin, {
"statu": "跳过(当前价格不低于最低价)",
"deleteSkipAsin": True,
"removeAsin": asin,
"statu": "跳过(当前价格低于或等于最低价)",
"currentPrice": current_price,
"minimumPrice": bottom_price, # 最低价格
})
continue
@@ -924,6 +934,11 @@ class PriceTask:
skip_asins_by_country = shop_item.get("skip_asins_by_country",{})
asin_rows_by_country = shop_item.get("asin_rows_by_country",{})
skip_asin_details_by_country = shop_item.get("skip_asin_details_by_country",{})
minimum_price_by_country_and_asin = shop_item.get("minimum_price_by_country_and_asin",{})
if len(minimum_price_by_country_and_asin) > 0:
country_codes = minimum_price_by_country_and_asin.keys()
# 指定ASIN的情况
mode = shop_item.get("mode")
if not company_name:
@@ -955,20 +970,25 @@ class PriceTask:
# 检查是否收到暂停请求
if task_id in runing_task and runing_task[task_id].get("stop_requested", False):
self.log(f"检测到任务 {task_id} 的暂停请求,停止处理国家", "WARNING")
self.log(f"检测到任务 {task_id} 的暂停请求,停止处理国家", "ERROR")
driver.close_store()
break
skip_asin = skip_asins_by_country.get(country_code,[]) #需要跳过的asin
appoint_asin = asin_rows_by_country.get(country_code,[])
miniprice_info = {i.get('asin'):i.get('minimumPrice') for i in skip_asin_details_by_country.get(country_code,[])}
if mode == "status":
miniprice_info = {i.get('asin'):i.get('minimumPrice') for i in skip_asin_details_by_country.get(country_code,[])}
else:
miniprice_info = minimum_price_by_country_and_asin.get(country_code,{})
try:
self.process_country(driver, country_code, task_id, shop_name, risk_listing_filter,
shopMallName=shopMallName,skip_asin=skip_asin, limit=limit,
appoint_asin=appoint_asin,mode=mode,miniprice_info=miniprice_info)
appoint_asin=appoint_asin,mode=mode,miniprice_info=miniprice_info,
)
except Exception as e:
import traceback
self.log(f"处理国家 {country_code} 失败: {str(e)}", "ERROR")
self.log(traceback.format_exc(), "ERROR")
if "与页面的连接已断开" in e:
if "与页面的连接已断开" in str(e):
iskill = True
# 更新已处理国家数
if task_id in runing_task:
@@ -994,8 +1014,7 @@ class PriceTask:
def process_country(self, driver: AmzonePriceMatch, country_code: str, task_id: int, shop_name: str,
risk_listing_filter: str,shopMallName:str,skip_asin:list,appoint_asin:list,mode:str,
miniprice_info:dict={},
limit: str = None):
miniprice_info:dict={}, limit: str = None):
"""处理单个国家的审批任务
Args:
@@ -1113,7 +1132,7 @@ class PriceTask:
for i in range(max_range):
if len(appoint_asin) > i:
_shopMallName = appoint_asin[i]["shopMallName"]
ap_asin = appoint_asin[i]["shopMallName"]
ap_asin = appoint_asin[i]["asin"]
else:
_shopMallName = shopMallName
ap_asin = None
@@ -1278,11 +1297,11 @@ class PriceTask:
if __name__ == '__main__':
# 使用示例
user_info = {
"company": "rongchuang123",
"company": "尾号5578的公司115",
"username": "自动化_Robot",
"password": "#20zsg25"
}
shop_name = "魏振峰"
shop_name = "林建华"
country = "德国"
kill_process('v6')
driver = AmzonePriceMatch(user_info)
@@ -1291,7 +1310,7 @@ if __name__ == '__main__':
driver.SwitchPage()
risk_listing_filter = "Active"
_shopMallName = "WEIZHENFENG168"
ap_asin ="B0F1N18XFW"
ap_asin ="B0FHGQY18W"
skip_asin = []
for _ in range(3):
try:
@@ -1304,7 +1323,7 @@ if __name__ == '__main__':
print("有数据,开始操作")
for asin, status in driver.run_page_action(
current_shop_name=_shopMallName,
appoint_asin=ap_asin,skip_asin=skip_asin
appoint_asin=ap_asin,skip_asin=skip_asin,mode="asin"
):
print(f"ASIN {asin} 的处理结果: {status}")
print("已完成操作")