优化
This commit is contained in:
parent
68c5968200
commit
032a63ab39
@ -283,18 +283,14 @@ def add_creator(request):
|
||||
elif isinstance(avg_video_views, (int, float)):
|
||||
creator.avg_video_views = avg_video_views
|
||||
|
||||
# 更新价格信息
|
||||
pricing_data = data.get('pricing', {})
|
||||
if pricing_data:
|
||||
# 处理individual价格或直接的pricing值
|
||||
if 'individual' in pricing_data:
|
||||
creator.pricing = pricing_data.get('individual')
|
||||
elif 'pricing' in pricing_data:
|
||||
creator.pricing = pricing_data.get('pricing')
|
||||
elif isinstance(pricing_data, (int, float)):
|
||||
creator.pricing = pricing_data
|
||||
# 更新价格信息 - 直接使用pricing和pricing_package字段
|
||||
pricing = data.get('pricing')
|
||||
if pricing is not None:
|
||||
creator.pricing = pricing
|
||||
|
||||
creator.pricing_package = pricing_data.get('package', creator.pricing_package) if isinstance(pricing_data, dict) else creator.pricing_package
|
||||
pricing_package = data.get('pricing_package')
|
||||
if pricing_package is not None:
|
||||
creator.pricing_package = pricing_package
|
||||
|
||||
creator.collab_count = data.get('collab_count', creator.collab_count)
|
||||
creator.latest_collab = data.get('latest_collab', creator.latest_collab)
|
||||
@ -733,18 +729,107 @@ def update_creator_detail(request):
|
||||
'data': None
|
||||
}, json_dumps_params={'ensure_ascii': False})
|
||||
|
||||
# 更新基础信息
|
||||
# 更新基本信息
|
||||
if 'name' in data:
|
||||
creator.name = data.get('name')
|
||||
if 'avatar_url' in data:
|
||||
creator.avatar_url = data.get('avatar_url')
|
||||
if 'platform_id' in data:
|
||||
creator.platform_id = data.get('platform_id')
|
||||
|
||||
# 更新联系方式
|
||||
creator.email = data.get('email', creator.email)
|
||||
creator.instagram = data.get('instagram', creator.instagram)
|
||||
creator.tiktok_link = data.get('tiktok_link', creator.tiktok_link)
|
||||
creator.location = data.get('location', creator.location)
|
||||
creator.live_schedule = data.get('live_schedule', creator.live_schedule)
|
||||
|
||||
# 更新达人平台信息
|
||||
if 'profile' in data:
|
||||
creator.profile = data.get('profile')
|
||||
if 'hashtags' in data:
|
||||
creator.hashtags = data.get('hashtags')
|
||||
if 'trends' in data:
|
||||
creator.trends = data.get('trends')
|
||||
if 'region' in data:
|
||||
creator.region = data.get('region')
|
||||
creator.tiktok_link = data.get('tiktok_link', creator.tiktok_link)
|
||||
if 'us_creator_level' in data:
|
||||
creator.us_creator_level = data.get('us_creator_level')
|
||||
|
||||
# 更新价格相关信息
|
||||
if 'price_gbp' in data:
|
||||
creator.price_gbp = data.get('price_gbp')
|
||||
if 'price_usd' in data:
|
||||
creator.price_usd = data.get('price_usd')
|
||||
if 'gmv_gbp' in data:
|
||||
creator.gmv_gbp = data.get('gmv_gbp')
|
||||
if 'link' in data:
|
||||
creator.link = data.get('link')
|
||||
|
||||
# 更新类别和等级信息
|
||||
if 'category' in data:
|
||||
creator.category = data.get('category')
|
||||
|
||||
# 处理电商等级
|
||||
e_commerce_level = data.get('e_commerce_level')
|
||||
if e_commerce_level:
|
||||
if isinstance(e_commerce_level, str) and e_commerce_level.startswith('L'):
|
||||
creator.e_commerce_level = int(e_commerce_level[1:])
|
||||
elif isinstance(e_commerce_level, int):
|
||||
creator.e_commerce_level = e_commerce_level
|
||||
|
||||
if 'exposure_level' in data:
|
||||
creator.exposure_level = data.get('exposure_level')
|
||||
if 'followers' in data:
|
||||
creator.followers = data.get('followers')
|
||||
|
||||
# 处理GMV
|
||||
gmv = data.get('gmv')
|
||||
if gmv:
|
||||
if isinstance(gmv, str) and gmv.startswith('$') and gmv.endswith('k'):
|
||||
# 将"$534.1k"转换为534.1
|
||||
creator.gmv = float(gmv.strip('$k'))
|
||||
elif isinstance(gmv, (int, float)):
|
||||
creator.gmv = gmv
|
||||
|
||||
# 处理items_sold
|
||||
items_sold = data.get('items_sold')
|
||||
if items_sold:
|
||||
if isinstance(items_sold, str) and items_sold.endswith('k'):
|
||||
creator.items_sold = float(items_sold.strip('k'))
|
||||
elif isinstance(items_sold, (int, float)):
|
||||
creator.items_sold = items_sold
|
||||
|
||||
# 处理avg_video_views
|
||||
avg_video_views = data.get('avg_video_views')
|
||||
if avg_video_views:
|
||||
if isinstance(avg_video_views, str) and avg_video_views.endswith('k'):
|
||||
creator.avg_video_views = float(avg_video_views.strip('k')) * 1000
|
||||
elif isinstance(avg_video_views, (int, float)):
|
||||
creator.avg_video_views = avg_video_views
|
||||
|
||||
# 更新价格信息 - 直接使用pricing和pricing_package字段
|
||||
pricing = data.get('pricing')
|
||||
if pricing is not None:
|
||||
creator.pricing = pricing
|
||||
|
||||
pricing_package = data.get('pricing_package')
|
||||
if pricing_package is not None:
|
||||
creator.pricing_package = pricing_package
|
||||
|
||||
if 'collab_count' in data:
|
||||
creator.collab_count = data.get('collab_count')
|
||||
if 'latest_collab' in data:
|
||||
creator.latest_collab = data.get('latest_collab')
|
||||
if 'e_commerce_platforms' in data:
|
||||
creator.e_commerce_platforms = data.get('e_commerce_platforms')
|
||||
|
||||
# 更新MCN机构
|
||||
creator.mcn = data.get('mcn', creator.mcn)
|
||||
|
||||
# 更新分析数据
|
||||
if 'gmv_by_channel' in data:
|
||||
creator.gmv_by_channel = data.get('gmv_by_channel')
|
||||
|
||||
if 'gmv_by_category' in data:
|
||||
creator.gmv_by_category = data.get('gmv_by_category')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user