904118851 пре 8 месеци
родитељ
комит
7b40c47b72

+ 6 - 5
common/dbproxy/tg_app.lua

@@ -21,13 +21,14 @@ end
 --小程序名称 name
 --添加小程序
 function M.addApp(msg_body)
-    local isok ,key =  tools.checkData({"tg_platform_id","app_id","instance_id","name","advertiser_id","landing_page","titles"},msg_body)
+    local isok ,key =  tools.checkData({"butler_id","tg_platform_id","app_id","instance_id","name","advertiser_id","landing_page","titles"},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_app` (tg_platform_id,app_id, instance_id, name,advertiser_id,landing_page,titles)  VALUES (%d,'%s','%s','%s','%s','%s','%s')",
+    local sql = string.format("INSERT INTO `tg_app` (butler_id,tg_platform_id,app_id, instance_id, name,advertiser_id,landing_page,titles)  VALUES (%d,%d,'%s','%s','%s','%s','%s','%s')",
+    msg_body.butler_id,
     msg_body.tg_platform_id,
     msg_body.app_id,
     msg_body.instance_id,msg_body.name,msg_body.advertiser_id,msg_body.landing_page,msg_body.titles)
@@ -39,14 +40,14 @@ end
 
 --修改小程序
 function M.modifyApp(msg_body)
-    local isok ,key =  tools.checkData({"id","tg_platform_id","app_id","instance_id","name","advertiser_id","landing_page","titles"},msg_body)
+    local isok ,key =  tools.checkData({"butler_id","id","tg_platform_id","app_id","instance_id","name","advertiser_id","landing_page","titles"},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_app` SET  tg_platform_id =%d ,app_id ='%s' , instance_id ='%s' , name ='%s' , advertiser_id ='%s'  , update_time ='%s'   , landing_page ='%s'  , titles ='%s' WHERE id = %d ",
-    msg_body.tg_platform_id,msg_body.app_id,msg_body.instance_id,msg_body.name,msg_body.advertiser_id,msg_body.update_time,msg_body.landing_page,msg_body.titles,msg_body.id)
+    local sql = string.format("UPDATE `tg_app` SET butler_id = %d , tg_platform_id =%d ,app_id ='%s' , instance_id ='%s' , name ='%s' , advertiser_id ='%s'  , update_time ='%s'   , landing_page ='%s'  , titles ='%s' WHERE id = %d ",
+    msg_body.butler_id,msg_body.tg_platform_id,msg_body.app_id,msg_body.instance_id,msg_body.name,msg_body.advertiser_id,msg_body.update_time,msg_body.landing_page,msg_body.titles,msg_body.id)
     mysqldbx.query(sql)
     skynet.send("backmgr","lua","on_recv",nil,"ws_push_msg",cjson.encode({cmd="updateAppConfig"}))
     return true

+ 7 - 3
service/agent.lua

@@ -165,7 +165,6 @@ end
 function RECV_TASK.addMain(msg_body)
     if AGENT_ID~=0 then
         isRunTask = true --工人进入工作状态
-        --根据主体匹配,筛选出需要创建推广连接的书
         websocket.write(AGENT_ID, cjson.encode({cmd="addMain",data=msg_body}))
     end
 end
@@ -173,7 +172,6 @@ end
 function RECV_TASK.updateFqKeyList(msg_body)
     if AGENT_ID~=0 then
         isRunTask = true --工人进入工作状态
-        --根据主体匹配,筛选出需要创建推广连接的书
         websocket.write(AGENT_ID, cjson.encode({cmd="updateFqKeyList",data=msg_body}))
     end
 end
@@ -181,11 +179,17 @@ end
 function RECV_TASK.updateBlackBooks(msg_body)
     if AGENT_ID~=0 then
         isRunTask = true --工人进入工作状态
-        --根据主体匹配,筛选出需要创建推广连接的书
         websocket.write(AGENT_ID, cjson.encode({cmd="updateBlackBooks",data=msg_body}))
     end
 end
 
+function RECV_TASK.syncMain(msg_body)
+    if AGENT_ID~=0 then
+        isRunTask = true --工人进入工作状态
+        websocket.write(AGENT_ID, cjson.encode({cmd="syncMain",data=msg_body}))
+    end
+end
+
 local dispatch = function(session, address,id, addr,cmd,...)
     if(cmd=="connect") then
         connect(id,addr)

+ 10 - 0
service/agent_manager.lua

@@ -124,6 +124,16 @@ function CMD.updatePullConig(_,msg_body)
     end
 end
 
+--同步主体
+function CMD.syncMain(_,msg_body) 
+    local agent = getOneAgent()
+    if agent~=nil then
+        skynet.call(agent,"lua",nil,nil,"syncMain",msg_body)
+    else
+        skynet.error("把任务放到队列")
+    end
+end
+
 skynet.start(function()
 	local protocol = "ws" 
 	-- for i= 1, 3 do --开启30个服务用来接收消息

+ 7 - 2
service/backmgr/filter_data.lua

@@ -6,7 +6,7 @@ local skynet = require "skynet"
 local cjson = require "cjson"
 
 function M.search_filter_data(msg_body)
-    local isok ,key =  tools.checkData({"tg_platform_id","page_size","page_number",
+    local isok ,key =  tools.checkData({"video_id","tg_platform_id","page_size","page_number",
     "d_z","comment","collect","forward","product_id","source","start_publish_time","end_publish_time","start_create_time","end_create_time"},msg_body)
     if not isok then
         return false,string.format("缺少字段: %s.", key)
@@ -26,6 +26,11 @@ function M.search_filter_data(msg_body)
         product_param =  string.format(" AND book_id = '%s' ",tonumber(msg_body.product_id))
     end
 
+    local video_id_param = ""
+    if msg_body.video_id~="" then
+        video_id_param =  " AND video_id = "..msg_body.video_id
+    end
+
     local source_param = ""
     if msg_body.source~="" then
         source_param =  string.format(" AND source = '%s' ",msg_body.source)
@@ -79,7 +84,7 @@ function M.search_filter_data(msg_body)
     end
     
 
-    local param = tg_platform_id_param..date_param..create_date_param..product_param..source_param
+    local param = tg_platform_id_param..date_param..create_date_param..product_param..source_param..video_id_param
 
     local up_down_param = d_z_param..comment_param..forward_param..collect_param
 

+ 11 - 94
service/backmgr/filter_task.lua

@@ -215,7 +215,7 @@ function M.search_tg_data(msg_body)
     "page_size",
     "page_number",
     "dy_id",
-"d_z","comment","collect","forward","status"},msg_body)
+"d_z","comment","collect","forward","status","signature","dy_id_1",},msg_body)
     if not isok then
         return false,string.format("缺少字段: %s.", key)
     end
@@ -274,6 +274,15 @@ function M.search_tg_data(msg_body)
         status_param = "AND status = "..msg_body.status.." "
     end
 
+    local signature_param = ""
+    if msg_body.signature~="" then
+        signature_param = string.format("AND signature = '%s' ",msg_body.signature)
+    end
+
+    local dy_id_1_param = ""
+    if msg_body.dy_id_1~="" then
+        dy_id_1_param = " AND dy_id =  "..tonumber(msg_body.dy_id_1)
+    end
 
     local d_z_param = ""
     if msg_body.d_z~="" then
@@ -311,7 +320,7 @@ function M.search_tg_data(msg_body)
         end
     end
     
-    local param = date_param..product_param..oce_material_param..status_param..tg_platform_param..sync_status_param..product_name_param..is_auto_param..material_id_param
+    local param = date_param..product_param..oce_material_param..status_param..tg_platform_param..sync_status_param..product_name_param..is_auto_param..material_id_param..signature_param..dy_id_1_param
 
     local up_down_param = d_z_param..comment_param..forward_param..collect_param
 
@@ -321,8 +330,6 @@ function M.search_tg_data(msg_body)
         up_down_param = " ORDER BY id DESC "
     end
 
-
-
     local sql = "SELECT * FROM video_material  WHERE  1=1 "..param..up_down_param..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
    
     local res = mysqldbx.query(sql)
@@ -442,97 +449,7 @@ function M.search_bao_liang_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({
-    "product_name",
-    "product_id",
-    "tg_platform_id",
-    "oce_material_id",
-    "page_size",
-    "page_number","is_auto"},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 product_param = ""
-    local isFirst = false
-    local and_param = " AND "
-    if msg_body.product_id~="" then
-        isFirst = true;
-        product_param = string.format(" product_id = '%s' ",msg_body.product_id)
-    end
-    local product_name_param = ""
-    if msg_body.product_name~="" then
-        if isFirst==true then
-            product_name_param = string.format("AND product_name = '%s' ",msg_body.product_name) 
-        else
-            isFirst = true;
-            product_name_param = string.format(" product_name = '%s' ",msg_body.product_name) 
-        end
-    end
-    local tg_platform_param = ""
-    if msg_body.tg_platform_id~="" then
-        if isFirst==true then
-            tg_platform_param = string.format("AND book_platform = %d ",msg_body.tg_platform_id) 
-        else
-            isFirst = true;
-            tg_platform_param = string.format(" book_platform = %d ",msg_body.tg_platform_id) 
-        end
-       
-    end
-    local is_auto_param = ""
-    if msg_body.is_auto~="" then
-        if isFirst==true then
-            is_auto_param = "AND is_auto = "..msg_body.is_auto.." "
-        else
-            isFirst = true;
-            is_auto_param = " is_auto = "..msg_body.is_auto.." "
-        end
-   
-    end
-
-    local is_store_param = ""
-    if msg_body.is_store~="" then
-        if isFirst==true then
-            is_store_param = "AND is_store = "..msg_body.is_store.." "
-        else
-            isFirst = true;
-            is_store_param = " is_store = "..msg_body.is_store.." "
-        end
-   
-    end
-
-    local genre_param = ""
-    if msg_body.genre~="" then
-        if isFirst==true then
-            genre_param = "AND genre = "..msg_body.genre.." "
-        else
-            isFirst = true;
-            genre_param = " genre = "..msg_body.genre.." "
-        end
-   
-    end
 
-    local param = product_param..product_name_param..tg_platform_param..is_auto_param..is_store_param..genre_param;
-
-    if param ~= "" then
-        param = " WHERE "..param
-    end
-    local sql = "SELECT * FROM video_product "..param.." ORDER BY id DESC "..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
-    local res = mysqldtaskbx.Singleton().query(sql)
-
-    sql =  "SELECT  COUNT(*) AS total  FROM video_product  "..param.."ORDER BY id DESC"
-
-    local total = mysqldtaskbx.Singleton().query(sql)
-
-    return true,res,total[1].total
-end
 
 --搜索小程序书
 --tg_platform_id 平台id

+ 2 - 0
service/backmgr/init.lua

@@ -32,6 +32,7 @@ local tg_mini_program_platform = require "tg_mini_program_platform"
 local task_material_queue_queue = require "task_material_queue_queue"
 local video_product = require "video_product"
 local origin_data = require "origin_data"
+local video_product_material = require "video_product_material"
 local status_200 = 200
 local CMD = {
     
@@ -62,6 +63,7 @@ CMD["tg_mini_program_platform"] = tg_mini_program_platform;
 CMD["task_material_queue_queue"] = task_material_queue_queue;
 CMD["video_product"] = video_product;
 CMD["origin_data"] = origin_data;
+CMD["video_product_material"] = video_product_material;
 function run(target,fun,msg_body,fd)
     if target~=nil and fun~=nil and target[fun]~=nil then
         local isok,data,total = target[fun](msg_body)

+ 8 - 2
service/backmgr/no_filter_origin.lua

@@ -12,7 +12,7 @@ function check_table_exists(table_name)
 end
 
 function M.search_no_filter_origin_data(msg_body)
-    local isok ,key =  tools.checkData({"date","page_size","page_number"},msg_body)
+    local isok ,key =  tools.checkData({"video_id","date","page_size","page_number"},msg_body)
     if not isok then
         return false,string.format("缺少字段: %s.", key)
     end
@@ -26,9 +26,15 @@ function M.search_no_filter_origin_data(msg_body)
     local page_number = msg_body.page_number
     local offset = (page_number - 1) * page_size
 
+    local video_id_param = ""
+    if msg_body.video_id~="" then
+        video_id_param =  " AND awemeId = "..msg_body.video_id
+    end
+
+    local param = video_id_param
     local up_down_param = " ORDER BY " .." likeCount DESC "
 
-    local sql = "SELECT * FROM "..table_name.." WHERE 1=1 "..up_down_param..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
+    local sql = "SELECT * FROM "..table_name.." WHERE 1=1 "..param..up_down_param..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
 
     local res =  mysqldbx.query(sql)
 

+ 1 - 1
service/backmgr/origin_data.lua

@@ -36,7 +36,7 @@ function M.search_origin_data(msg_body)
 
     local guajian_info_param = ""
     if msg_body.guajian_info~="" then
-        -- guajian_info_param =  string.format(" AND  ( guajian_link LIKE CONCAT( '%%%s%%')) ",msg_body.guajian_info)
+        guajian_info_param =  string.format(" AND  ( guajian_link LIKE CONCAT( '%%%s%%')) ",msg_body.guajian_info)
     end
 
     local param = date_param..create_date_param..guajian_info_param

+ 64 - 0
service/backmgr/video_product.lua

@@ -8,6 +8,70 @@ local config = require "run_config"
 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)
+    local isok ,key =  tools.checkData({
+    "alias_name",
+    "product_name",
+    "product_id",
+    "tg_platform_id",
+    "oce_material_id",
+    "page_size",
+    "page_number","is_auto"},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 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 sql = "SELECT * FROM video_product where 1=1 "..param.." ORDER BY id DESC "..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)
     local isok ,key =  tools.checkData({"id","alias_name"},msg_body)

+ 124 - 0
service/backmgr/video_product_material.lua

@@ -0,0 +1,124 @@
+--下载队列
+local M = {}
+local mysqldbx = require "mysqldbx"
+local tools = require "tools"
+local skynet = require "skynet"
+local cjson = require "cjson"
+
+function M.set_status(msg_body)
+    local isok ,key =  tools.checkData({"id_list","is_download","d_z_number"},msg_body)
+    if not isok then
+        return false,string.format("缺少字段: %s.", key)
+    end
+
+    local idString = table.concat(msg_body.id_list, ",")
+    local sql = string.format("SELECT * FROM video_product_material WHERE id IN (%s)",idString)
+    local isok,res;
+    res = mysqldbx.query(sql)
+
+    for i = 1, #res, 1 do
+        local id =   res[i].id
+        sql = string.format("UPDATE  video_product_material SET is_download = %d , d_z_number = %d WHERE id =%d ",msg_body.is_download,msg_body.d_z_number,id)
+        mysqldbx.query(sql)
+    end
+
+    return true,{}
+end
+
+function M.search_video_product_material(msg_body)
+    local isok ,key =  tools.checkData({"page_size",
+    "page_number",
+    "start_yun_fabu_time",
+    "end_yun_fabu_time",
+    "dy_id",
+    "product_id",
+    "product_name",
+    "book_platform",
+    "title",
+    "is_download",
+    "signature",
+    "cleaning_status"},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 dy_id_param = ""
+    if msg_body.dy_id~="" then
+        dy_id_param =  " AND dy_id = "..msg_body.dy_id
+    end
+
+    local product_id_param = ""
+    if msg_body.product_id~="" then
+        product_id_param =  " AND product_id = "..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 book_platform_param = ""
+    if msg_body.book_platform~="" then
+        book_platform_param =  " AND book_platform = "..msg_body.book_platform
+    end
+
+    local title_param = ""
+    if msg_body.title~="" then
+        title_param =    string.format(" AND  ( product_name LIKE CONCAT( '%%%s%%'))  ",msg_body.title)
+    end
+
+    local is_download_param = ""
+    if msg_body.is_download~="" then
+        is_download_param =   " AND is_download = "..msg_body.is_download
+    end
+
+
+    local status_param = ""
+    -- if msg_body.status~="" then
+    --     status_param = " AND status = "..msg_body.status
+    -- end
+
+    local signature_param = ""
+    if msg_body.signature~="" then
+        signature_param = string.format(" AND signature = '%s' ",msg_body.signature) 
+    end
+
+    local cleaning_status_param = ""
+    if msg_body.cleaning_status~="" then
+        cleaning_status_param = " AND cleaning_status = "..msg_body.cleaning_status
+    end
+
+    local yun_fabu_time_date_param = ""
+    if msg_body.start_yun_fabu_time~="" and msg_body.end_yun_fabu_time~="" then
+        yun_fabu_time_date_param = " AND DATE(yun_fabu_time) >= DATE(FROM_UNIXTIME(" .. (msg_body.start_yun_fabu_time / 1000) .. ")) AND DATE(yun_fabu_time) <= DATE(FROM_UNIXTIME(" .. (msg_body.end_yun_fabu_time / 1000) .. "))"
+    end
+
+    local param = dy_id_param..product_id_param..product_name_param..book_platform_param..title_param..is_download_param..status_param..yun_fabu_time_date_param..cleaning_status_param
+
+    local sql = "SELECT * FROM video_product_material WHERE dy_id!=0  "..param..  " ORDER BY update_time DESC "..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
+   
+    local list = mysqldbx.query(sql)
+
+    sql = "SELECT   COUNT(*) AS total  FROM video_product_material  WHERE dy_id!=0  "..param
+
+    local total = mysqldbx.query(sql)
+
+    return true,list,total[1].total
+end
+
+function M.delete_video_product_material(msg_body)
+    local isok ,key =  tools.checkData({"id_list"},msg_body)
+    if not isok then
+        return false,string.format("缺少字段: %s.", key)
+    end
+    for i = 1, #msg_body.id_list, 1 do
+        local id = msg_body.id_list[i]
+        local sql = string.format("DELETE FROM video_product_material WHERE id = %d ",id)
+        mysqldbx.query(sql)
+    end
+    return true, {}
+end
+return M