904118851 2 сар өмнө
parent
commit
88d500e957

+ 25 - 7
common/dbproxy/tg_main.lua

@@ -64,7 +64,7 @@ end
 
 function M.search(msg_body)
 
-    local isok ,key =  tools.checkData({"is_group_record","tf_time_interval","mini_program_platform_id","is_comment","material_rule_id","parent_main_id","id","ads_operation_status","statistics_platform_id","converted_time_duration","cbo_status","project_type","oce_product_id","oce_product_platform_id","delivery_mode","material_platform_id","wx_miniapp_create_status","genre","template_bid","cpa_bid","page_size","page_number","main_name","running_status","custom_budget","pay_type","tg_platform_id","butler_id","tg_app_index","is_open_create_link","is_delete"},msg_body)
+    local isok ,key =  tools.checkData({"is_boost","is_reservation","title_type_id","is_group_record","tf_time_interval","mini_program_platform_id","is_comment","material_rule_id","parent_main_id","id","ads_operation_status","statistics_platform_id","converted_time_duration","cbo_status","project_type","oce_product_id","oce_product_platform_id","delivery_mode","material_platform_id","wx_miniapp_create_status","genre","template_bid","cpa_bid","page_size","page_number","main_name","running_status","custom_budget","pay_type","tg_platform_id","butler_id","tg_app_index","is_open_create_link","is_delete"},msg_body)
    
     if not isok then
         return false,string.format("缺少字段: %s.", key)
@@ -76,6 +76,21 @@ function M.search(msg_body)
 
     local offset = (page_number - 1) * page_size
 
+    local is_boost_param = ""
+    if msg_body.is_boost~="" then
+        is_boost_param =  " AND is_boost = "..msg_body.is_boost
+    end
+
+    local is_reservation_param = ""
+    if msg_body.is_reservation~="" then
+        is_reservation_param =  " AND is_reservation = "..msg_body.is_reservation
+    end
+
+    local title_type_id_param = ""
+    if msg_body.title_type_id~="" then
+        title_type_id_param =  " AND title_type_id = "..msg_body.title_type_id
+    end
+
     local is_group_record_param = ""
     if msg_body.is_group_record~="" then
         is_group_record_param =  " AND is_group_record = "..msg_body.is_group_record
@@ -233,7 +248,7 @@ function M.search(msg_body)
         genre_param =  string.format(" AND genre = %d ",msg_body.genre) 
     end
 
-    local param = is_group_record_param..tf_time_interval_param..mini_program_platform_id_param..is_comment_param..material_rule_id_param..parent_main_id_param..id_param..ads_operation_status_param..statistics_platform_id_param..converted_time_duration_param..infra_status_param..cbo_script_status_param..cbo_status_param..project_type_param..oce_product_platform_id_param..oce_product_id_param..delivery_mode_param..main_name_param..tg_platform_param..running_status_param..pay_type_param..butler_id_param..tg_app_index_param..is_open_create_link_param..is_delete_param..custom_budget_param..cpa_bid_param..template_bid_param..genre_param..wx_miniapp_create_status_param..material_platform_id_param;
+    local param =  is_boost_param..is_reservation_param..title_type_id_param..is_group_record_param..tf_time_interval_param..mini_program_platform_id_param..is_comment_param..material_rule_id_param..parent_main_id_param..id_param..ads_operation_status_param..statistics_platform_id_param..converted_time_duration_param..infra_status_param..cbo_script_status_param..cbo_status_param..project_type_param..oce_product_platform_id_param..oce_product_id_param..delivery_mode_param..main_name_param..tg_platform_param..running_status_param..pay_type_param..butler_id_param..tg_app_index_param..is_open_create_link_param..is_delete_param..custom_budget_param..cpa_bid_param..template_bid_param..genre_param..wx_miniapp_create_status_param..material_platform_id_param;
 
     local sql = "SELECT * FROM tg_main where 1=1 "..param..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
     local res = mysqldbx.query(sql)
@@ -257,13 +272,16 @@ end
 -- `daily_new_limit` int DEFAULT '0' COMMENT '今天新上数量上限',
 
 function M.addMain(msg_body)
-    local isok ,key =  tools.checkData({"is_group_record","tf_time_interval","mat_roi","reduce_roi","boost_high_price_end_time","boost_high_price_number","reduce_consume_amount","reduce_bid_amount","is_comment","member_token","zy_conifg","convert_cnt","material_rule_id","material_rule_number","parent_main_id","tg_day","valid_timer_like_num" ,"ads_operation_status","statistics_platform_id","hide_if_converted","converted_time_duration","cbo_script_time","cbo_script_status","cbo_status","project_type","tf_status","tf_start_time","min_book_word","max_book_word","stat_cost","hy_accountId","oce_product_id","oce_product_platform_id","material_platform_id","delivery_mode","advertiser_id","wx_miniapp_create_status","genre","ad_act","template_bid","zh_id","roi_goal","ql_bid","infra_status","pay_type","qm_id","ldy_template_site_id","yw_id","parent_platform_id","platform_shared_id","distributor_id","is_delete","ad_convert_type","aweme_id","tg_app_index","butler_id","mini_program_platform_id","landing_page","valid_timer_time","valid_timer_number","channelId","no_bid_budget","max_ad_quantity","tg_link_config","tg_platform_id","app_id","main_name","running_status","ad_quantity","cpa_bid","bid_type","bid_ratio","custom_budget","daily_new_limit","valid_time","group_id"},msg_body)
+    local isok ,key =  tools.checkData({"is_boost","is_reservation","title_type_id","is_group_record","tf_time_interval","mat_roi","reduce_roi","boost_high_price_end_time","boost_high_price_number","reduce_consume_amount","reduce_bid_amount","is_comment","member_token","zy_conifg","convert_cnt","material_rule_id","material_rule_number","parent_main_id","tg_day","valid_timer_like_num" ,"ads_operation_status","statistics_platform_id","hide_if_converted","converted_time_duration","cbo_script_time","cbo_script_status","cbo_status","project_type","tf_status","tf_start_time","min_book_word","max_book_word","stat_cost","hy_accountId","oce_product_id","oce_product_platform_id","material_platform_id","delivery_mode","advertiser_id","wx_miniapp_create_status","genre","ad_act","template_bid","zh_id","roi_goal","ql_bid","infra_status","pay_type","qm_id","ldy_template_site_id","yw_id","parent_platform_id","platform_shared_id","distributor_id","is_delete","ad_convert_type","aweme_id","tg_app_index","butler_id","mini_program_platform_id","landing_page","valid_timer_time","valid_timer_number","channelId","no_bid_budget","max_ad_quantity","tg_link_config","tg_platform_id","app_id","main_name","running_status","ad_quantity","cpa_bid","bid_type","bid_ratio","custom_budget","daily_new_limit","valid_time","group_id"},msg_body)
     if not isok then
         return false,string.format("缺少字段: %s.", key)
     end
     local current_time = os.date("%Y-%m-%d %H:%M:%S")
     msg_body.create_time = current_time
-    local sql = string.format("INSERT INTO `tg_main` (is_group_record,tf_time_interval,mat_roi,reduce_roi,boost_high_price_end_time,boost_high_price_number,reduce_consume_amount,reduce_bid_amount,is_comment,member_token,zy_conifg,convert_cnt,material_rule_id,material_rule_number,parent_main_id,tg_day,valid_timer_like_num,ads_operation_status,statistics_platform_id,hide_if_converted,converted_time_duration,cbo_script_time,cbo_script_status,cbo_status,project_type,tf_status,tf_start_time,min_book_word,max_book_word,stat_cost,hy_accountId,oce_product_id,oce_product_platform_id,material_platform_id,delivery_mode,advertiser_id,wx_miniapp_create_status,genre,ad_act,template_bid,zh_id,roi_goal,ql_bid,infra_status,pay_type,qm_id,ldy_template_site_id,yw_id,parent_platform_id,platform_shared_id,distributor_id,is_delete,ad_convert_type,aweme_id,tg_app_index,butler_id,mini_program_platform_id,landing_page,valid_timer_time,valid_timer_number,channelId,no_bid_budget,max_ad_quantity,tg_link_config,tg_platform_id,app_id,main_name,running_status,ad_quantity,cpa_bid,bid_type,bid_ratio,custom_budget,daily_new_limit,valid_time,group_id)  VALUES (%d,%d,%f,%f,%d,%d,%f,%f,%d,'%s','%s',%d,%d,%d, %d,%d,%d,'%s',%d,'%s','%s','%s',%d,%d,%d,%d,'%s',%d,%d,%d,'%s','%s','%s',%d,'%s','%s',%d,%d,%d,%d,'%s',%d,%d,%d,%d,'%s','%s','%s',%d,%d,'%s',%d,'%s','%s', %d, %d, %d,'%s', %d, '%s', '%s',%d, %d, '%s', %d, '%s', '%s', %d, %d, %d,%d, '%s', %d, %d, '%s', '%s')",
+    local sql = string.format("INSERT INTO `tg_main` (is_boost,is_reservation,title_type_id,is_group_record,tf_time_interval,mat_roi,reduce_roi,boost_high_price_end_time,boost_high_price_number,reduce_consume_amount,reduce_bid_amount,is_comment,member_token,zy_conifg,convert_cnt,material_rule_id,material_rule_number,parent_main_id,tg_day,valid_timer_like_num,ads_operation_status,statistics_platform_id,hide_if_converted,converted_time_duration,cbo_script_time,cbo_script_status,cbo_status,project_type,tf_status,tf_start_time,min_book_word,max_book_word,stat_cost,hy_accountId,oce_product_id,oce_product_platform_id,material_platform_id,delivery_mode,advertiser_id,wx_miniapp_create_status,genre,ad_act,template_bid,zh_id,roi_goal,ql_bid,infra_status,pay_type,qm_id,ldy_template_site_id,yw_id,parent_platform_id,platform_shared_id,distributor_id,is_delete,ad_convert_type,aweme_id,tg_app_index,butler_id,mini_program_platform_id,landing_page,valid_timer_time,valid_timer_number,channelId,no_bid_budget,max_ad_quantity,tg_link_config,tg_platform_id,app_id,main_name,running_status,ad_quantity,cpa_bid,bid_type,bid_ratio,custom_budget,daily_new_limit,valid_time,group_id)  VALUES (%d, %d,%d,  %d,%d,%f,%f,%d,%d,%f,%f,%d,'%s','%s',%d,%d,%d, %d,%d,%d,'%s',%d,'%s','%s','%s',%d,%d,%d,%d,'%s',%d,%d,%d,'%s','%s','%s',%d,'%s','%s',%d,%d,%d,%d,'%s',%d,%d,%d,%d,'%s','%s','%s',%d,%d,'%s',%d,'%s','%s', %d, %d, %d,'%s', %d, '%s', '%s',%d, %d, '%s', %d, '%s', '%s', %d, %d, %d,%d, '%s', %d, %d, '%s', '%s')",
+    msg_body.is_boost,
+    msg_body.is_reservation,
+    msg_body.title_type_id,
     msg_body.is_group_record,
     msg_body.tf_time_interval,
     msg_body.mat_roi,
@@ -462,14 +480,14 @@ function pushAddMainMsg(msg_body)
    
 end
 function M.modifyMain(msg_body)
-    local isok ,key =  tools.checkData({"is_group_record","tf_time_interval","mat_roi","reduce_roi","boost_high_price_end_time","boost_high_price_number","reduce_consume_amount","reduce_bid_amount","is_comment","member_token","zy_conifg","convert_cnt","material_rule_id","material_rule_number","tg_day","valid_timer_like_num","ads_operation_status","statistics_platform_id","hide_if_converted","converted_time_duration","cbo_script_time","cbo_script_status","cbo_status","project_type","tf_status","tf_start_time","min_book_word","max_book_word","stat_cost","hy_accountId","oce_product_id","oce_product_platform_id","material_platform_id","delivery_mode","advertiser_id","wx_miniapp_create_status","genre","ad_act","template_bid","zh_id","roi_goal","ql_bid","infra_status","pay_type","pay_type","qm_id","ldy_template_site_id","yw_id","parent_platform_id","platform_shared_id","distributor_id","is_delete","ad_convert_type","aweme_id","tg_app_index","butler_id","mini_program_platform_id","landing_page","valid_timer_time","valid_timer_number","channelId","no_bid_budget","max_ad_quantity","tg_link_config","id","tg_platform_id","app_id","main_name","running_status","ad_quantity","cpa_bid","bid_type","bid_ratio","custom_budget","daily_new_limit","valid_time","group_id"},msg_body)
+    local isok ,key =  tools.checkData({"is_boost","is_reservation","title_type_id","is_group_record","tf_time_interval","mat_roi","reduce_roi","boost_high_price_end_time","boost_high_price_number","reduce_consume_amount","reduce_bid_amount","is_comment","member_token","zy_conifg","convert_cnt","material_rule_id","material_rule_number","tg_day","valid_timer_like_num","ads_operation_status","statistics_platform_id","hide_if_converted","converted_time_duration","cbo_script_time","cbo_script_status","cbo_status","project_type","tf_status","tf_start_time","min_book_word","max_book_word","stat_cost","hy_accountId","oce_product_id","oce_product_platform_id","material_platform_id","delivery_mode","advertiser_id","wx_miniapp_create_status","genre","ad_act","template_bid","zh_id","roi_goal","ql_bid","infra_status","pay_type","pay_type","qm_id","ldy_template_site_id","yw_id","parent_platform_id","platform_shared_id","distributor_id","is_delete","ad_convert_type","aweme_id","tg_app_index","butler_id","mini_program_platform_id","landing_page","valid_timer_time","valid_timer_number","channelId","no_bid_budget","max_ad_quantity","tg_link_config","id","tg_platform_id","app_id","main_name","running_status","ad_quantity","cpa_bid","bid_type","bid_ratio","custom_budget","daily_new_limit","valid_time","group_id"},msg_body)
     if not isok then
         return false,string.format("缺少字段: %s.", key)
     end
     local current_time = os.date("%Y-%m-%d %H:%M:%S")
     msg_body.update_time = current_time
-    local sql = string.format("UPDATE  `tg_main` SET is_group_record = %d , tf_time_interval = %d , mat_roi = %f , reduce_roi = %f , boost_high_price_end_time = %d , boost_high_price_number = %d , reduce_consume_amount = %f , reduce_bid_amount = %f , is_comment = %d , member_token = '%s' , zy_conifg = '%s' , convert_cnt = %d , material_rule_id = %d , material_rule_number = %d , tg_day = %d ,  valid_timer_like_num = %d , ads_operation_status = '%s' , statistics_platform_id = %d , hide_if_converted = '%s' ,converted_time_duration = '%s' ,cbo_script_time = '%s' , cbo_script_status = %d , cbo_status = %d ,  project_type = %d ,tf_status = %d , tf_start_time = '%s' , min_book_word = %d ,  max_book_word = %d , stat_cost = %d , hy_accountId = '%s' , oce_product_id = '%s' , oce_product_platform_id = '%s' , material_platform_id = %d , delivery_mode = '%s' , advertiser_id = '%s' ,wx_miniapp_create_status = %d , genre = %d , ad_act = %d ,template_bid = %d , zh_id = '%s', roi_goal = %d , ql_bid = %d, infra_status = %d , pay_type = %d ,qm_id = '%s' , ldy_template_site_id = '%s' , yw_id = '%s' , parent_platform_id = %d , platform_shared_id = %d ,distributor_id = '%s' , is_delete = %d , ad_convert_type = '%s', aweme_id = '%s' ,tg_app_index = %d , butler_id = %d , mini_program_platform_id = %d , landing_page = '%s' , valid_timer_time = %d , valid_timer_number = %d ,channelId = '%s' , no_bid_budget = %d , max_ad_quantity = %d ,tg_platform_id = %d , app_id = '%s' ,main_name = '%s' , update_time = '%s' , running_status = %d ,ad_quantity = %d ,cpa_bid = %d ,bid_type = %d ,bid_ratio = '%s' ,custom_budget = %d ,daily_new_limit = %d ,valid_time = %d ,tg_link_config = '%s' ,group_id = '%s' WHERE id = %d ",
-    msg_body.is_group_record,msg_body.tf_time_interval,msg_body.mat_roi,msg_body.reduce_roi,msg_body.boost_high_price_end_time,msg_body.boost_high_price_number,msg_body.reduce_consume_amount,msg_body.reduce_bid_amount,msg_body.is_comment,msg_body.member_token,cjson.encode(msg_body.zy_conifg),msg_body.convert_cnt,msg_body.material_rule_id,msg_body.material_rule_number,msg_body.tg_day,msg_body.valid_timer_like_num,msg_body.ads_operation_status,msg_body.statistics_platform_id,msg_body.hide_if_converted,msg_body.converted_time_duration,msg_body.cbo_script_time,msg_body.cbo_script_status,msg_body.cbo_status,msg_body.project_type,msg_body.tf_status,msg_body.tf_start_time,msg_body.min_book_word,msg_body.max_book_word,msg_body.stat_cost,msg_body.hy_accountId,msg_body.oce_product_id,msg_body.oce_product_platform_id,msg_body.material_platform_id,msg_body.delivery_mode,msg_body.advertiser_id,msg_body.wx_miniapp_create_status,msg_body.genre,msg_body.ad_act,msg_body.template_bid,msg_body.zh_id,msg_body.roi_goal,msg_body.ql_bid,msg_body.infra_status,msg_body.pay_type,msg_body.qm_id,msg_body.ldy_template_site_id,msg_body.yw_id,msg_body.parent_platform_id,msg_body.platform_shared_id,msg_body.distributor_id,msg_body.is_delete,msg_body.ad_convert_type,msg_body.aweme_id,msg_body.tg_app_index,msg_body.butler_id,msg_body.mini_program_platform_id,msg_body.landing_page,tonumber(msg_body.valid_timer_time),tonumber(msg_body.valid_timer_number),msg_body.channelId,msg_body.no_bid_budget,msg_body.max_ad_quantity,msg_body.tg_platform_id,msg_body.app_id,msg_body.main_name,msg_body.update_time,msg_body.running_status,msg_body.ad_quantity,msg_body.cpa_bid,msg_body.bid_type,msg_body.bid_ratio,msg_body.custom_budget,
+    local sql = string.format("UPDATE  `tg_main` SET is_boost = %d , is_reservation = %d , title_type_id = %d , is_group_record = %d , tf_time_interval = %d , mat_roi = %f , reduce_roi = %f , boost_high_price_end_time = %d , boost_high_price_number = %d , reduce_consume_amount = %f , reduce_bid_amount = %f , is_comment = %d , member_token = '%s' , zy_conifg = '%s' , convert_cnt = %d , material_rule_id = %d , material_rule_number = %d , tg_day = %d ,  valid_timer_like_num = %d , ads_operation_status = '%s' , statistics_platform_id = %d , hide_if_converted = '%s' ,converted_time_duration = '%s' ,cbo_script_time = '%s' , cbo_script_status = %d , cbo_status = %d ,  project_type = %d ,tf_status = %d , tf_start_time = '%s' , min_book_word = %d ,  max_book_word = %d , stat_cost = %d , hy_accountId = '%s' , oce_product_id = '%s' , oce_product_platform_id = '%s' , material_platform_id = %d , delivery_mode = '%s' , advertiser_id = '%s' ,wx_miniapp_create_status = %d , genre = %d , ad_act = %d ,template_bid = %d , zh_id = '%s', roi_goal = %d , ql_bid = %d, infra_status = %d , pay_type = %d ,qm_id = '%s' , ldy_template_site_id = '%s' , yw_id = '%s' , parent_platform_id = %d , platform_shared_id = %d ,distributor_id = '%s' , is_delete = %d , ad_convert_type = '%s', aweme_id = '%s' ,tg_app_index = %d , butler_id = %d , mini_program_platform_id = %d , landing_page = '%s' , valid_timer_time = %d , valid_timer_number = %d ,channelId = '%s' , no_bid_budget = %d , max_ad_quantity = %d ,tg_platform_id = %d , app_id = '%s' ,main_name = '%s' , update_time = '%s' , running_status = %d ,ad_quantity = %d ,cpa_bid = %d ,bid_type = %d ,bid_ratio = '%s' ,custom_budget = %d ,daily_new_limit = %d ,valid_time = %d ,tg_link_config = '%s' ,group_id = '%s' WHERE id = %d ",
+    msg_body.is_boost,msg_body.is_reservation,msg_body.title_type_id,msg_body.is_group_record,msg_body.tf_time_interval,msg_body.mat_roi,msg_body.reduce_roi,msg_body.boost_high_price_end_time,msg_body.boost_high_price_number,msg_body.reduce_consume_amount,msg_body.reduce_bid_amount,msg_body.is_comment,msg_body.member_token,cjson.encode(msg_body.zy_conifg),msg_body.convert_cnt,msg_body.material_rule_id,msg_body.material_rule_number,msg_body.tg_day,msg_body.valid_timer_like_num,msg_body.ads_operation_status,msg_body.statistics_platform_id,msg_body.hide_if_converted,msg_body.converted_time_duration,msg_body.cbo_script_time,msg_body.cbo_script_status,msg_body.cbo_status,msg_body.project_type,msg_body.tf_status,msg_body.tf_start_time,msg_body.min_book_word,msg_body.max_book_word,msg_body.stat_cost,msg_body.hy_accountId,msg_body.oce_product_id,msg_body.oce_product_platform_id,msg_body.material_platform_id,msg_body.delivery_mode,msg_body.advertiser_id,msg_body.wx_miniapp_create_status,msg_body.genre,msg_body.ad_act,msg_body.template_bid,msg_body.zh_id,msg_body.roi_goal,msg_body.ql_bid,msg_body.infra_status,msg_body.pay_type,msg_body.qm_id,msg_body.ldy_template_site_id,msg_body.yw_id,msg_body.parent_platform_id,msg_body.platform_shared_id,msg_body.distributor_id,msg_body.is_delete,msg_body.ad_convert_type,msg_body.aweme_id,msg_body.tg_app_index,msg_body.butler_id,msg_body.mini_program_platform_id,msg_body.landing_page,tonumber(msg_body.valid_timer_time),tonumber(msg_body.valid_timer_number),msg_body.channelId,msg_body.no_bid_budget,msg_body.max_ad_quantity,msg_body.tg_platform_id,msg_body.app_id,msg_body.main_name,msg_body.update_time,msg_body.running_status,msg_body.ad_quantity,msg_body.cpa_bid,msg_body.bid_type,msg_body.bid_ratio,msg_body.custom_budget,
     tonumber(msg_body.daily_new_limit),tonumber(msg_body.valid_time),cjson.encode(msg_body.tg_link_config),msg_body.group_id,msg_body.id)
     tools.dump(mysqldbx.query(sql))
     skynet.send("backmgr","lua","on_recv",nil,"ws_push_msg",cjson.encode({cmd="updateMainConfig"}))

+ 48 - 8
service/backmgr/video_titles.lua

@@ -7,10 +7,12 @@ local md5 =	require	"md5"
 
 
 function M.add_video_title(msg_body)
-    local isok ,key =  tools.checkData({"title_list"},msg_body)
+    local isok ,key =  tools.checkData({"title_list","pay_type","title_type_id"},msg_body)
     if not isok then
         return false,string.format("缺少字段: %s.", key)
     end
+    local pay_type = msg_body.pay_type
+    local title_type_id = msg_body.title_type_id
     for i = 1, #msg_body.title_list, 1 do
         local title = msg_body.title_list[i].title
         local md5_tag = msg_body.title_list[i].md5_tag
@@ -20,7 +22,7 @@ function M.add_video_title(msg_body)
         if #res > 0 then
 
         else
-            sql = string.format("INSERT INTO `video_titles` (title,md5_tag)  VALUES ('%s','%s')",title,md5_tag)
+            sql = string.format("INSERT INTO `video_titles` (title,md5_tag,pay_type,title_type_id)  VALUES ('%s','%s',%d,%d)",title,md5_tag,pay_type,title_type_id)
             mysqldbx.query(sql)
         end
 
@@ -42,27 +44,65 @@ function M.delete_video_title(msg_body)
 end
 
 function M.modify_video_title(msg_body)
-    local isok ,key =  tools.checkData({"title","md5_tag","id"},msg_body)
+    local isok ,key =  tools.checkData({"title","md5_tag","id","pay_type","title_type_id"},msg_body)
     if not isok then
         return false,string.format("缺少字段: %s.", key)
     end
-    local sql = string.format("UPDATE  video_titles SET title = '%s' , md5_tag = '%s' WHERE id = %d ",msg_body.title,msg_body.md5_tag,msg_body.id)
+    local sql = string.format("UPDATE  video_titles SET title_type_id = %d , pay_type = %d , title = '%s' , md5_tag = '%s' WHERE id = %d ",msg_body.title_type_id,msg_body.pay_type,msg_body.title,msg_body.md5_tag,msg_body.id)
+    mysqldbx.query(sql)
+    return true, {}
+end
+
+function M.modify_pay_type(msg_body)
+    local isok ,key =  tools.checkData({"id_list","pay_type"},msg_body)
+    if not isok then
+        return false,string.format("缺少字段: %s.", key)
+    end
+    local idString = table.concat(msg_body.id_list, ",")
+    sql = string.format("UPDATE `video_titles` SET pay_type = %d WHERE id IN (%s) ",msg_body.pay_type,idString)
+    mysqldbx.query(sql)
+    return true, {}
+end
+
+function M.modify_title_type_id(msg_body)
+    local isok ,key =  tools.checkData({"id_list","title_type_id"},msg_body)
+    if not isok then
+        return false,string.format("缺少字段: %s.", key)
+    end
+    local idString = table.concat(msg_body.id_list, ",")
+    sql = string.format("UPDATE `video_titles` SET title_type_id = %d WHERE id IN (%s) ",msg_body.title_type_id,idString)
     mysqldbx.query(sql)
     return true, {}
 end
 
 function M.search_video_title(msg_body)
-    local isok ,key =  tools.checkData({"page_size","page_number","content"},msg_body)
+    local isok ,key =  tools.checkData({"page_size","page_number","content","pay_type","title_type_id"},msg_body)
     if not isok then
         return false,string.format("缺少字段: %s.", key)
     end
     local page_size = msg_body.page_size
     local page_number = msg_body.page_number
     local offset = (page_number - 1) * page_size
-    
-    local sql = "SELECT * FROM video_titles "..string.format(" WHERE  (title LIKE CONCAT( '%%%s%%')) ",msg_body.content)..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
+
+    local content_param = ""
+    if msg_body.content~=""then
+        content_param = string.format(" AND  (title LIKE CONCAT( '%%%s%%')) ",msg_body.content)
+    end
+
+    local pay_type_param = ""
+    if msg_body.pay_type~=""then
+        pay_type_param = string.format(" AND  pay_type = %d ",msg_body.pay_type)
+    end
+
+    local title_type_id_param = ""
+    if msg_body.title_type_id~=""then
+        title_type_id_param = string.format(" AND  title_type_id = %d ",msg_body.title_type_id)
+    end
+
+    local param = content_param..pay_type_param..title_type_id_param
+    local sql = "SELECT * FROM video_titles WHERE 1=1 "..param.." ORDER BY id DESC".. string.format(" LIMIT %d OFFSET %d ",page_size, offset)
     local list = mysqldbx.query(sql)
-    sql = "SELECT   COUNT(*) AS total  FROM video_titles "..string.format(" WHERE  (title LIKE CONCAT( '%%%s%%')) ",msg_body.content)
+    sql = "SELECT   COUNT(*) AS total  FROM video_titles  WHERE 1=1 "..param
     local total = mysqldbx.query(sql)
     return true,list,total[1].total
 end