904118851 před 5 měsíci
rodič
revize
08a583881a

+ 0 - 2
bin/dj_back.pid

@@ -1,2 +0,0 @@
-9252
-

+ 62 - 7
common/dbproxy/tg_main.lua

@@ -64,7 +64,9 @@ end
 
 function M.search(msg_body)
 
-    local isok ,key =  tools.checkData({"material_platform_id","wx_miniapp_create_status","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({"cbo_status","project_type","oce_product_id",
+    "oce_product_platform_id",
+    "delivery_mode","material_platform_id","wx_miniapp_create_status","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 +78,37 @@ function M.search(msg_body)
 
     local offset = (page_number - 1) * page_size
 
+    
+    local infra_status_param = ""
+    if msg_body.infra_status~=""  then
+        infra_status_param = string.format(" AND infra_status =  %d ",msg_body.infra_status) 
+    end
+
+    local cbo_script_status_param = ""
+    if msg_body.cbo_script_status~=""  then
+        cbo_script_status_param = string.format(" AND cbo_script_status =  %d ",msg_body.cbo_script_status) 
+    end
+
+    local cbo_status_param = ""
+    if msg_body.cbo_status~=""  then
+        cbo_status_param = string.format(" AND cbo_status =  %d ",msg_body.cbo_status) 
+    end
+
+    local project_type_param = ""
+    if msg_body.project_type~=""  then
+        project_type_param = string.format(" AND project_type =  %d ",msg_body.project_type) 
+    end
+
+    local oce_product_id_param = ""
+    if msg_body.oce_product_id~="" and msg_body.oce_product_id~=nil then
+        oce_product_id_param = string.format(" AND oce_product_id =  '%s' ",msg_body.oce_product_id) 
+    end
+
+    local oce_product_platform_id_param = ""
+    if msg_body.oce_product_platform_id~="" and msg_body.oce_oce_product_platform_idproduct_id~=nil then
+        oce_product_platform_id_param = string.format(" AND oce_product_platform_id =  '%s' ",msg_body.oce_product_platform_id) 
+    end
+
     local delivery_mode_param = ""
     if msg_body.delivery_mode~="" and msg_body.delivery_mode~=nil then
         delivery_mode_param = string.format(" AND delivery_mode =  '%s' ",msg_body.delivery_mode) 
@@ -152,8 +185,7 @@ function M.search(msg_body)
     --     genre_param =  string.format(" AND genre = %d ",msg_body.genre) 
     -- end
 
-    local 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..wx_miniapp_create_status_param..material_platform_id_param;
-
+    local 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..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)
     skynet.error("sql:",sql)
@@ -176,13 +208,20 @@ end
 -- `daily_new_limit` int DEFAULT '0' COMMENT '今天新上数量上限',
 
 function M.addMain(msg_body)
-    local isok ,key =  tools.checkData({"oce_product_id","oce_product_platform_id","material_platform_id","strategy_config","delivery_mode","price","pack_strategy_status","start_chapter","advertiser_id","wx_miniapp_create_status","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({"cbo_script_time","cbo_script_status","cbo_status","project_type","tf_status","tf_start_time","stat_cost","oce_product_id","oce_product_platform_id","material_platform_id","strategy_config","delivery_mode","price","pack_strategy_status","start_chapter","advertiser_id","wx_miniapp_create_status","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` (oce_product_id,oce_product_platform_id,material_platform_id,strategy_config,delivery_mode,price,pack_strategy_status,start_chapter,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 ('%s','%s',%d,'%s','%s',%d,%d,%d,%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` (cbo_script_time,cbo_script_status,cbo_status,project_type,tf_status,tf_start_time,stat_cost,oce_product_id,oce_product_platform_id,material_platform_id,strategy_config,delivery_mode,price,pack_strategy_status,start_chapter,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 ( '%s',%d,%d,%d,%d,'%s',%d,'%s','%s',%d,'%s','%s',%d,%d,%d,%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.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.stat_cost,
     msg_body.oce_product_id,
     msg_body.oce_product_platform_id,
     msg_body.material_platform_id,
@@ -240,12 +279,14 @@ function M.addMain(msg_body)
 end
 --此主体将书库的书都发布到小程序书籍
 function M.syncMain(msg_body)
-    local isok ,key =  tools.checkData({"id"},msg_body)
+    local isok ,key =  tools.checkData({"id","min_stat_cost","max_stat_cost"},msg_body)
     if not isok then
         return false,string.format("缺少字段: %s.", key)
     end
     local sql = string.format("select * from `tg_main` where id = %d LIMIT 1 ",msg_body.id)
     local res = mysqldbx.query(sql)
+    res[1].min_stat_cost = msg_body.min_stat_cost
+    res[1].max_stat_cost = msg_body.max_stat_cost
     syncMainAppletProduct(res[1])
     return true,{}
 end
@@ -353,7 +394,7 @@ local function combine_query_and_params(query, params)
     return combined_query
 end
 function M.modifyMain(msg_body)
-    local isok ,key =  tools.checkData({"oce_product_id","oce_product_platform_id","material_platform_id","strategy_config","delivery_mode","price","pack_strategy_status","start_chapter","advertiser_id","wx_miniapp_create_status","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({ "cbo_script_time","cbo_script_status","cbo_status","project_type","tf_status","tf_start_time","stat_cost","oce_product_id","oce_product_platform_id","material_platform_id","strategy_config","delivery_mode","price","pack_strategy_status","start_chapter","advertiser_id","wx_miniapp_create_status","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
@@ -363,6 +404,13 @@ function M.modifyMain(msg_body)
 
     local query = [[
     UPDATE `tg_main` SET
+        cbo_script_time = ?,
+        cbo_script_status = ?,
+        cbo_status = ?,
+        project_type = ?,
+        tf_status = ?,
+        tf_start_time = ?,
+        stat_cost = ?,
         oce_product_id = ?,
         oce_product_platform_id = ?,
         material_platform_id = ?,
@@ -417,6 +465,13 @@ function M.modifyMain(msg_body)
 ]]
 
 local params = {
+    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.stat_cost,
     msg_body.oce_product_id,
     msg_body.oce_product_platform_id,
     msg_body.material_platform_id,

+ 4 - 2
service/backmgr/filter_task.lua

@@ -339,9 +339,11 @@ function M.send_book_data(msg_body)
         local sql = string.format("SELECT * FROM video_applet_product where product_id = '%s' and book_platform  = %d and dy_small_applet_app_id = '%s' and main_id = %d ",product_id,msg_body.tg_platform_id,msg_body.app_id,msg_body.main_id)
         local result = mysqldtaskbx.Singleton().query(sql)
         if #result<=0 then 
-            sql = string.format("INSERT INTO `video_applet_product` (product_id,product_name,book_platform,dy_small_applet_app_id,main_id,wait_status,status)  VALUES ('%s','%s',%d,'%s',%d,%d,%d)",
-            product_id,product_name,msg_body.tg_platform_id,msg_body.app_id,msg_body.main_id,0,0)
+            local butler_info = mysqldbx.query( "SELECT  butler_id  FROM tg_main WHERE id = "..msg_body.main_id.." LIMIT 1")
+            sql = string.format("INSERT INTO `video_applet_product` (product_id,product_name,book_platform,dy_small_applet_app_id,main_id,wait_status,status,butler_id)  VALUES ('%s','%s',%d,'%s',%d,%d,%d,%d)",
+            product_id,product_name,msg_body.tg_platform_id,msg_body.app_id,msg_body.main_id,0,0, butler_info[1].butler_id)
             mysqldtaskbx.Singleton().query(sql)
+            skynet.error("sql:",sql)
         end
     end
     return true,{}

+ 88 - 14
service/backmgr/video_applet_product.lua

@@ -8,27 +8,57 @@ local config = require "run_config"
 local mysql = require "skynet.db.mysql"
 local db
 local mysqldtaskbx = {}
+
+function M.check_table_exists(table_name)
+    local sql = string.format("SHOW TABLES LIKE '%s'", table_name)
+    local res =  mysqldtaskbx.Singleton().query(sql)
+    return res and #res > 0
+end
+
 function M.add_applet_product(msg_body)
-    local isok ,key =  tools.checkData({"product_name","product_id","book_platform","dy_small_program_start","dy_small_program_start_data","dy_small_applet_app_id","check_url","main_id","status"},msg_body)
+
+    local isok ,key =  tools.checkData({"butler_id","product_name","product_id","book_platform","dy_small_program_start","dy_small_program_start_data","dy_small_applet_app_id","check_url","main_id","status"},msg_body)
     if not isok then
         return false,string.format("缺少字段: %s.", key)
     end
-    local sql = string.format("INSERT INTO `video_applet_product` (product_name,product_id,book_platform,dy_small_program_start,dy_small_program_start_data,dy_small_applet_app_id,check_url,main_id,status,wait_status)  VALUES ('%s','%s',%d,'%s','%s','%s','%s',%d,%d,%d)",
-    msg_body.product_name,msg_body.product_id,msg_body.book_platform,msg_body.dy_small_program_start,msg_body.dy_small_program_start_data,msg_body.dy_small_applet_app_id,msg_body.check_url,msg_body.main_id,msg_body.status,2)
+
+    local table_name = "video_applet_product_"..msg_body.butler_id
+
+    if msg_body.isOrigin == 1  then
+        table_name = "video_applet_product"
+    else
+        if not M.check_table_exists(table_name) then
+            return false,string.format("不存在  %s 这个数据.", table_name)
+        end
+    end
+
+    local sql = string.format("INSERT INTO `%s` (product_name,product_id,book_platform,dy_small_program_start,dy_small_program_start_data,dy_small_applet_app_id,check_url,main_id,status,wait_status)  VALUES ('%s','%s',%d,'%s','%s','%s','%s',%d,%d,%d)",
+    table_name,msg_body.product_name,msg_body.product_id,msg_body.book_platform,msg_body.dy_small_program_start,msg_body.dy_small_program_start_data,msg_body.dy_small_applet_app_id,msg_body.check_url,msg_body.main_id,msg_body.status,2)
     mysqldtaskbx.Singleton().query(sql)
     return true, {}
 end
 
 --开启小程序书籍任务
 function M.open_app_book_task(msg_body)
-    local isok ,key =  tools.checkData({"id_list"},msg_body)
+    local isok ,key =  tools.checkData({"butler_id","id_list"},msg_body)
     if not isok then
         return false,string.format("缺少字段: %s.", key)
     end
+
+    local table_name = "video_applet_product_"..msg_body.butler_id
+
+    if msg_body.isOrigin == 1  then
+        table_name = "video_applet_product"
+    else
+        if not M.check_table_exists(table_name) then
+            return false,string.format("不存在  %s 这个数据.", table_name)
+        end
+    end
+
     for i = 1, #msg_body.id_list, 1 do
         local res,sql,id;
         id = msg_body.id_list[i]
-        sql = string.format("UPDATE  video_applet_product SET status = 0 ,  wait_status = 0 ,is_close_execution = 1  WHERE id = %d ",id)
+        sql = string.format("UPDATE  '%s' SET status = 0 ,  wait_status = 0 ,is_close_execution = 1  WHERE id = %d ",table_name,id)
         res = mysqldtaskbx.Singleton().query(sql)
     end
     return true,{}
@@ -37,14 +67,25 @@ end
 
 --开启小程序书籍任务
 function M.open_app_book_task(msg_body)
-    local isok ,key =  tools.checkData({"id_list"},msg_body)
+    local isok ,key =  tools.checkData({"butler_id","id_list"},msg_body)
     if not isok then
         return false,string.format("缺少字段: %s.", key)
     end
+
+    local table_name = "video_applet_product_"..msg_body.butler_id
+
+    if msg_body.isOrigin == 1  then
+        table_name = "video_applet_product"
+    else
+        if not M.check_table_exists(table_name) then
+            return false,string.format("不存在  %s 这个数据.", table_name)
+        end
+    end
+
     for i = 1, #msg_body.id_list, 1 do
         local res,sql,id;
         id = msg_body.id_list[i]
-        sql = string.format("UPDATE  video_applet_product SET status = 0 ,  wait_status = 0 ,is_close_execution = 1  WHERE id = %d ",id)
+        sql = string.format("UPDATE  '%s' SET status = 0 ,  wait_status = 0 ,is_close_execution = 1  WHERE id = %d ",table_name,id)
         res = mysqldtaskbx.Singleton().query(sql)
     end
     return true,{}
@@ -52,12 +93,23 @@ end
 
 --开启检测链接任务
 function M.open_check_url_task(msg_body)
-    local isok ,key =  tools.checkData({"id_list"},msg_body)
+    local isok ,key =  tools.checkData({"butler_id","id_list"},msg_body)
     if not isok then
         return false,string.format("缺少字段: %s.", key)
     end
+
+    local table_name = "video_applet_product_"..msg_body.butler_id
+
+    if msg_body.isOrigin == 1  then
+        table_name = "video_applet_product"
+    else
+        if not M.check_table_exists(table_name) then
+            return false,string.format("不存在  %s 这个数据.", table_name)
+        end
+    end
+
     local idString = table.concat(msg_body.id_list, ",")
-    local sql = string.format("UPDATE  video_applet_product SET status = 0 ,  wait_status = 1   WHERE id IN (%s) ",idString)
+    local sql = string.format("UPDATE  '%s' SET status = 0 ,  wait_status = 1   WHERE id IN (%s) ",table_name,idString)
     skynet.error("sql:",sql)
     mysqldtaskbx.Singleton().query(sql)
     return true,{}
@@ -65,12 +117,23 @@ end
 
 --设置任务权重
 function M.set_task_weight(msg_body)
-    local isok ,key =  tools.checkData({"id_list","weight"},msg_body)
+    local isok ,key =  tools.checkData({"butler_id","id_list","weight"},msg_body)
     if not isok then
         return false,string.format("缺少字段: %s.", key)
     end
+
+    local table_name = "video_applet_product_"..msg_body.butler_id
+
+    if msg_body.isOrigin == 1  then
+        table_name = "video_applet_product"
+    else
+        if not M.check_table_exists(table_name) then
+            return false,string.format("不存在  %s 这个数据.", table_name)
+        end
+    end
+
     local idString = table.concat(msg_body.id_list, ",")
-    local sql = string.format("UPDATE  video_applet_product SET weight = %d    WHERE id IN (%s) ",msg_body.weight,idString)
+    local sql = string.format("UPDATE  '%s' SET weight = %d    WHERE id IN (%s) ",table_name,msg_body.weight,idString)
     skynet.error("sql:",sql)
     mysqldtaskbx.Singleton().query(sql)
     return true,{}
@@ -91,10 +154,21 @@ function M.search_app_book_data(msg_body)
     "main_id",
     "app_id",
     "page_size",
-    "page_number"},msg_body)
+    "page_number","butler_id"},msg_body)
     if not isok then
         return false,string.format("缺少字段: %s.", key)
     end
+
+    local table_name = "video_applet_product_"..msg_body.butler_id
+
+    if msg_body.isOrigin == 1  then
+        table_name = "video_applet_product"
+    else
+        if not M.check_table_exists(table_name) then
+            return false,string.format("不存在  %s 这个数据.", table_name)
+        end
+    end
+
     local page_size = msg_body.page_size
     local page_number = msg_body.page_number
     local offset = (page_number - 1) * page_size
@@ -128,10 +202,10 @@ function M.search_app_book_data(msg_body)
     local param = product_param..product_name_param..tg_platform_param..main_param..app_param..status_param;
 
 
-    local sql = "SELECT * FROM video_applet_product WHERE 1=1 "..param.." ORDER BY id DESC "..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
+    local sql = "SELECT * FROM "..table_name.." WHERE 1=1 "..param.." ORDER BY id DESC "..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
     local list = mysqldtaskbx.Singleton().query(sql)
 
-    sql = "SELECT   COUNT(*) AS total  FROM video_applet_product  WHERE 1=1 "..param.." ORDER BY id DESC "
+    sql = "SELECT   COUNT(*) AS total  FROM "..table_name.."  WHERE 1=1 "..param.." ORDER BY id DESC "
 
     local total = mysqldtaskbx.Singleton().query(sql)
 

+ 101 - 8
service/backmgr/video_product.lua

@@ -9,11 +9,7 @@ local mysql = require "skynet.db.mysql"
 local db
 local mysqldtaskbx = {}
 
---搜索书
---tg_platform_id 平台id
---product_id 书id
---product_name 书名
-function M.search_book_data(msg_body)
+function M.search_book_data_on_main(msg_body)
     local isok ,key =  tools.checkData({
     "alias_name",
     "product_name",
@@ -21,13 +17,24 @@ function M.search_book_data(msg_body)
     "tg_platform_id",
     "oce_material_id",
     "page_size",
-    "page_number","is_auto"},msg_body)
+    "page_number",
+    "is_auto",
+    "stat_cost",
+    "min_stat_cost",
+    "max_stat_cost"},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 stat_cost_param = ""
+    if msg_body.min_stat_cost~="" and msg_body.max_stat_cost~="" then
+        stat_cost_param =  string.format(" AND stat_cost >= %f  AND stat_cost <= %f ",msg_body.min_stat_cost,msg_body.max_stat_cost)
+    end
+
     local product_param = ""
     if msg_body.product_id~="" then
         product_param = string.format(" AND product_id = '%s' ",msg_body.product_id)
@@ -60,9 +67,12 @@ function M.search_book_data(msg_body)
         alias_name_param = string.format(" AND  ( alias_name LIKE CONCAT( '%%%s%%')) ",msg_body.alias_name)
     end
 
-    local param = product_param..product_name_param..tg_platform_param..is_auto_param..is_store_param..genre_param..alias_name_param;
+    local param = stat_cost_param..product_param..product_name_param..tg_platform_param..is_auto_param..is_store_param..genre_param..alias_name_param;
 
-    local sql = "SELECT * FROM video_product where 1=1 "..param.." ORDER BY id DESC "..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
+
+    local sql = "SELECT * FROM video_product where 1=1 "..param..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
+    
+    skynet.error("sql:",sql)
     local res = mysqldtaskbx.Singleton().query(sql)
 
     sql =  "SELECT  COUNT(*) AS total  FROM video_product where 1=1 "..param.."ORDER BY id DESC"
@@ -71,6 +81,89 @@ function M.search_book_data(msg_body)
 
     return true,res,total[1].total
 end
+--搜索书
+--tg_platform_id 平台id
+--product_id 书id
+--product_name 书名
+function M.search_book_data(msg_body)
+    local isok ,key =  tools.checkData({
+        "alias_name",
+        "product_name",
+        "product_id",
+        "tg_platform_id",
+        "oce_material_id",
+        "page_size",
+        "page_number",
+        "is_auto",
+        "stat_cost"},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 stat_cost_param = ""
+        if msg_body.stat_cost~="" then
+            if(msg_body.stat_cost == 0) then
+                stat_cost_param = " stat_cost ASC"
+            else
+                stat_cost_param = " stat_cost DESC"
+            end
+        end
+    
+        local product_param = ""
+        if msg_body.product_id~="" then
+            product_param = string.format(" AND product_id = '%s' ",msg_body.product_id)
+        end
+        local product_name_param = ""
+        if msg_body.product_name~="" then
+            product_name_param = string.format(" AND  ( product_name LIKE CONCAT( '%%%s%%')) ",msg_body.product_name)
+        end
+        local tg_platform_param = ""
+        if msg_body.tg_platform_id~="" then
+            tg_platform_param = string.format(" AND book_platform = %d ",msg_body.tg_platform_id) 
+        end
+        local is_auto_param = ""
+        if msg_body.is_auto~="" then
+            is_auto_param = " AND is_auto = "..msg_body.is_auto.." "
+        end
+    
+        local is_store_param = ""
+        if msg_body.is_store~="" then
+            is_store_param = " AND is_store = "..msg_body.is_store.." "
+        end
+    
+        local genre_param = ""
+        if msg_body.genre~="" then
+            genre_param = " AND genre = "..msg_body.genre.." "
+        end
+    
+        local alias_name_param = ""
+        if msg_body.alias_name~="" then
+            alias_name_param = string.format(" AND  ( alias_name LIKE CONCAT( '%%%s%%')) ",msg_body.alias_name)
+        end
+    
+        local param = product_param..product_name_param..tg_platform_param..is_auto_param..is_store_param..genre_param..alias_name_param;
+    
+        local up_down_param = stat_cost_param
+    
+        if up_down_param ~= "" then
+            up_down_param = " ORDER BY " ..up_down_param
+        else
+            up_down_param =  "ORDER BY id DESC"
+        end
+        local sql = "SELECT * FROM video_product where 1=1 "..param..up_down_param..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
+        
+    
+        local res = mysqldtaskbx.Singleton().query(sql)
+    
+        sql =  "SELECT  COUNT(*) AS total  FROM video_product where 1=1 "..param.."ORDER BY id DESC"
+    
+        local total = mysqldtaskbx.Singleton().query(sql)
+    
+        return true,res,total[1].total
+end
 
 --设置书别名
 function M.set_video_product_alias_name(msg_body)