904118851 8 tháng trước cách đây
mục cha
commit
c32a717c88

+ 18 - 0
service/agent.lua

@@ -48,6 +48,8 @@ function  M.status_task(id, msg)
         RECV_TASK.updateMainConfig()
         -- skynet.sleep(200)
         RECV_TASK.updatePlatformConfig()
+        RECV_TASK.updateFqKeyList()
+        RECV_TASK.updateBlackBooks()
     end)
 
 end
@@ -154,6 +156,22 @@ function RECV_TASK.addMain(msg_body)
     end
 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
+
+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
+
 local dispatch = function(session, address,id, addr,cmd,...)
     if(cmd=="connect") then
         connect(id,addr)

+ 22 - 0
service/agent_manager.lua

@@ -92,6 +92,28 @@ function CMD.addMain(_,msg_body)
         skynet.error("把任务放到队列")
     end
 end
+
+
+--更新番茄key列表
+function CMD.updateFqKeyList(_,msg_body) 
+    local agent = getOneAgent()
+    if agent~=nil then
+        skynet.call(agent,"lua",nil,nil,"updateFqKeyList",msg_body)
+    else
+        skynet.error("把任务放到队列")
+    end
+end
+
+--更新黑名单的书
+function CMD.updateBlackBooks(_,msg_body) 
+    local agent = getOneAgent()
+    if agent~=nil then
+        skynet.call(agent,"lua",nil,nil,"updateBlackBooks",msg_body)
+    else
+        skynet.error("把任务放到队列")
+    end
+end
+
 --收到一个获取黑岩书的任务
 function CMD.task_get_heiyan_book() 
     

+ 18 - 0
service/backmgr/book_black_list.lua

@@ -4,6 +4,11 @@ local mysqldbx = require "mysqldbx"
 local tools = require "tools"
 local skynet = require "skynet"
 
+function M.get_all_black_books()
+    local sql = "SELECT * FROM black_list "
+    local res = mysqldbx.query(sql)
+    return true,res
+end
 function M.add_book(msg_body)
     local isok ,key =  tools.checkData({"product_id","product_name"},msg_body)
     if not isok then
@@ -17,6 +22,7 @@ function M.add_book(msg_body)
     end
     sql = string.format("INSERT INTO `black_list` (product_id,product_name)  VALUES ('%s','%s')",msg_body.product_id,msg_body.product_name)
     mysqldbx.query(sql)
+    skynet.send("backmgr","lua","on_recv",nil,"push_msg","updateBlackBooks")
     return true, {}
 end
 
@@ -27,9 +33,21 @@ function M.delete_book(msg_body)
     end
     local sql = string.format("DELETE FROM black_list WHERE product_id = '%s' ",msg_body.product_id)
     mysqldbx.query(sql)
+    skynet.send("backmgr","lua","on_recv",nil,"push_msg","updateBlackBooks")
     return true, {}
 end
 
+function M.is_black_book(msg_body)
+    local isok ,key =  tools.checkData({"product_id"},msg_body)
+    if not isok then
+        return false,string.format("缺少字段: %s.", key)
+    end
+    local sql = string.format("SELECT * FROM black_list WHERE product_id = '%s' LIMIT 1", msg_body.product_id)
+    local isok,res;
+    res = mysqldbx.query(sql)
+    return true, {is_black_book = #res > 0}
+end
+
 function M.search_book_list(msg_body)
     local isok ,key =  tools.checkData({"page_size","page_number","product_id","product_name"},msg_body)
     if not isok then

+ 14 - 0
service/backmgr/filter_task.lua

@@ -117,6 +117,20 @@ function M.set_app_book_status(msg_body)
     return true,{}
 end
 
+--开启小程序书籍任务
+function M.open_app_book_task(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 res,sql,id;
+        id = msg_body.id_list[i]
+        sql = string.format("UPDATE  video_applet_product SET status = 0 ,  wait_status = 0 WHERE id = %d ",id)
+        res = mysqldtaskbx.Singleton().query(sql)
+    end
+    return true,{}
+end
 
 --获取推广数据总数
 function M.get_tui_guang_total()

+ 8 - 0
service/backmgr/fq_book.lua

@@ -4,6 +4,12 @@ local mysqldbx = require "mysqldbx"
 local tools = require "tools"
 local skynet = require "skynet"
 
+function M.get_all_fq_key()
+    local sql = "SELECT * FROM fq_book_config "
+    local res = mysqldbx.query(sql)
+    return true,res
+end
+
 function M.add_fq_book_sid_tt(msg_body)
     local isok ,key =  tools.checkData({"sid_tt","name"},msg_body)
     if not isok then
@@ -17,6 +23,7 @@ function M.add_fq_book_sid_tt(msg_body)
     end
     sql = string.format("INSERT INTO `fq_book_config` (sid_tt,name)  VALUES ('%s','%s')",msg_body.sid_tt,msg_body.name)
     mysqldbx.query(sql)
+    skynet.send("backmgr","lua","on_recv",nil,"push_msg","updateFqKeyList")
     return true, {}
 end
 
@@ -27,6 +34,7 @@ function M.delete_fq_book_sid_tt(msg_body)
     end
     local sql = string.format("DELETE FROM fq_book_config WHERE sid_tt = '%s' ",msg_body.sid_tt)
     mysqldbx.query(sql)
+    skynet.send("backmgr","lua","on_recv",nil,"push_msg","updateFqKeyList")
     return true, {}
 end
 

+ 2 - 0
service/backmgr/init.lua

@@ -18,6 +18,7 @@ local push_msg = require "push_msg"
 local filter_task = require "filter_task"
 local fq_book = require "fq_book"
 local book_black_list = require "book_black_list"
+local video_titles = require "video_titles"
 local status_200 = 200
 local CMD = {
     
@@ -34,6 +35,7 @@ CMD["push_msg"] = push_msg;
 CMD["filter_task"] = filter_task;
 CMD["fq_book"] = fq_book;
 CMD["book_black_list"] = book_black_list;
+CMD["video_titles"] = video_titles;
 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)

+ 68 - 0
service/backmgr/video_titles.lua

@@ -0,0 +1,68 @@
+--视频标题
+local M = {}
+local mysqldbx = require "mysqldbx"
+local tools = require "tools"
+local skynet = require "skynet"
+local md5 =	require	"md5"
+
+
+function M.add_video_title(msg_body)
+    local isok ,key =  tools.checkData({"title","md5_tag"},msg_body)
+    if not isok then
+        return false,string.format("缺少字段: %s.", key)
+    end
+    local sql = string.format("SELECT * FROM video_titles WHERE md5_tag = '%s' LIMIT 1", msg_body.md5_tag)
+    local isok,res;
+    res = mysqldbx.query(sql)
+    if #res > 0 then
+        return false ,"sid_tt :"..msg_body.sid_tt.." 已存在!"
+    end
+    sql = string.format("INSERT INTO `video_titles` (title,md5_tag)  VALUES ('%s','%s')",msg_body.title,msg_body.md5_tag)
+    mysqldbx.query(sql)
+    return true, {}
+end
+
+function M.delete_video_title(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_titles WHERE id = %d ",id)
+        mysqldbx.query(sql)
+    end
+    return true, {}
+end
+
+function M.search_video_title(msg_body)
+    local isok ,key =  tools.checkData({"page_size","page_number","content"},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 list = mysqldbx.query(sql)
+    sql = "SELECT   COUNT(*) AS total  FROM video_titles "..string.format(" WHERE  (title LIKE CONCAT( '%%%s%%')) ",msg_body.content)
+    local total = mysqldbx.query(sql)
+    return true,list,total[1].total
+end
+
+function M.initAll()
+    local sql = "SELECT * FROM video_titles "
+    local list = mysqldbx.query(sql)
+    for i = 1, #list, 1 do
+        if (list[i].md5_tag==nil) then
+            local id = list[i].id
+            local md5_tag =md5.sumhexa(list[i].title)
+            skynet.error("md5_tag:",md5_tag)
+            sql = string.format("UPDATE  video_titles SET md5_tag = '%s' WHERE id = %d ",md5_tag,id)
+            mysqldbx.query(sql)
+        end
+    end
+    return true,{}
+end
+return M