904118851 преди 4 месеца
родител
ревизия
eb4f8ba76c
променени са 4 файла, в които са добавени 177 реда и са изтрити 12 реда
  1. 2 0
      service/backmgr/init.lua
  2. 40 9
      service/backmgr/video_product.lua
  3. 30 3
      service/backmgr/video_product_material.lua
  4. 105 0
      service/backmgr/whitelist_books.lua

+ 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 whitelist_books = require "whitelist_books"
 local video_titles = require "video_titles"
 local pull_data_config = require "pull_data_config"
 local pull_data_config2 = require "pull_data_config2"
@@ -102,6 +103,7 @@ CMD["xs_origin_data"] = xs_origin_data;
 CMD["statistics_platform"] = statistics_platform;
 CMD["data_manager"] = data_manager;
 CMD["review_user"] = review_user;
+CMD["whitelist_books"] = whitelist_books;
 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)

+ 40 - 9
service/backmgr/video_product.lua

@@ -50,7 +50,7 @@ function M.search_book_data_on_main(msg_body)
     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)
@@ -90,7 +90,6 @@ function M.search_book_data_on_main(msg_body)
 
     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..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
     
     skynet.error("sql:",sql)
@@ -108,6 +107,9 @@ end
 --product_name 书名
 function M.search_book_data(msg_body)
     local isok ,key =  tools.checkData({
+        "start_publish_time",
+        "end_publish_time",
+        "up_or_down_publish_time",
         "alias_name",
         "product_name",
         "product_id",
@@ -124,6 +126,21 @@ function M.search_book_data(msg_body)
         local page_number = msg_body.page_number
         local offset = (page_number - 1) * page_size
     
+
+        local date_param = ""
+        if msg_body.start_publish_time~="" and msg_body.end_publish_time~="" then
+            date_param = " AND DATE(publish_time) >= DATE(FROM_UNIXTIME(" .. (msg_body.start_publish_time / 1000) .. ")) AND DATE(publish_time) <= DATE(FROM_UNIXTIME(" .. (msg_body.end_publish_time / 1000) .. ")) "
+        end
+    
+        local up_or_down_publish_time_param = ""
+        if msg_body.up_or_down_publish_time~="" then
+            if(msg_body.up_or_down_publish_time == 0) then
+                up_or_down_publish_time_param = " publish_time ASC"
+            else
+                up_or_down_publish_time_param = " publish_time DESC"
+            end
+        end
+
         local stat_cost_param = ""
         if msg_body.stat_cost~="" then
             if(msg_body.stat_cost == 0) then
@@ -165,18 +182,32 @@ 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 up_down_param = stat_cost_param
+        local param = date_param..product_param..product_name_param..tg_platform_param..is_auto_param..is_store_param..genre_param..alias_name_param;
     
+
+        local up_down_param = ""
+
+        
+        if up_or_down_publish_time_param ~= "" then
+            up_down_param = up_or_down_publish_time_param
+        end
+
+        if stat_cost_param ~= "" then
+            if (up_down_param~="") then
+                up_down_param = up_down_param.." , "..stat_cost_param
+            else
+                up_down_param = stat_cost_param
+            end
+            
+        end
+
         if up_down_param ~= "" then
-            up_down_param = " ORDER BY " ..up_down_param
-        else
-            up_down_param =  "ORDER BY id DESC"
+            up_down_param = " ORDER BY "..up_down_param
         end
+
         local sql = "SELECT * FROM video_product where 1=1 "..param..up_down_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"

+ 30 - 3
service/backmgr/video_product_material.lua

@@ -49,7 +49,11 @@ function M.set_d_z_number(msg_body)
 end
 
 function M.search_video_product_material(msg_body)
-    local isok ,key =  tools.checkData({"page_size",
+    local isok ,key =  tools.checkData({
+    "start_publish_time",
+    "end_publish_time",
+    "up_or_down_publish_time",
+    "page_size",
     "page_number",
     "start_create_time",
     "end_create_time",
@@ -68,6 +72,20 @@ function M.search_video_product_material(msg_body)
     local page_number = msg_body.page_number
     local offset = (page_number - 1) * page_size
 
+    local date_param = ""
+    if msg_body.start_publish_time~="" and msg_body.end_publish_time~="" then
+        date_param = " AND DATE(publish_time) >= DATE(FROM_UNIXTIME(" .. (msg_body.start_publish_time / 1000) .. ")) AND DATE(publish_time) <= DATE(FROM_UNIXTIME(" .. (msg_body.end_publish_time / 1000) .. ")) "
+    end
+
+    local up_or_down_publish_time_param = ""
+    if msg_body.up_or_down_publish_time~="" then
+        if(msg_body.up_or_down_publish_time == 0) then
+            up_or_down_publish_time_param = " publish_time ASC"
+        else
+            up_or_down_publish_time_param = " publish_time DESC"
+        end
+    end
+
     local dy_id_param = ""
     if msg_body.dy_id~="" then
         dy_id_param =  " AND dy_id = "..msg_body.dy_id
@@ -120,10 +138,19 @@ function M.search_video_product_material(msg_body)
         create_date_param = " AND DATE(create_at) >= DATE(FROM_UNIXTIME(" .. (msg_body.start_create_time / 1000) .. ")) AND DATE(create_at) <= DATE(FROM_UNIXTIME(" .. (msg_body.end_create_time / 1000) .. "))"
     end
 
-    local param = dy_id_param..product_id_param..product_name_param..book_platform_param..title_param..is_download_param..status_param..create_date_param..cleaning_status_param
+    local param = date_param..dy_id_param..product_id_param..product_name_param..book_platform_param..title_param..is_download_param..status_param..create_date_param..cleaning_status_param
+
+    local up_down_param = up_or_down_publish_time_param
+
+    if up_down_param~="" then
+        up_down_param = " ORDER BY "..up_down_param
+    else
+        up_down_param = "  ORDER BY  update_time DESC "
+    end
 
-    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 sql = "SELECT * FROM video_product_material WHERE dy_id!=0  "..param.. up_down_param..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
    
+    skynet.error("sql:",sql)
     local list =  mysqldtaskbx.Singleton().query(sql)
 
     sql = "SELECT   COUNT(*) AS total  FROM video_product_material  WHERE dy_id!=0  "..param

+ 105 - 0
service/backmgr/whitelist_books.lua

@@ -0,0 +1,105 @@
+--白名单
+local M = {}
+local mysqldbx = require "mysqldbx"
+local tools = require "tools"
+local skynet = require "skynet"
+local cjson = require "cjson"
+function M.get_all_black_books()
+    local sql = "SELECT * FROM whitelist_books "
+    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
+        return false,string.format("缺少字段: %s.", key)
+    end
+    local sql = string.format("SELECT * FROM whitelist_books WHERE product_id = '%s' LIMIT 1", msg_body.product_id)
+    local isok,res;
+    res = mysqldbx.query(sql)
+    if #res > 0 then
+        return false ,"product_id :"..msg_body.product_id.." 已存在!"
+    end
+    sql = string.format("INSERT INTO `whitelist_books` (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,"ws_push_msg",cjson.encode({cmd="updateBlackBooks"}))
+    return true, {}
+end
+
+function M.delete_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("DELETE FROM whitelist_books WHERE product_id = '%s' ",msg_body.product_id)
+    mysqldbx.query(sql)
+    skynet.send("backmgr","lua","on_recv",nil,"ws_push_msg",cjson.encode({cmd="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 whitelist_books 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.who_at_in_black(msg_body)
+    local isok ,key =  tools.checkData({"id_list"},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 whitelist_books WHERE  product_id IN (%s)",idString)
+    local isok,res;
+    res = mysqldbx.query(sql)
+    return true,res
+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
+        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 isFirst = false
+    local product_param = ""
+
+    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 param = product_param..product_name_param
+
+    if param ~= "" then
+        param = " WHERE "..param
+    end
+
+    local sql = "SELECT * FROM whitelist_books "..param..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
+   
+    local list = mysqldbx.query(sql)
+
+    sql = "SELECT   COUNT(*) AS total  FROM whitelist_books "..param
+
+    local total = mysqldbx.query(sql)
+
+    return true,list,total[1].total
+end
+
+return M