Commit 49f49ef3 by chenyuanjie

修改卖家解析规则

parent 281b9289
......@@ -835,27 +835,40 @@ def udf_parse_seller_json(seller_json):
:return: buy_box_seller_type: 1.amazon,2.fba,3.fbm,4.默认值(无类型)
:return: 类型、店铺名称、店铺id
"""
# if not seller_json:
# if not seller_json or seller_json.strip() in ("", "null", "None"):
# return 0, None, None
if 'seller_id' not in str(seller_json):
if not seller_json or 'seller_id' not in str(seller_json):
return 0, None, None
else:
try:
seller_info_parsed = json.loads(seller_json)
except json.JSONDecodeError:
return 0, None, None
ship_from = seller_info_parsed.get("ship_from", None)
sold_by = seller_info_parsed.get("sold_by", None)
fulfilled_by = seller_info_parsed.get("fulfilled_by", None)
seller_id = seller_info_parsed.get("seller_id", None)
# 如果sold_by是amazon,优先归为1类
if sold_by and sold_by.lower().strip().startswith("amazon"):
return 1, sold_by, seller_id # Amazon
# 判断是否为Amazon相关(FBA情况)
if (ship_from and ship_from.lower().strip().startswith("amazon")) or (
fulfilled_by and 'amazon' in fulfilled_by.lower()):
if sold_by and not sold_by.lower().strip().startswith("amazon"):
return 2, sold_by, seller_id # FBA
elif sold_by and sold_by.lower().strip().startswith("amazon"):
return 1, sold_by, seller_id # Amazon
elif (ship_from or fulfilled_by) and sold_by:
# FBM情况:有发货地或配送方信息,且有销售方
if (ship_from or fulfilled_by) and sold_by:
return 3, sold_by, seller_id # FBM
# 其他情况
return 4, sold_by, seller_id # Other
# if (ship_from and ship_from.lower().strip().startswith("amazon")) or (
# fulfilled_by and 'amazon' in fulfilled_by.lower()):
# if sold_by and not sold_by.lower().strip().startswith("amazon"):
# return 2, sold_by, seller_id # FBA
# elif sold_by and sold_by.lower().strip().startswith("amazon"):
# return 1, sold_by, seller_id # Amazon
# elif (ship_from or fulfilled_by) and sold_by:
# return 3, sold_by, seller_id # FBM
# return 4, sold_by, seller_id # Other
def udf_parse_amazon_orders(asin_amazon_orders_str):
"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment