904118851 8 bulan lalu
induk
melakukan
64a01f9a5f

+ 1 - 2
common/dbproxy/tg_app.lua

@@ -32,7 +32,7 @@ function M.addApp(msg_body)
     msg_body.app_id,
     msg_body.instance_id,msg_body.name,msg_body.advertiser_id,msg_body.landing_page,msg_body.titles)
     mysqldbx.query(sql)
-    skynet.send("backmgr","lua","on_recv",nil,"push_msg","updateAppConfig")
+    kynet.send("backmgr","lua","on_recv",nil,"ws_push_msg",cjson.encode({cmd="updateAppConfig"}))
     return true
 end
 
@@ -53,5 +53,4 @@ function M.modifyApp(msg_body)
 end
 
 
-
 return M

+ 7 - 9
common/dbproxy/tg_main.lua

@@ -42,17 +42,16 @@ end
 -- `daily_new_limit` int DEFAULT '0' COMMENT '今天新上数量上限',
 
 function M.addMain(msg_body)
-    local isok ,key =  tools.checkData({"no_bid_budget","max_ad_quantity","tg_link_config","tg_platform_id","app_id","main_name","running_status","ad_quantity","cpa_bid","bid_type","bid_ratio","custom_budget","daily_new_limit","valid_time"},msg_body)
+    local isok ,key =  tools.checkData({"no_bid_budget","max_ad_quantity","tg_link_config","tg_platform_id","app_id","main_name","running_status","ad_quantity","cpa_bid","bid_type","bid_ratio","custom_budget","daily_new_limit","valid_time","group_id"},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_main` (no_bid_budget,max_ad_quantity,tg_link_config,tg_platform_id,app_id,main_name,running_status,ad_quantity,cpa_bid,bid_type,bid_ratio,custom_budget,daily_new_limit,valid_time)  VALUES (%d,%d,'%s',%d,'%s','%s',%d,%d,%d,%d,'%s',%d,%d,%d)",
+    local sql = string.format("INSERT INTO `tg_main` (no_bid_budget,max_ad_quantity,tg_link_config,tg_platform_id,app_id,main_name,running_status,ad_quantity,cpa_bid,bid_type,bid_ratio,custom_budget,daily_new_limit,valid_time,group_id)  VALUES (%d,%d,'%s',%d,'%s','%s',%d,%d,%d,%d,'%s',%d,%d,%d,'%s')",
         msg_body.no_bid_budget,msg_body.max_ad_quantity,cjson.encode(msg_body.tg_link_config),msg_body.tg_platform_id,msg_body.app_id,msg_body.main_name
-    ,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)
-    tools.dump(mysqldbx.query(sql))
-    skynet.error("sql:",sql)
+    ,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)
     return true
@@ -124,15 +123,15 @@ function pushAddMainMsg(msg_body)
    
 end
 function M.modifyMain(msg_body)
-    local isok ,key =  tools.checkData({"no_bid_budget","max_ad_quantity","tg_link_config","id","tg_platform_id","app_id","main_name","running_status","ad_quantity","cpa_bid","bid_type","bid_ratio","custom_budget","daily_new_limit","valid_time"},msg_body)
+    local isok ,key =  tools.checkData({"no_bid_budget","max_ad_quantity","tg_link_config","id","tg_platform_id","app_id","main_name","running_status","ad_quantity","cpa_bid","bid_type","bid_ratio","custom_budget","daily_new_limit","valid_time","group_id"},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_main` SET no_bid_budget = %d , max_ad_quantity = %d ,tg_platform_id = %d , app_id = '%s' ,main_name = '%s' , update_time = '%s' , running_status = %d ,ad_quantity = %d ,cpa_bid = %d ,bid_type = %d ,bid_ratio = '%s' ,custom_budget = %d ,daily_new_limit = %d ,valid_time = %d ,tg_link_config = '%s'  WHERE id = %d ",
+    local sql = string.format("UPDATE  `tg_main` SET no_bid_budget = %d , max_ad_quantity = %d ,tg_platform_id = %d , app_id = '%s' ,main_name = '%s' , update_time = '%s' , running_status = %d ,ad_quantity = %d ,cpa_bid = %d ,bid_type = %d ,bid_ratio = '%s' ,custom_budget = %d ,daily_new_limit = %d ,valid_time = %d ,tg_link_config = '%s' ,group_id = '%s' WHERE id = %d ",
     msg_body.no_bid_budget,msg_body.max_ad_quantity,msg_body.tg_platform_id,msg_body.app_id,msg_body.main_name,msg_body.update_time,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,cjson.encode(msg_body.tg_link_config),msg_body.id)
+    msg_body.daily_new_limit,msg_body.valid_time,cjson.encode(msg_body.tg_link_config),msg_body.group_id,msg_body.id)
     mysqldbx.query(sql)
     skynet.send("backmgr","lua","on_recv",nil,"ws_push_msg",cjson.encode({cmd="updateMainConfig"}))
     return true
@@ -193,7 +192,6 @@ function mysqldtaskbx.start()
 end
 
 
-
 function mysqldtaskbx.Singleton()
     if db == nil then
         mysqldtaskbx.start()

+ 12 - 11
common/dbproxy/tg_platform.lua

@@ -49,7 +49,7 @@ end
 
 --添加回传规则
 function M.addHuiChuanRule(msg_body)
-    local isok ,key =  tools.checkData({"name","id"},msg_body)
+    local isok ,key =  tools.checkData({"name","id","value"},msg_body)
     if not isok then
         return false,string.format("缺少字段: %s.", key)
     end
@@ -58,10 +58,9 @@ function M.addHuiChuanRule(msg_body)
     local obj = {}
     if res[1].huichuan~=nil then
         obj = cjson.decode(res[1].huichuan)
-        tools.dump(obj)
     end
     local id = #obj+1
-    table.insert(obj,id,{id=id,name=msg_body.name})
+    table.insert(obj,id,{id=id,name=msg_body.name,value=msg_body.value})
     sql = string.format("UPDATE `tg_platform` SET  huichuan = '%s'  WHERE id = %d ",
     cjson.encode(obj),msg_body.id)
     mysqldbx.query(sql)
@@ -71,7 +70,7 @@ end
 
 --修改回传规则
 function M.modifyHuiChuanRule(msg_body)
-    local isok ,key =  tools.checkData({"name","id","table_id"},msg_body)
+    local isok ,key =  tools.checkData({"name","id","value","table_id"},msg_body)
     if not isok then
         return false,string.format("缺少字段: %s.", key)
     end
@@ -84,6 +83,7 @@ function M.modifyHuiChuanRule(msg_body)
     for i = 1, #obj, 1 do
         if obj[i].id == msg_body.table_id then
             obj[i].name = msg_body.name
+            obj[i].value = msg_body.value
             break
         end
     end
@@ -96,7 +96,7 @@ end
 
 --添加收费卡点
 function M.addShouFeiKaDian(msg_body)
-    local isok ,key =  tools.checkData({"name","id"},msg_body)
+    local isok ,key =  tools.checkData({"name","id","value"},msg_body)
     if not isok then
         return false,string.format("缺少字段: %s.", key)
     end
@@ -105,10 +105,9 @@ function M.addShouFeiKaDian(msg_body)
     local obj = {}
     if res[1].kadian~=nil then
         obj = cjson.decode(res[1].kadian)
-        tools.dump(obj)
     end
     local id = #obj+1
-    table.insert(obj,id,{id=id,name=msg_body.name})
+    table.insert(obj,id,{id=id,name=msg_body.name,value=msg_body.value})
     sql = string.format("UPDATE `tg_platform` SET  kadian = '%s'  WHERE id = %d ",
     cjson.encode(obj),msg_body.id)
     mysqldbx.query(sql)
@@ -117,7 +116,7 @@ end
 
 --修改收费卡点
 function M.modifyShouFeiKaDian(msg_body)
-    local isok ,key =  tools.checkData({"name","id","table_id"},msg_body)
+    local isok ,key =  tools.checkData({"name","id","table_id","value"},msg_body)
     if not isok then
         return false,string.format("缺少字段: %s.", key)
     end
@@ -130,6 +129,7 @@ function M.modifyShouFeiKaDian(msg_body)
     for i = 1, #obj, 1 do
         if obj[i].id == msg_body.table_id then
             obj[i].name = msg_body.name
+            obj[i].value = msg_body.value
             break
         end
     end
@@ -141,7 +141,7 @@ end
 
 --添加充值模板
 function M.addChongZhiTemplate(msg_body)
-    local isok ,key =  tools.checkData({"name","id"},msg_body)
+    local isok ,key =  tools.checkData({"name","id","value"},msg_body)
     if not isok then
         return false,string.format("缺少字段: %s.", key)
     end
@@ -152,7 +152,7 @@ function M.addChongZhiTemplate(msg_body)
         obj = cjson.decode(res[1].chongzhi)
     end
     local id = #obj+1
-    table.insert(obj,id,{id=id,name=msg_body.name})
+    table.insert(obj,id,{id=id,name=msg_body.name,value=msg_body.value})
     sql = string.format("UPDATE `tg_platform` SET  chongzhi = '%s'  WHERE id = %d ",
     cjson.encode(obj),msg_body.id)
     mysqldbx.query(sql)
@@ -161,7 +161,7 @@ end
 
 --修改充值模板
 function M.modifyChongZhiTemplate(msg_body)
-    local isok ,key =  tools.checkData({"name","id","table_id"},msg_body)
+    local isok ,key =  tools.checkData({"name","id","table_id","value"},msg_body)
     if not isok then
         return false,string.format("缺少字段: %s.", key)
     end
@@ -174,6 +174,7 @@ function M.modifyChongZhiTemplate(msg_body)
     for i = 1, #obj, 1 do
         if obj[i].id == msg_body.table_id then
             obj[i].name = msg_body.name
+            obj[i].value = msg_body.value
             break
         end
     end

+ 3 - 3
service/backmgr/book_black_list.lua

@@ -3,7 +3,7 @@ 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 black_list "
     local res = mysqldbx.query(sql)
@@ -22,7 +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")
+    skynet.send("backmgr","lua","on_recv",nil,"ws_push_msg",cjson.encode({cmd="updateBlackBooks"}))
     return true, {}
 end
 
@@ -33,7 +33,7 @@ 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")
+    skynet.send("backmgr","lua","on_recv",nil,"ws_push_msg",cjson.encode({cmd="updateBlackBooks"}))
     return true, {}
 end
 

+ 17 - 12
service/backmgr/filter_task.lua

@@ -313,36 +313,36 @@ function M.search_tg_data(msg_body)
     local d_z_param = ""
     if msg_body.d_z~="" then
         if(msg_body.d_z == 0) then
-            d_z_param = ", d_z_number ASC"
+            d_z_param = " d_z_number ASC"
         else
-            d_z_param = ", d_z_number DESC"
+            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"
+            comment_param = " comment_number ASC"
         else
-            comment_param = ", comment_number DESC"
+            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"
+            forward_param = " forward_number ASC"
         else
-            forward_param = ", forward_number DESC"
+            forward_param = " forward_number DESC"
         end
     end
     
     local collect_param = ""
     if msg_body.collect~="" then
         if(msg_body.collect == 0) then
-            collect_param = ", collect_number ASC"
+            collect_param = " collect_number ASC"
         else
-            collect_param = ", collect_number DESC"
+            collect_param = " collect_number DESC"
         end
     end
     
@@ -354,12 +354,18 @@ function M.search_tg_data(msg_body)
 
     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)
+    if up_down_param ~= "" then
+        up_down_param = " ORDER BY " ..up_down_param
+    else
+        up_down_param = " ORDER BY id DESC "
+    end
+
+    local sql = "SELECT * FROM video_material "..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 "
+    
     local total = mysqldbx.query(sql)
 
     return true,res,total[1].total
@@ -527,7 +533,7 @@ function M.search_book_data(msg_body)
     sql =  "SELECT  COUNT(*) AS total  FROM video_product  "..param.."ORDER BY id DESC"
 
     local total = mysqldtaskbx.Singleton().query(sql)
-    tools.dump(total)
+
     return true,res,total[1].total
 end
 
@@ -675,7 +681,6 @@ function M.delete_book_data(msg_body)
         local id =   msg_body.id_list[i]
         local sql = string.format("DELETE FROM video_product WHERE id = %d ",id)
         local res = mysqldtaskbx.Singleton().query(sql)
-        tools.dump(res)
     end
 
     return true,{}

+ 3 - 2
service/backmgr/fq_book.lua

@@ -3,6 +3,7 @@ local M = {}
 local mysqldbx = require "mysqldbx"
 local tools = require "tools"
 local skynet = require "skynet"
+local cjson = require "cjson"
 
 function M.get_all_fq_key()
     local sql = "SELECT * FROM fq_book_config "
@@ -23,7 +24,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")
+    skynet.send("backmgr","lua","on_recv",nil,"ws_push_msg",cjson.encode({cmd="updateFqKeyList"}))
     return true, {}
 end
 
@@ -34,7 +35,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")
+    skynet.send("backmgr","lua","on_recv",nil,"ws_push_msg",cjson.encode({cmd="updateFqKeyList"}))
     return true, {}
 end
 

+ 24 - 8
service/backmgr/video_titles.lua

@@ -7,18 +7,24 @@ local md5 =	require	"md5"
 
 
 function M.add_video_title(msg_body)
-    local isok ,key =  tools.checkData({"title","md5_tag"},msg_body)
+    local isok ,key =  tools.checkData({"title_list"},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.." 已存在!"
+    for i = 1, #msg_body.title_list, 1 do
+        local title = msg_body.title_list[i].title
+        local md5_tag = msg_body.title_list[i].md5_tag
+        local sql = string.format("SELECT * FROM video_titles WHERE md5_tag = '%s' LIMIT 1", md5_tag)
+        local isok,res;
+        res = mysqldbx.query(sql)
+        if #res > 0 then
+
+        else
+            sql = string.format("INSERT INTO `video_titles` (title,md5_tag)  VALUES ('%s','%s')",title,md5_tag)
+            mysqldbx.query(sql)
+        end
+
     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
 
@@ -35,6 +41,16 @@ function M.delete_video_title(msg_body)
     return true, {}
 end
 
+function M.modify_video_title(msg_body)
+    local isok ,key =  tools.checkData({"title","md5_tag","id"},msg_body)
+    if not isok then
+        return false,string.format("缺少字段: %s.", key)
+    end
+    local sql = string.format("UPDATE  video_titles SET title = '%s' , md5_tag = '%s' WHERE id = %d ",msg_body.title,msg_body.md5_tag,msg_body.id)
+    mysqldbx.query(sql)
+    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

+ 6 - 0
service/doc/cmd_sql.sql

@@ -158,4 +158,10 @@ create table black_list (
 	create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
 	primary key (id));
 
+create table pull_log (  
+id int not null auto_increment COMMENT '唯一id',
+create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+primary key (id));
+
+