904118851 7 сар өмнө
parent
commit
9607699e86

+ 29 - 0
common/dbproxy/tg_app.lua

@@ -54,5 +54,34 @@ function M.modifyApp(msg_body)
     return true
 end
 
+function M.search(msg_body)
+    local isok ,key =  tools.checkData({"tg_platform_id","butler_id","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 tg_platform_id_param = ""
+    if msg_body.tg_platform_id~="" then
+        tg_platform_id_param = "AND tg_platform_id = "..msg_body.tg_platform_id.." "
+    end
+
+    local butler_id_param = ""
+    if msg_body.butler_id ~= "" then
+        butler_id_param = " AND butler_id = "..msg_body.butler_id.." "
+    end
+
+
+    local param = tg_platform_id_param..butler_id_param
+    local sql = "SELECT COUNT(*) AS total FROM tg_app  WHERE 1=1 "..param
+    local total = mysqldbx.query(sql)
+
+    sql = "SELECT * FROM tg_app  WHERE 1=1 "..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
+end
 
 return M

+ 37 - 17
common/dbproxy/tg_main.lua

@@ -64,7 +64,7 @@ end
 
 function M.search(msg_body)
 
-    local isok ,key =  tools.checkData({"page_size","page_number","main_name","running_status","custom_budget","pay_type","tg_platform_id","butler_id","tg_app_index","is_open_create_link","is_delete"},msg_body)
+    local isok ,key =  tools.checkData({"template_bid","cpa_bid","page_size","page_number","main_name","running_status","custom_budget","pay_type","tg_platform_id","butler_id","tg_app_index","is_open_create_link","is_delete"},msg_body)
    
     if not isok then
         return false,string.format("缺少字段: %s.", key)
@@ -119,10 +119,20 @@ function M.search(msg_body)
 
     local custom_budget_param = ""
     if msg_body.custom_budget~="" then
-        custom_budget_param = string.format(" AND custom_budget = %d ",msg_body.custom_budget) 
+        custom_budget_param = string.format(" AND custom_budget LIKE '%%%d%%' ", msg_body.custom_budget)
     end
 
-    local param = main_name_param..tg_platform_param..running_status_param..pay_type_param..butler_id_param..tg_app_index_param..is_open_create_link_param..is_delete_param..custom_budget_param;
+    local cpa_bid_param = ""
+    if msg_body.cpa_bid~="" then
+        cpa_bid_param = string.format(" AND cpa_bid LIKE '%%%d%%' ", msg_body.cpa_bid)
+    end
+
+    local template_bid_param = ""
+    if msg_body.template_bid~="" then
+        template_bid_param = string.format(" AND template_bid LIKE '%%%d%%' ", msg_body.template_bid)
+    end
+
+    local param = main_name_param..tg_platform_param..running_status_param..pay_type_param..butler_id_param..tg_app_index_param..is_open_create_link_param..is_delete_param..custom_budget_param..cpa_bid_param..template_bid_param;
 
     local sql = "SELECT * FROM tg_main where 1=1 "..param..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
     local res = mysqldbx.query(sql)
@@ -146,13 +156,15 @@ end
 -- `daily_new_limit` int DEFAULT '0' COMMENT '今天新上数量上限',
 
 function M.addMain(msg_body)
-    local isok ,key =  tools.checkData({"roi_goal","ql_bid","infra_status","pay_type","qm_id","ldy_template_site_id","yw_id","parent_platform_id","platform_shared_id","distributor_id","is_delete","ad_convert_type","aweme_id","tg_app_index","butler_id","mini_program_platform_id","landing_page","valid_timer_time","valid_timer_number","channelId","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)
+    local isok ,key =  tools.checkData({"template_bid","zh_id","roi_goal","ql_bid","infra_status","pay_type","qm_id","ldy_template_site_id","yw_id","parent_platform_id","platform_shared_id","distributor_id","is_delete","ad_convert_type","aweme_id","tg_app_index","butler_id","mini_program_platform_id","landing_page","valid_timer_time","valid_timer_number","channelId","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` (roi_goal,ql_bid,infra_status,pay_type,qm_id,ldy_template_site_id,yw_id,parent_platform_id,platform_shared_id,distributor_id,is_delete,ad_convert_type,aweme_id,tg_app_index,butler_id,mini_program_platform_id,landing_page,valid_timer_time,valid_timer_number,channelId,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,%d,%d,'%s','%s','%s',%d,%d,'%s',%d,'%s','%s', %d, %d, %d,'%s', %d, '%s', '%s',%d, %d, '%s', %d, '%s', '%s', %d, %d, %d,%d, '%s', %d, %d, '%s', '%s')",
+    local sql = string.format("INSERT INTO `tg_main` (template_bid,zh_id,roi_goal,ql_bid,infra_status,pay_type,qm_id,ldy_template_site_id,yw_id,parent_platform_id,platform_shared_id,distributor_id,is_delete,ad_convert_type,aweme_id,tg_app_index,butler_id,mini_program_platform_id,landing_page,valid_timer_time,valid_timer_number,channelId,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,'%s',%d,%d,%d,%d,'%s','%s','%s',%d,%d,'%s',%d,'%s','%s', %d, %d, %d,'%s', %d, '%s', '%s',%d, %d, '%s', %d, '%s', '%s', %d, %d, %d,%d, '%s', %d, %d, '%s', '%s')",
+    msg_body.template_bid,
+    msg_body.zh_id,
     msg_body.roi_goal,
     msg_body.ql_bid,
     msg_body.infra_status,
@@ -296,14 +308,14 @@ function pushAddMainMsg(msg_body)
    
 end
 function M.modifyMain(msg_body)
-    local isok ,key =  tools.checkData({"roi_goal","ql_bid","infra_status","pay_type","pay_type","qm_id","ldy_template_site_id","yw_id","parent_platform_id","platform_shared_id","distributor_id","is_delete","ad_convert_type","aweme_id","tg_app_index","butler_id","mini_program_platform_id","landing_page","valid_timer_time","valid_timer_number","channelId","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)
+    local isok ,key =  tools.checkData({"template_bid","zh_id","roi_goal","ql_bid","infra_status","pay_type","pay_type","qm_id","ldy_template_site_id","yw_id","parent_platform_id","platform_shared_id","distributor_id","is_delete","ad_convert_type","aweme_id","tg_app_index","butler_id","mini_program_platform_id","landing_page","valid_timer_time","valid_timer_number","channelId","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 roi_goal = %d , ql_bid = %d, infra_status = %d , pay_type = %d ,qm_id = '%s' , ldy_template_site_id = '%s' , yw_id = '%s' , parent_platform_id = %d , platform_shared_id = %d ,distributor_id = '%s' , is_delete = %d , ad_convert_type = '%s', aweme_id = '%s' ,tg_app_index = %d , butler_id = %d , mini_program_platform_id = %d , landing_page = '%s' , valid_timer_time = %d , valid_timer_number = %d ,channelId = '%s' , 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.roi_goal,msg_body.ql_bid,msg_body.infra_status,msg_body.pay_type,msg_body.qm_id,msg_body.ldy_template_site_id,msg_body.yw_id,msg_body.parent_platform_id,msg_body.platform_shared_id,msg_body.distributor_id,msg_body.is_delete,msg_body.ad_convert_type,msg_body.aweme_id,msg_body.tg_app_index,msg_body.butler_id,msg_body.mini_program_platform_id,msg_body.landing_page,tonumber(msg_body.valid_timer_time),tonumber(msg_body.valid_timer_number),msg_body.channelId,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,
+    local sql = string.format("UPDATE  `tg_main` SET template_bid = %d , zh_id = '%s', roi_goal = %d , ql_bid = %d, infra_status = %d , pay_type = %d ,qm_id = '%s' , ldy_template_site_id = '%s' , yw_id = '%s' , parent_platform_id = %d , platform_shared_id = %d ,distributor_id = '%s' , is_delete = %d , ad_convert_type = '%s', aweme_id = '%s' ,tg_app_index = %d , butler_id = %d , mini_program_platform_id = %d , landing_page = '%s' , valid_timer_time = %d , valid_timer_number = %d ,channelId = '%s' , 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.template_bid,msg_body.zh_id,msg_body.roi_goal,msg_body.ql_bid,msg_body.infra_status,msg_body.pay_type,msg_body.qm_id,msg_body.ldy_template_site_id,msg_body.yw_id,msg_body.parent_platform_id,msg_body.platform_shared_id,msg_body.distributor_id,msg_body.is_delete,msg_body.ad_convert_type,msg_body.aweme_id,msg_body.tg_app_index,msg_body.butler_id,msg_body.mini_program_platform_id,msg_body.landing_page,tonumber(msg_body.valid_timer_time),tonumber(msg_body.valid_timer_number),msg_body.channelId,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,
     tonumber(msg_body.daily_new_limit),tonumber(msg_body.valid_time),cjson.encode(msg_body.tg_link_config),msg_body.group_id,msg_body.id)
     tools.dump(mysqldbx.query(sql))
     skynet.send("backmgr","lua","on_recv",nil,"ws_push_msg",cjson.encode({cmd="updateMainConfig"}))
@@ -362,16 +374,24 @@ function M.search_info_by_id(msg_body)
     if not isok then
         return false,string.format("缺少字段: %s.", key)
     end
-    local temp = {}
-    for i = 1, #msg_body.query_list, 1 do
-        local main_id = msg_body.query_list[i]
-        local sql = string.format("SELECT * FROM tg_main WHERE id = %d LIMIT 1",main_id)
-        local res = mysqldbx.query(sql)
-        if #res >0 then
-            table.insert(temp,#temp+1,res[1])
-        end
+
+    local idString = table.concat(msg_body.query_list, ",")
+    local sql = string.format("SELECT * FROM tg_main WHERE id IN (%s)",idString)
+    local res = mysqldbx.query(sql)
+    return true,res
+end
+
+
+function M.search_info_by_tg_app_index(msg_body)
+    local isok ,key =  tools.checkData({"query_list"},msg_body)
+    if not isok then
+        return false,string.format("缺少字段: %s.", key)
     end
-    return true,temp
+
+    local idString = table.concat(msg_body.query_list, ",")
+    local sql = string.format("SELECT * FROM tg_main WHERE tg_app_index IN (%s)",idString)
+    local res = mysqldbx.query(sql)
+    return true,res
 end
 
 function mysqldtaskbx.start()

+ 8 - 0
service/agent.lua

@@ -50,6 +50,7 @@ function  M.status_task(id, msg)
         RECV_TASK.updatePlatformConfig()
         RECV_TASK.updateFqKeyList()
         RECV_TASK.updateFqMfKeyList()
+        RECV_TASK.updateYwKeyList()
         RECV_TASK.updateBlackBooks()
         RECV_TASK.getPullDataConfig()
     end)
@@ -184,6 +185,13 @@ function RECV_TASK.updateFqMfKeyList(msg_body)
     end
 end
 
+function RECV_TASK.updateYwKeyList(msg_body)
+    if AGENT_ID~=0 then
+        isRunTask = true --工人进入工作状态
+        websocket.write(AGENT_ID, cjson.encode({cmd="updateYwKeyList",data=msg_body}))
+    end
+end
+
 function RECV_TASK.updateBlackBooks(msg_body)
     if AGENT_ID~=0 then
         isRunTask = true --工人进入工作状态

+ 9 - 0
service/agent_manager.lua

@@ -113,6 +113,15 @@ function CMD.updateFqMfKeyList(_,msg_body)
     end
 end
 
+function CMD.updateYwKeyList(_,msg_body)
+    local agent = getOneAgent()
+    if agent~=nil then
+        skynet.call(agent,"lua",nil,nil,"updateYwKeyList",msg_body)
+    else
+        skynet.error("把任务放到队列")
+    end
+end
+
 --更新黑名单的书
 function CMD.updateBlackBooks(_,msg_body) 
     local agent = getOneAgent()

+ 2 - 0
service/backmgr/init.lua

@@ -41,6 +41,7 @@ local ad_convert_type = require "ad_convert_type"
 local other_book = require "other_book"
 local platform_shared = require "platform_shared"
 local material_review = require "material_review"
+local yw_book = require "yw_book"
 local status_200 = 200
 local CMD = {
     
@@ -80,6 +81,7 @@ CMD["ad_convert_type"] = ad_convert_type;
 CMD["other_book"] = other_book;
 CMD["platform_shared"] = platform_shared;
 CMD["material_review"] = material_review;
+CMD["yw_book"] = yw_book;
 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)

+ 11 - 4
service/backmgr/tg_main_price_template.lua

@@ -31,7 +31,7 @@ function M.modify_tg_main_price_template(msg_body)
 end
 
 function M.search_tg_main_price_template(msg_body)
-    local isok ,key =  tools.checkData({"page_size","page_number","name","status","tg_main_name","cpa_bid"},msg_body)
+    local isok ,key =  tools.checkData({"page_size","page_number","name","status","tg_main_name","cpa_bid","tg_main_id"},msg_body)
     if not isok then
         return false,string.format("缺少字段: %s.", key)
     end
@@ -41,7 +41,7 @@ function M.search_tg_main_price_template(msg_body)
 
     local name_param = ""
     if msg_body.name~="" then
-        name_param = string.format(" AND (tg_main_name LIKE '%%%s%%' ) ",msg_body.name)
+        name_param = string.format(" AND (name LIKE '%%%s%%' ) ",msg_body.name)
     end
 
     local tg_main_name_param = ""
@@ -54,15 +54,22 @@ function M.search_tg_main_price_template(msg_body)
         status_param =  string.format(" AND status = %d ",msg_body.status)
     end
 
+    local tg_main_id_param = ""
+    if msg_body.tg_main_id~="" then
+        tg_main_id_param =  string.format(" AND tg_main_id = %d ",msg_body.tg_main_id)
+    end
+
     local cpa_bid_param = ""
     if msg_body.cpa_bid~="" then
-        cpa_bid_param =  string.format(" AND cpa_bid = %d ",msg_body.cpa_bid)
+        cpa_bid_param = string.format(" AND cpa_bid LIKE '%%%d%%' ", msg_body.cpa_bid)
     end
 
-    local param = name_param..tg_main_name_param..status_param..cpa_bid_param
+    local param = name_param..tg_main_name_param..status_param..cpa_bid_param..tg_main_id_param
 
     local sql = "SELECT * FROM tg_main_price_template WHERE 1=1 "..param..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
    
+    skynet.error("sql:",sql)
+    
     local list = mysqldbx.query(sql)
 
     sql = "SELECT   COUNT(*) AS total  FROM tg_main_price_template WHERE 1=1  "..param

+ 58 - 0
service/backmgr/yw_book.lua

@@ -0,0 +1,58 @@
+--阅文
+local M = {}
+local mysqldbx = require "mysqldbx"
+local tools = require "tools"
+local skynet = require "skynet"
+local cjson = require "cjson"
+
+function M.get_all_yw_key()
+    local sql = "SELECT * FROM yw_book_config "
+    local res = mysqldbx.query(sql)
+    return true,res
+end
+
+function M.add_yw_book_open_sessid(msg_body)
+    local isok ,key =  tools.checkData({"open_sessid","name"},msg_body)
+    if not isok then
+        return false,string.format("缺少字段: %s.", key)
+    end
+    local sql = string.format("SELECT * FROM yw_book_config WHERE open_sessid = '%s' LIMIT 1", msg_body.open_sessid)
+    local isok,res;
+    res = mysqldbx.query(sql)
+    if #res > 0 then
+        return false ,"open_sessid :"..msg_body.open_sessid.." 已存在!"
+    end
+    sql = string.format("INSERT INTO `yw_book_config` (open_sessid,name)  VALUES ('%s','%s')",msg_body.open_sessid,msg_body.name)
+    mysqldbx.query(sql)
+    skynet.send("backmgr","lua","on_recv",nil,"ws_push_msg",cjson.encode({cmd="updateYwKeyList"}))
+    return true, {}
+end
+
+function M.modify_yw_book_open_sessid(msg_body)
+    local isok ,key =  tools.checkData({"open_sessid","id","name"},msg_body)
+    if not isok then
+        return false,string.format("缺少字段: %s.", key)
+    end
+    local sql = string.format("UPDATE  yw_book_config SET open_sessid = '%s' ,  name = '%s' WHERE id =%d ",msg_body.open_sessid,msg_body.name,msg_body.id)
+    mysqldbx.query(sql)
+    skynet.send("backmgr","lua","on_recv",nil,"ws_push_msg",cjson.encode({cmd="updateYwKeyList"}))
+    return true, {}
+end
+
+
+
+function M.get_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 yw_book_config "..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
+    local list = mysqldbx.query(sql)
+    sql = "SELECT   COUNT(*) AS total  FROM yw_book_config "
+    local total = mysqldbx.query(sql)
+    return true,list,total[1].total
+end
+return M

+ 8 - 0
service/doc/cmd_sql.sql

@@ -213,3 +213,11 @@ create table platform_shared (
 	create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
 primary key (id));
 
+
+create table yw_book_config (  
+	id int not null auto_increment COMMENT '唯一id',
+	name  varchar(64),	
+	open_sessid  varchar(255),	
+	`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
+primary key (id));
+