瀏覽代碼

MOD:删除微信计划,逻辑修改

cxyu 3 年之前
父節點
當前提交
ea8d94f8f9
共有 3 個文件被更改,包括 14 次插入103 次删除
  1. 1 0
      web_module/tornado_api.py
  2. 6 97
      wechat_action/create_ad_layout.py
  3. 7 6
      wechat_action/sql_tools.py

+ 1 - 0
web_module/tornado_api.py

@@ -523,6 +523,7 @@ class get_task_list(BaseHandler):
 
 
 class get_all_ad_task(BaseHandler):
+    #TODO:添加两个字段,微信,朋友圈
     def get(self):
         user_id = self.get_argument('user_id', None)
         sql_session = db.DBSession()

+ 6 - 97
wechat_action/create_ad_layout.py

@@ -241,9 +241,9 @@ class CreateAd:
 
         if info['type'] == 'topImg':
             single_page_set()
-        if info['type'] == 'multi_page':
+        if info['type'] == 'topSlider':
             multi_page_set()
-        if info['type'] == 'movie':
+        if info['type'] == 'topVideo':
             movie_set()
 
         # 设置头部组件
@@ -410,100 +410,9 @@ class CreateAd:
                 distance_buttons_can_use[1].send_keys(Keys.BACKSPACE)
             distance_buttons_can_use[1].send_keys(config_info['str_dimarginBottomstance'])
 
-    def set_follow_button(self, button_type):
-        # 设置关注按钮
-        # 1.设置button文本内容2.是否加粗3.设置字体颜色,边框颜色,填充色4.设置边距
+    def set_follow_button(self, config_info):
+        # TODO:是否一键关注
 
-        self.driver.find_element_by_xpath('//*[@id="stage-sidebar"]/section/div[4]/div[2]/div/div').click()
-        if button_type == 1:
-            input_elements = self.driver.find_elements_by_xpath('//input[@class="adui-input-base"]')
-            for _ in input_elements:
-                if _.is_enabled() and _.is_displayed() and _.get_attribute("value") == '关注公众号':
-                    _.click()
-                    _.clear()
-                    for i in range(10):
-                        _.send_keys(Keys.BACKSPACE)
-                    _.send_keys('保存阅读记录')
-            big_elements = self.driver.find_elements_by_xpath('//span[@class="adui-button-content"]')
-            for _ in big_elements:
-                if _.text == '加粗' and _.is_displayed() and _.is_enabled():
-                    _.click()
-            input_elements = self.driver.find_elements_by_xpath('//input[@class="adui-input-base"]')
-            for _ in input_elements:
-                if _.is_enabled() and _.is_displayed() and _.get_attribute("value") == '07C160':
-                    _.click()
-                    _.send_keys('DE2821')
-        if button_type == 2:
-            input_elements = self.driver.find_elements_by_xpath('//input[@class="adui-input-base"]')
-            for _ in input_elements:
-                if _.is_enabled() and _.is_displayed() and _.get_attribute("value") == '关注公众号':
-                    _.click()
-                    _.clear()
-                    for i in range(10):
-                        _.send_keys(Keys.BACKSPACE)
-                    _.send_keys('点击此处,继续阅读')
-            big_elements = self.driver.find_elements_by_xpath('//span[@class="adui-button-content"]')
-            for _ in big_elements:
-                if _.text == '加粗' and _.is_displayed() and _.is_enabled():
-                    _.click()
-            input_elements = self.driver.find_elements_by_xpath('//input[@class="adui-input-base"]')
-            for _ in input_elements:
-                if _.is_enabled() and _.is_displayed() and _.get_attribute("value") == '07C160':
-                    _.click()
-                    _.send_keys('DE2821')
-            size_buttons = self.driver.find_elements_by_xpath('//input[@class="adui-input-base"]')
-            size_buttons_can_use = []
-            for _ in size_buttons:
-                if _.is_enabled() and _.is_displayed() and _.get_attribute("value") == '28':
-                    size_buttons_can_use.append(_)
-            size_buttons_can_use[0].click()
-            for i in range(4):
-                size_buttons_can_use[0].send_keys(Keys.BACKSPACE)
-            size_buttons_can_use[0].send_keys('0')
-            size_buttons_can_use[1].click()
-            for i in range(4):
-                size_buttons_can_use[1].send_keys(Keys.BACKSPACE)
-            size_buttons_can_use[1].send_keys('0')
-
-        if button_type == 3:
-            input_elements = self.driver.find_elements_by_xpath('//input[@class="adui-input-base"]')
-            for _ in input_elements:
-                if _.is_enabled() and _.is_displayed() and _.get_attribute("value") == '关注公众号':
-                    _.click()
-                    _.clear()
-                    for i in range(10):
-                        _.send_keys(Keys.BACKSPACE)
-                    _.send_keys('点我,继续阅读')
-            big_elements = self.driver.find_elements_by_xpath('//span[@class="adui-button-content"]')
-            for _ in big_elements:
-                if _.text == '加粗' and _.is_displayed() and _.is_enabled():
-                    _.click()
-            input_elements = self.driver.find_elements_by_xpath('//input[@class="adui-input-base"]')
-            for _ in input_elements:
-                if _.is_enabled() and _.is_displayed() and _.get_attribute("value") == '07C160':
-                    _.click()
-                    _.send_keys('FFFFFF')
-            input_elements = self.driver.find_elements_by_xpath('//input[@class="adui-input-base"]')
-            for _ in input_elements:
-                if _.is_enabled() and _.is_displayed() and _.get_attribute("value") == 'FFFFFF':
-                    _.click()
-                    _.send_keys('DE2821')
-                    break
-            size_buttons = self.driver.find_elements_by_xpath('//input[@class="adui-input-base"]')
-            size_buttons_can_use = []
-            for _ in size_buttons:
-                if _.is_enabled() and _.is_displayed() and _.get_attribute("value") == '28':
-                    size_buttons_can_use.append(_)
-            size_buttons_can_use[0].click()
-            for i in range(4):
-                size_buttons_can_use[0].send_keys(Keys.BACKSPACE)
-            size_buttons_can_use[0].send_keys('0')
-            size_buttons_can_use[1].click()
-            for i in range(4):
-                size_buttons_can_use[1].send_keys(Keys.BACKSPACE)
-            size_buttons_can_use[1].send_keys('100')
-
-    def set_follow_button_(self, config_info):
         # 设置关注按钮
         # 1.设置button文本内容 2.是否加粗 3.设置字体颜色,边框颜色,填充色 4.设置边距
 
@@ -662,6 +571,7 @@ class CreateAd:
                     for _ in v:
                         if isinstance(_, dict):
                             get_url(_)
+
         # 上传文件,单线程
         # 上传文件,文件上传与整体流程切割开
         WebDriverWait(self.driver, 10).until(
@@ -685,7 +595,6 @@ class CreateAd:
         #             else:
         #                 file_set.add(v[v_name])
 
-
         get_url(layout)
         for _ in file_set:
             self.send_file(_)
@@ -760,7 +669,7 @@ class CreateAd:
                 if _['type'] == 'txt':
                     self.set_content(_['content'])
                 if _['type'] == 'followAcc':
-                    self.set_follow_button_(_['content'])
+                    self.set_follow_button(_['content'])
 
             self.set_share_content(title_content=layout['shareTittle'], des_content=layout['shareDesc'])
 

+ 7 - 6
wechat_action/sql_tools.py

@@ -111,7 +111,7 @@ def get_layout_typesetting_rough(sql_session, user_id, typesetting_name):
 def get_layout_typesetting(sql_session, user_id, typesetting_name):
     sql = '''
             select typesetting from layout_typesetting lt 
-            where user_id ='{}' and name='{}' and is_delete=0;
+            where user_id ='{}' and is_delete=0 and name='{}' ;
     '''.format(user_id, typesetting_name)
     cursor = sql_session.execute(sql)
     lines = cursor.fetchall()
@@ -134,7 +134,7 @@ def delete_layout_typesetting_vir(sql_session, user_id, typesetting_name):
 def get_plan_typesetting_rough(sql_session, user_id, typesetting_name):
     sql = '''
             select typesetting,name,create_time,update_time from ad_plan_typesetting lt 
-            where user_id ='{}' and is_delete=0 and name like '%{}%';
+            where user_id ='{}'  and name like '%{}%';
     '''.format(user_id, typesetting_name)
     print(sql)
     cursor = sql_session.execute(sql)
@@ -146,7 +146,7 @@ def get_plan_typesetting_rough(sql_session, user_id, typesetting_name):
 def get_ad_plan_typesetting(sql_session, user_id, typesetting_name):
     sql = '''
             select typesetting from ad_plan_typesetting lt 
-            where user_id ='{}' and name='{}' and is_delete=0;
+            where user_id ='{}' and name='{}' ;
     '''.format(user_id, typesetting_name)
     cursor = sql_session.execute(sql)
     lines = cursor.fetchall()
@@ -157,9 +157,10 @@ def get_ad_plan_typesetting(sql_session, user_id, typesetting_name):
 
 def delete_ad_plan_typesetting_vir(sql_session, user_id, typesetting_name, wechat_name, service_name):
     sql = '''
-            update ad_plan_typesetting lt 
+            update action_record lt 
             set is_delete=1
-            where user_id ='{user_id}' and name = '{name}' and 
+            where action_type='create_ad_plan' and
+             user_id ='{user_id}' and object_name = '{name}' and 
             wechat_name='{wechat_name}' and service_name='{service_name}';
     '''.format(user_id=user_id, name=typesetting_name,
                service_name=service_name, wechat_name=wechat_name)
@@ -191,7 +192,7 @@ def get_plan_record(sql_session, user_id, service_name, wechat_name,
         action_record as record_list
         on object_name=name
         where typesetting_list.user_id ='{user_id}'
-        and typesetting_list.is_delete = 0
+        and record_list.is_delete = 0
         and record_list.status in ('done','error')
         {other_info}
         ) as foo left join wechat_info