|
@@ -7,8 +7,8 @@ from sqlalchemy import Table
|
|
|
import json
|
|
|
import time
|
|
|
|
|
|
-layout_create_action = 'layout_create'
|
|
|
-ad_plan_create_action = 'ad_plan_create'
|
|
|
+layout_create_action = 'create_ad_layout'
|
|
|
+ad_plan_create_action = 'create_ad_plan'
|
|
|
|
|
|
|
|
|
def run(user_id, log_ad, db, cookie_canuse):
|
|
@@ -53,9 +53,54 @@ def cookie_acion(db, log_ad, cookie_canuse, user_id):
|
|
|
sql_session.commit()
|
|
|
print('update wechat cookies')
|
|
|
|
|
|
-def carry_plan():
|
|
|
-
|
|
|
- pass
|
|
|
+
|
|
|
+def carry_plan(user_id, ad_plan_list, log_ad, db, cookie_canuse):
|
|
|
+
|
|
|
+
|
|
|
+ action_record_table = Table('action_record', db.metadata,
|
|
|
+ autoload=True, autoload_with=db.engine)
|
|
|
+ sql_session = db.DBSession()
|
|
|
+
|
|
|
+
|
|
|
+ cookie_acion(db, log_ad, cookie_canuse, user_id)
|
|
|
+
|
|
|
+ for _ in ad_plan_list:
|
|
|
+ service_name = _['service_name']
|
|
|
+ wechat_name = _['wechat_name']
|
|
|
+
|
|
|
+ log_ad.select_ad_master(service_name, wechat_name)
|
|
|
+ create_ad_layout = CreateAd(login_ad=log_ad, service_name=service_name, wechat_name=wechat_name)
|
|
|
+ create_ad_layout.check_sucess_ready()
|
|
|
+
|
|
|
+ layout_name = _['idea']['jump_type_page_type']['layout_name'].replace(' ', '')[:29]
|
|
|
+ if create_ad_layout.check_sucess(layout_name=layout_name):
|
|
|
+ res = {'sucess': True, 'result_info': '已经创建过对应落地页'}
|
|
|
+ sql_tools.action_record(res, sql_session, layout_create_action, user_id, layout_name, action_record_table,
|
|
|
+ service_name, wechat_name)
|
|
|
+
|
|
|
+ else:
|
|
|
+
|
|
|
+ create_ad_layout.get_into_create_page()
|
|
|
+ layout_typesetting_dict = sql_tools.get_layout_typesetting(sql_session, user_id,
|
|
|
+ typesetting_name=layout_name)
|
|
|
+ layout_typesetting_dict = json.loads(layout_typesetting_dict)
|
|
|
+ res = create_ad_layout.create_layout(layout_typesetting_dict)
|
|
|
+ sql_tools.action_record(res, sql_session, layout_create_action, user_id, layout_name, action_record_table,
|
|
|
+ service_name, wechat_name)
|
|
|
+ log_ad.refresh_driver()
|
|
|
+
|
|
|
+
|
|
|
+ log_ad.select_ad_master(service_name, wechat_name)
|
|
|
+ plan_name = _['title'].replace(' ', '')[:29]
|
|
|
+
|
|
|
+
|
|
|
+ create_ad_plan = CreateAdPlan(login_ad=log_ad, task=_)
|
|
|
+ res = create_ad_plan.run()
|
|
|
+
|
|
|
+ sql_tools.action_record(res, sql_session, ad_plan_create_action, user_id, plan_name, action_record_table,
|
|
|
+ service_name, wechat_name)
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -133,7 +178,7 @@ def create_layout(user_id, layout_name, wechat_json, log_ad, db, cookie_canuse):
|
|
|
sql_session = db.DBSession()
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
cookie_acion(db, log_ad, cookie_canuse, user_id)
|
|
|
|
|
|
|
|
@@ -146,14 +191,6 @@ def create_layout(user_id, layout_name, wechat_json, log_ad, db, cookie_canuse):
|
|
|
typesetting_dict[-4] = {'layout_name': layout_name}
|
|
|
|
|
|
wechat_json = json.loads(wechat_json)
|
|
|
- for _ in wechat_json:
|
|
|
- action_info = {'user_id': user_id, 'service_name': _['service_name'], 'wechat_name': _['wechat_name'],
|
|
|
- 'action_type': json.dumps({'action_type': layout_create_action, 'object_name': layout_name}),
|
|
|
- 'status': 'todo'}
|
|
|
- record_insert = sql_tools.save_action_record(action_record_info=action_info,
|
|
|
- table_action_record=action_record_table)
|
|
|
- sql_session.execute(record_insert)
|
|
|
- sql_session.commit()
|
|
|
|
|
|
for _ in wechat_json:
|
|
|
service_name = _['service_name']
|
|
@@ -179,6 +216,7 @@ def create_layout(user_id, layout_name, wechat_json, log_ad, db, cookie_canuse):
|
|
|
pass
|
|
|
|
|
|
action_type = layout_create_action
|
|
|
+
|
|
|
sql_tools.action_record(res, sql_session, action_type, user_id, layout_name, action_record_table, service_name,
|
|
|
wechat_name)
|
|
|
log_ad.refresh_driver()
|
|
@@ -212,16 +250,6 @@ def create_ad_plan(user_id, ad_plan_name, wechat_json, log_ad, db, cookie_canuse
|
|
|
typesetting_dict['title'] = ad_plan_name
|
|
|
|
|
|
wechat_json = json.loads(wechat_json)
|
|
|
- for _ in wechat_json:
|
|
|
-
|
|
|
-
|
|
|
- action_info = {'user_id': user_id, 'service_name': _['service_name'], 'wechat_name': _['wechat_name'],
|
|
|
- 'action_type': json.dumps({'action_type': 'ad_plan_create', 'object_name': ad_plan_name}),
|
|
|
- 'status': 'todo'}
|
|
|
- record_insert = sql_tools.save_action_record(action_record_info=action_info,
|
|
|
- table_action_record=action_record_table)
|
|
|
- sql_session.execute(record_insert)
|
|
|
- sql_session.commit()
|
|
|
|
|
|
for _ in wechat_json:
|
|
|
service_name = _['service_name']
|