904118851 8 місяців тому
батько
коміт
b2b61b73dd

+ 19 - 0
common/dbproxy/tg_main.lua

@@ -152,6 +152,25 @@ function M.tgLinkConfig(msg_body)
     return true, {}
 end
 
+--获取主体下的运行总数
+function M.get_main_ad_run_number(msg_body)
+    local isok ,key =  tools.checkData({"main_id"},msg_body)
+    if not isok then
+        return false,string.format("缺少字段: %s.", key)
+    end
+    local sql ="SELECT * FROM advertiser WHERE main_id = " .. msg_body.main_id;
+    local res = mysqldbx.query(sql)
+    local all_run_number = 0
+    for i = 1, #res, 1 do
+        local run_number = res[i].ad_run_number
+        all_run_number = all_run_number + run_number
+    end
+    local nums = #res
+    sql = string.format("select * from `tg_main` where id = %d LIMIT 1 ",msg_body.main_id)
+    res = mysqldbx.query(sql)
+    local max = nums * res[1].ad_quantity
+    return true,{all_run_number=all_run_number,max=max}
+end
 
 function mysqldtaskbx.start()
     local function on_connect(db)

+ 75 - 0
service/backmgr/book_black_list.lua

@@ -0,0 +1,75 @@
+--黑名单
+local M = {}
+local mysqldbx = require "mysqldbx"
+local tools = require "tools"
+local skynet = require "skynet"
+
+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 black_list 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 `black_list` (product_id,product_name)  VALUES ('%s','%s')",msg_body.product_id,msg_body.product_name)
+    mysqldbx.query(sql)
+    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 black_list WHERE product_id = '%s' ",msg_body.product_id)
+    mysqldbx.query(sql)
+    return true, {}
+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 black_list "..param..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
+   
+    local list = mysqldbx.query(sql)
+
+    sql = "SELECT   COUNT(*) AS total  FROM black_list "..param
+
+    local total = mysqldbx.query(sql)
+
+    return true,list,total[1].total
+end
+
+return M

+ 91 - 7
service/backmgr/filter_task.lua

@@ -160,7 +160,7 @@ end
 
 --推广增量
 function M.tui_guang_zeng_liang(msg_body)
-    local isok ,key =  tools.checkData({"main_id","quantity","bid_type","id_list","is_rise"},msg_body)
+    local isok ,key =  tools.checkData({"main_id","quantity","bid_type","id_list","is_rise","is_new"},msg_body)
     if not isok then
         return false,string.format("缺少字段: %s.", key)
     end
@@ -175,8 +175,8 @@ function M.tui_guang_zeng_liang(msg_body)
         sql = string.format("UPDATE  video_material SET bl_status = 1 WHERE id =%d ",id)
         mysqldbx.query(sql)
 
-        sql = string.format("INSERT INTO `task_boost_material_queue` (material_id,main_id,quantity,bid_type,is_rise)  VALUES (%d,%d,%d,%d,%d)",
-        material_id,msg_body.main_id,msg_body.quantity,msg_body.bid_type,msg_body.is_rise)
+        sql = string.format("INSERT INTO `task_boost_material_queue` (material_id,main_id,quantity,bid_type,is_rise,is_new)  VALUES (%d,%d,%d,%d,%d,%d)",
+        material_id,msg_body.main_id,msg_body.quantity,msg_body.bid_type,msg_body.is_rise,msg_body.is_new)
         mysqldbx.query(sql)
 
     end
@@ -195,8 +195,12 @@ function M.search_tg_data(msg_body)
     "product_id",
     "tg_platform_id",
     "oce_material_id",
+    "product_name",
+    "material_id",
     "page_size",
-    "page_number"},msg_body)
+    "page_number",
+    "dy_id",
+"d_z","comment","collect","forward"},msg_body)
     if not isok then
         return false,string.format("缺少字段: %s.", key)
     end
@@ -209,6 +213,48 @@ function M.search_tg_data(msg_body)
         isFirst = true
         product_param =  string.format(" product_id = %d ",tonumber(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 is_auto_param = ""
+    if msg_body.dy_id~="" then
+        if isFirst==true then
+            if msg_body.dy_id~=0 then
+                is_auto_param = " AND dy_id != 0"
+            else
+                is_auto_param = " AND dy_id = 0"
+            end
+            
+        else
+            isFirst = true;
+            if msg_body.dy_id~=0 then
+                is_auto_param = " dy_id != 0"
+            else
+                is_auto_param = " dy_id = 0"
+            end
+            
+        end
+    end
+
+    local material_id_param = ""
+    if msg_body.material_id~="" then
+        if isFirst==true then
+            material_id_param =  string.format(" AND material_id = %d ",tonumber(msg_body.material_id)) 
+        else
+            isFirst = true;
+            material_id_param =  string.format("  material_id = %d ",tonumber(msg_body.material_id)) 
+        end
+    end
+
     local oce_material_param = ""
     if msg_body.oce_material_id~="" then
         if isFirst == true then
@@ -248,14 +294,53 @@ function M.search_tg_data(msg_body)
             sync_status_param = " sync_status = "..msg_body.sync_status.." "
         end
     end
+
+
+    local d_z_param = ""
+    if msg_body.d_z~="" then
+        if(msg_body.d_z == 0) then
+            d_z_param = ", d_z_number ASC"
+        else
+            d_z_param = ", d_z_number DESC"
+        end
+    end
+   
+    local comment_param = ""
+    if msg_body.comment~="" then
+        if(msg_body.comment == 0) then
+            comment_param = ", comment_number ASC"
+        else
+            comment_param = ", comment_number DESC"
+        end
+    end
+
+    local forward_param = ""
+    if msg_body.forward~="" then
+        if(msg_body.forward == 0) then
+            forward_param = ", forward_number ASC"
+        else
+            forward_param = ", forward_number DESC"
+        end
+    end
     
-    local param = date_param..product_param..oce_material_param..tg_platform_param..sync_status_param
+    local collect_param = ""
+    if msg_body.collect~="" then
+        if(msg_body.collect == 0) then
+            collect_param = ", collect_number ASC"
+        else
+            collect_param = ", collect_number DESC"
+        end
+    end
+    
+    local param = date_param..product_param..oce_material_param..tg_platform_param..sync_status_param..product_name_param..is_auto_param..material_id_param
 
     if param ~= "" then
         param = " WHERE "..param
     end
 
-    local sql = "SELECT * FROM video_material "..param.." ORDER BY id DESC "..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
+    local up_down_param = d_z_param..comment_param..forward_param..collect_param
+
+    local sql = "SELECT * FROM video_material "..param.." ORDER BY id DESC "..up_down_param..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
    
     local res = mysqldbx.query(sql)
 
@@ -495,7 +580,6 @@ function M.search_app_book_data(msg_body)
         else
             app_param = string.format(" dy_small_applet_app_id = '%s' ",msg_body.app_id) 
         end
-     
     end
 
     local param = product_param..product_name_param..tg_platform_param..main_param..app_param;

+ 47 - 0
service/backmgr/fq_book.lua

@@ -0,0 +1,47 @@
+--番茄
+local M = {}
+local mysqldbx = require "mysqldbx"
+local tools = require "tools"
+local skynet = require "skynet"
+
+function M.add_fq_book_sid_tt(msg_body)
+    local isok ,key =  tools.checkData({"sid_tt","name"},msg_body)
+    if not isok then
+        return false,string.format("缺少字段: %s.", key)
+    end
+    local sql = string.format("SELECT * FROM fq_book_config WHERE sid_tt = '%s' LIMIT 1", msg_body.sid_tt)
+    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 `fq_book_config` (sid_tt,name)  VALUES ('%s','%s')",msg_body.sid_tt,msg_body.name)
+    mysqldbx.query(sql)
+    return true, {}
+end
+
+function M.delete_fq_book_sid_tt(msg_body)
+    local isok ,key =  tools.checkData({"sid_tt"},msg_body)
+    if not isok then
+        return false,string.format("缺少字段: %s.", key)
+    end
+    local sql = string.format("DELETE FROM fq_book_config WHERE sid_tt = '%s' ",msg_body.sid_tt)
+    mysqldbx.query(sql)
+    return true, {}
+end
+
+function M.fq_book_list(msg_body)
+    local isok ,key =  tools.checkData({"page_size","page_number"},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 fq_book_config "..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
+    local list = mysqldbx.query(sql)
+    sql = "SELECT   COUNT(*) AS total  FROM fq_book_config "
+    local total = mysqldbx.query(sql)
+    return true,list,total[1].total
+end
+return M

+ 4 - 0
service/backmgr/init.lua

@@ -16,6 +16,8 @@ local tg_main   = require "tg_main"
 local db_filter_config = require "db_filter_config"
 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 status_200 = 200
 local CMD = {
     
@@ -30,6 +32,8 @@ CMD["tg_main"] = tg_main;
 CMD["db_filter_config"] = db_filter_config;
 CMD["push_msg"] = push_msg;
 CMD["filter_task"] = filter_task;
+CMD["fq_book"] = fq_book;
+CMD["book_black_list"] = book_black_list;
 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)

+ 13 - 0
service/doc/cmd_sql.sql

@@ -145,4 +145,17 @@ create table get_fq_book_tab (
 	info JSON  COMMENT  '详情',
 	primary key (id));
 
+create table fq_book_config (  
+	id int not null auto_increment COMMENT '唯一id',
+	sid_tt  varchar(100)  COMMENT 'sid_tt',	
+	create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+	primary key (id));
+
+create table black_list (  
+	id int not null auto_increment COMMENT '唯一id',
+	product_id  varchar(64),	
+	product_name  varchar(64),
+	create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+	primary key (id));
+