904118851 8 ماه پیش
والد
کامیت
c545d103f5

+ 1 - 1
common/dbproxy/tg_main.lua

@@ -53,7 +53,7 @@ function M.addMain(msg_body)
     ,msg_body.running_status,msg_body.ad_quantity,msg_body.cpa_bid,msg_body.bid_type,msg_body.bid_ratio,msg_body.custom_budget,msg_body.daily_new_limit,msg_body.valid_time,msg_body.group_id)
     mysqldbx.query(sql)
     skynet.send("backmgr","lua","on_recv",nil,"ws_push_msg",cjson.encode({cmd="updateMainConfig"}))
-    pushAddMainMsg(msg_body)
+    -- pushAddMainMsg(msg_body)
     return true
 end
 --此主体将书库的书都发布到小程序书籍

+ 13 - 4
common/dbproxy/tg_zhanghu.lua

@@ -97,7 +97,7 @@ function M.switch(msg_body)
     return true,{}
 end
 function M.mainFilter(msg_body)
-    local isok ,key =  tools.checkData({"main_id","page_size","page_number"},msg_body)
+    local isok ,key =  tools.checkData({"content","main_id","page_size","page_number"},msg_body)
     if not isok then
         return false,string.format("缺少字段: %s.", key)
     end
@@ -105,10 +105,19 @@ function M.mainFilter(msg_body)
     local page_number = msg_body.page_number
     local offset = (page_number - 1) * page_size
 
-    local sql = string.format(" SELECT COUNT(*) AS total FROM advertiser  WHERE main_id = %d ",  msg_body.main_id)
+    local main_id_param = ""
+    if msg_body.main_id ~= "" then
+        main_id_param = " AND main_id = "..msg_body.main_id.." "
+    end
+
+    local content_param = ""
+    if msg_body.content ~= "" then
+        content_param = string.format(" AND  (advertiser_name LIKE CONCAT( '%%%s%%')) OR (advertiser_id LIKE CONCAT('%%%s%%'))",msg_body.content,msg_body.content)
+    end
+    local sql = "SELECT COUNT(*) AS total FROM advertiser  WHERE 1=1 "..main_id_param..content_param
     local total = mysqldbx.query(sql)
-   
-    sql = string.format("SELECT * FROM advertiser  WHERE main_id = %d  ORDER BY id LIMIT %d OFFSET %d ", msg_body.main_id, page_size, offset)
+
+    sql = "SELECT * FROM advertiser  WHERE 1=1 "..main_id_param..content_param..string.format(" ORDER BY id LIMIT %d OFFSET %d ",page_size, offset)
     local res;
     res = mysqldbx.query(sql)
     return true,res,total[1].total

+ 13 - 28
service/backmgr/filter_data.lua

@@ -7,7 +7,7 @@ local cjson = require "cjson"
 
 function M.search_filter_data(msg_body)
     local isok ,key =  tools.checkData({"tg_platform_id","page_size","page_number",
-    "d_z","comment","collect","forward","product_id","source","start_publish_time","end_publish_time"},msg_body)
+    "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)
     end
@@ -16,44 +16,32 @@ function M.search_filter_data(msg_body)
     local offset = (page_number - 1) * page_size
 
     local tg_platform_id_param = ""
-    local isFirst = false
     if msg_body.tg_platform_id~="" then
-        isFirst = true;
-        tg_platform_id_param =  " tg_platform_id = "..msg_body.tg_platform_id.." "
+        tg_platform_id_param =  " AND tg_platform_id = "..msg_body.tg_platform_id.." "
     end
 
 
     local product_param = ""
     if msg_body.product_id~="" then
-        if isFirst == true then
-            product_param =  string.format(" AND book_id = '%s' ",tonumber(msg_body.product_id))
-        else
-            isFirst = true
-            product_param =  string.format(" book_id = '%s' ",tonumber(msg_body.product_id))
-        end
+        product_param =  string.format(" AND book_id = '%s' ",tonumber(msg_body.product_id))
     end
 
     local source_param = ""
     if msg_body.source~="" then
-        if isFirst == true then
-            source_param =  string.format(" AND source = '%s' ",msg_body.source)
-        else
-            isFirst = true
-            source_param =  string.format(" source = '%s' ",msg_body.source)
-        end
+        source_param =  string.format(" AND source = '%s' ",msg_body.source)
     end
 
     local date_param = ""
     if msg_body.start_publish_time~="" and msg_body.end_publish_time~="" then
-        if isFirst == true 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) .. "))"
-        else
-            isFirst = true
-            date_param = " 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
+        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 create_date_param = ""
+    if msg_body.start_create_time~="" and msg_body.end_create_time~="" then
+        create_date_param = " AND DATE(create_time) >= DATE(FROM_UNIXTIME(" .. (msg_body.start_create_time / 1000) .. ")) AND DATE(create_time) <= DATE(FROM_UNIXTIME(" .. (msg_body.end_create_time / 1000) .. "))"
+    end
+
     local d_z_param = ""
     if msg_body.d_z~="" then
         if(msg_body.d_z == 0) then
@@ -91,7 +79,7 @@ function M.search_filter_data(msg_body)
     end
     
 
-    local param = tg_platform_id_param..date_param..product_param..source_param
+    local param = tg_platform_id_param..date_param..create_date_param..product_param..source_param
 
     local up_down_param = d_z_param..comment_param..forward_param..collect_param
 
@@ -99,14 +87,11 @@ function M.search_filter_data(msg_body)
         up_down_param = " ORDER BY " ..up_down_param
     end
 
-    if param ~= "" then
-        param = " WHERE "..param
-    end
-    local sql = "SELECT * FROM filter_data "..param..up_down_param.."ORDER BY id DESC"..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
+    local sql = "SELECT * FROM filter_data WHERE 1=1 "..param..up_down_param.."ORDER BY id DESC"..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
 
     local res =  mysqldbx.query(sql)
 
-    sql =  "SELECT  COUNT(*) AS total  FROM filter_data  "..param
+    sql =  "SELECT  COUNT(*) AS total  FROM filter_data WHERE 1=1 "..param
 
     local total = mysqldbx.query(sql)
 

+ 14 - 65
service/backmgr/filter_task.lua

@@ -197,6 +197,7 @@ function M.tui_guang_zeng_liang(msg_body)
     return true,res
 end
 
+
 --搜索推广数据
 --oce_material_id 推广素材id
 --book_platform 平台id
@@ -218,107 +219,59 @@ function M.search_tg_data(msg_body)
     if not isok then
         return false,string.format("缺少字段: %s.", key)
     end
-    local isFirst = false
     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
-        isFirst = true
-        product_param =  string.format(" product_id = %d ",tonumber(msg_body.product_id))
+        product_param =  string.format(" AND 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
+        product_name_param = string.format("AND product_name = '%s' ",msg_body.product_name) 
     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
-            
+        if msg_body.dy_id~=0 then
+            is_auto_param = " AND dy_id != 0"
         else
-            isFirst = true;
-            if msg_body.dy_id~=0 then
-                is_auto_param = " dy_id != 0"
-            else
-                is_auto_param = " dy_id = 0"
-            end
-            
+            is_auto_param = " AND dy_id = 0"
         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
+        material_id_param =  string.format(" AND material_id = %d ",tonumber(msg_body.material_id)) 
     end
 
     local oce_material_param = ""
     if msg_body.oce_material_id~="" then
-        if isFirst == true then
-            oce_material_param =string.format("AND oce_material_id =  %d ",tonumber(msg_body.oce_material_id))
-        else
-            isFirst = true
-            oce_material_param =string.format(" oce_material_id =  %d ",tonumber(msg_body.oce_material_id))
-        end
+        oce_material_param =string.format("AND oce_material_id =  %d ",tonumber(msg_body.oce_material_id))
     end
     local tg_platform_param = ""
     if msg_body.tg_platform_id~="" then
-        if isFirst == true then
-            tg_platform_param = "AND book_platform = "..msg_body.tg_platform_id.." "
-        else
-            isFirst = true
-            tg_platform_param = " book_platform = "..msg_body.tg_platform_id.." "
-        end
+        tg_platform_param = "AND book_platform = "..msg_body.tg_platform_id.." "
     end
 
     local date_param = ""
     if msg_body.start_time_date~="" and msg_body.end_time_date~="" then
-        if isFirst == true then
-            date_param = " AND DATE(create_at) >= DATE(FROM_UNIXTIME(" .. (msg_body.start_time_date / 1000) .. ")) AND DATE(create_at) <= DATE(FROM_UNIXTIME(" .. (msg_body.end_time_date / 1000) .. "))"
-        else
-            isFirst = true
-            date_param = " DATE(create_at) >= DATE(FROM_UNIXTIME(" .. (msg_body.start_time_date / 1000) .. ")) AND DATE(create_at) <= DATE(FROM_UNIXTIME(" .. (msg_body.end_time_date / 1000) .. "))"
-        end
+        date_param = " AND DATE(create_at) >= DATE(FROM_UNIXTIME(" .. (msg_body.start_time_date / 1000) .. ")) AND DATE(create_at) <= DATE(FROM_UNIXTIME(" .. (msg_body.end_time_date / 1000) .. "))"
     end
 
     local sync_status_param = ""
 
     if msg_body.sync_status~="" then
-        if isFirst == true then
-            sync_status_param = "AND sync_status = "..msg_body.sync_status.." "
-        else
-            isFirst = true
-            sync_status_param = " sync_status = "..msg_body.sync_status.." "
-        end
+        sync_status_param = "AND sync_status = "..msg_body.sync_status.." "
     end
 
 
     local status_param = ""
 
     if msg_body.status~="" then
-        if isFirst == true then
-            status_param = "AND status = "..msg_body.status.." "
-        else
-            isFirst = true
-            status_param = " status = "..msg_body.status.." "
-        end
+        status_param = "AND status = "..msg_body.status.." "
     end
 
 
@@ -360,10 +313,6 @@ function M.search_tg_data(msg_body)
     
     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
 
-    if param ~= "" then
-        param = " WHERE "..param
-    end
-
     local up_down_param = d_z_param..comment_param..forward_param..collect_param
 
     if up_down_param ~= "" then
@@ -374,11 +323,11 @@ function M.search_tg_data(msg_body)
 
 
 
-    local sql = "SELECT * FROM video_material "..param..up_down_param..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
+    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)
 
-    sql =  "SELECT COUNT(*) AS total FROM video_material "..param.." ORDER BY id DESC "
+    sql =  "SELECT COUNT(*) AS total FROM video_material  WHERE  1=1 "..param.." ORDER BY id DESC "
     
     local total = mysqldbx.query(sql)
 

+ 2 - 0
service/backmgr/init.lua

@@ -23,6 +23,7 @@ local pull_data_config = require "pull_data_config"
 local pull_data_status = require "pull_data_status"
 local video_applet_product = require "video_applet_product"
 local filter_data = require "filter_data"
+local video_material = require "video_material"
 local status_200 = 200
 local CMD = {
     
@@ -44,6 +45,7 @@ CMD["pull_data_config"] = pull_data_config;
 CMD["pull_data_status"] = pull_data_status;
 CMD["video_applet_product"] = video_applet_product;
 CMD["filter_data"] = filter_data;
+CMD["video_material"] = video_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)

+ 31 - 0
service/backmgr/video_material.lua

@@ -0,0 +1,31 @@
+--推广
+local M = {}
+local mysqldbx = require "mysqldbx"
+local tools = require "tools"
+local skynet = require "skynet"
+local cjson = require "cjson"
+local config = require "run_config"
+local db
+--设置推广状态
+function M.set_tui_guang_status(msg_body)
+    local isok ,key =  tools.checkData({"id_list","status"},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_material WHERE id IN (%s)",idString)
+    local isok,res;
+    res = mysqldbx.query(sql)
+
+    for i = 1, #res, 1 do
+        local id =   res[i].id
+        local material_id = res[i].material_id
+        sql = string.format("UPDATE  video_material SET status = %d WHERE id =%d ",msg_body.status,id)
+        mysqldbx.query(sql)
+    end
+    
+    return true,{}
+end
+
+return M