904118851 7 months ago
parent
commit
bd0deacf86

+ 2 - 4
common/dbproxy/tg_app.lua

@@ -21,13 +21,12 @@ end
 --小程序名称 name
 --添加小程序
 function M.addApp(msg_body)
-    local isok ,key =  tools.checkData({"butler_id","tg_platform_id","app_id","instance_id","name","advertiser_id","landing_page","titles"},msg_body)
+    local isok ,key =  tools.checkData({"wx_origin_id","butler_id","tg_platform_id","app_id","instance_id","name","advertiser_id","landing_page","titles"},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
-    msg_body.wx_origin_id = ""
     local sql = string.format("INSERT INTO `tg_app` (wx_origin_id,butler_id,tg_platform_id,app_id, instance_id, name,advertiser_id,landing_page,titles)  VALUES ('%s',%d,%d,'%s','%s','%s','%s','%s','%s')",
     msg_body.wx_origin_id,
     msg_body.butler_id,
@@ -42,13 +41,12 @@ end
 
 --修改小程序
 function M.modifyApp(msg_body)
-    local isok ,key =  tools.checkData({"butler_id","id","tg_platform_id","app_id","instance_id","name","advertiser_id","landing_page","titles"},msg_body)
+    local isok ,key =  tools.checkData({"wx_origin_id","butler_id","id","tg_platform_id","app_id","instance_id","name","advertiser_id","landing_page","titles"},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
-    msg_body.wx_origin_id = ""
     local sql = string.format("UPDATE `tg_app` SET wx_origin_id = '%s' , butler_id = %d , tg_platform_id =%d ,app_id ='%s' , instance_id ='%s' , name ='%s' , advertiser_id ='%s'  , update_time ='%s'   , landing_page ='%s'  , titles ='%s' WHERE id = %d ",
     msg_body.wx_origin_id,msg_body.butler_id,msg_body.tg_platform_id,msg_body.app_id,msg_body.instance_id,msg_body.name,msg_body.advertiser_id,msg_body.update_time,msg_body.landing_page,msg_body.titles,msg_body.id)
     mysqldbx.query(sql)

+ 6 - 6
common/dbproxy/tg_main.lua

@@ -73,14 +73,14 @@ end
 -- `daily_new_limit` int DEFAULT '0' COMMENT '今天新上数量上限',
 
 function M.addMain(msg_body)
-    local isok ,key =  tools.checkData({"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({"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` (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','%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.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, msg_body.valid_timer_time, msg_body.valid_timer_number,msg_body.channelId, 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
+    local sql = string.format("INSERT INTO `tg_main` (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 ('%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.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, msg_body.valid_timer_time, msg_body.valid_timer_number,msg_body.channelId, 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,msg_body.group_id)
     mysqldbx.query(sql)
     skynet.send("backmgr","lua","on_recv",nil,"ws_push_msg",cjson.encode({cmd="updateMainConfig"}))
@@ -189,14 +189,14 @@ function pushAddMainMsg(msg_body)
    
 end
 function M.modifyMain(msg_body)
-    local isok ,key =  tools.checkData({"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({"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 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.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 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.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)
     mysqldbx.query(sql)
     skynet.send("backmgr","lua","on_recv",nil,"ws_push_msg",cjson.encode({cmd="updateMainConfig"}))

+ 5 - 4
common/dbproxy/tg_platform.lua

@@ -18,13 +18,13 @@ end
 
 --添加平台
 function M.addPlatform(msg_body)
-    local isok ,key ,id=  tools.checkData({"platform_shared_id","mini_program_platform_id","tg_platform_name","filter_guajian_logic"},msg_body)
+    local isok ,key ,id=  tools.checkData({"filter_guajian_logic_list","platform_shared_id","mini_program_platform_id","tg_platform_name","filter_guajian_logic"},msg_body)
     if not isok then
         return false,string.format("缺少字段: %s.", key)
     end
     local _,data = M.getTotal()
     local id = data.total + 1
-    local sql = string.format("INSERT INTO `tg_platform` (platform_shared_id,mini_program_platform_id,tg_platform_id,tg_platform_name,filter_guajian_logic)  VALUES (%d,%d,%d,'%s','%s')",msg_body.platform_shared_id,msg_body.mini_program_platform_id,id,msg_body.tg_platform_name,msg_body.filter_guajian_logic)
+    local sql = string.format("INSERT INTO `tg_platform` (filter_guajian_logic_list,platform_shared_id,mini_program_platform_id,tg_platform_id,tg_platform_name,filter_guajian_logic)  VALUES ('%s',%d,%d,%d,'%s','%s')", cjson.encode(msg_body.filter_guajian_logic_list),msg_body.platform_shared_id,msg_body.mini_program_platform_id,id,msg_body.tg_platform_name,msg_body.filter_guajian_logic)
     skynet.error(sql)
     mysqldbx.query(sql)
     skynet.send("backmgr","lua","on_recv",nil,"ws_push_msg",cjson.encode({cmd="updatePlatformConfig"}))
@@ -34,11 +34,12 @@ end
 
 --修改平台
 function M.modifyPlatform(msg_body)
-    local isok ,key =  tools.checkData({"platform_shared_id","mini_program_platform_id","tg_platform_name","id","filter_guajian_logic"},msg_body)
+    local isok ,key =  tools.checkData({"filter_guajian_logic_list","platform_shared_id","mini_program_platform_id","tg_platform_name","id","filter_guajian_logic"},msg_body)
     if not isok then
         return false,string.format("缺少字段: %s.", key)
     end
-    local sql = string.format("UPDATE `tg_platform` SET platform_shared_id = %d , mini_program_platform_id = %d , filter_guajian_logic = '%s' , tg_platform_name = '%s'  WHERE id = %d ",
+    local sql = string.format("UPDATE `tg_platform` SET filter_guajian_logic_list = '%s' , platform_shared_id = %d , mini_program_platform_id = %d , filter_guajian_logic = '%s' , tg_platform_name = '%s'  WHERE id = %d ",
+    cjson.encode(msg_body.filter_guajian_logic_list),
     msg_body.platform_shared_id,
     msg_body.mini_program_platform_id,
     msg_body.filter_guajian_logic,

+ 20 - 3
common/dbproxy/tg_zhanghu.lua

@@ -124,7 +124,7 @@ function M.mainFilter(msg_body)
 end
 
 function M.search(msg_body)
-    local isok ,key =  tools.checkData({"content","page_size","page_number"},msg_body)
+    local isok ,key =  tools.checkData({"main_id","content","page_size","page_number","status"},msg_body)
     if not isok then
         return false,string.format("缺少字段: %s.", key)
     end
@@ -132,9 +132,26 @@ function M.search(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 (advertiser_name LIKE CONCAT( '%%%s%%')) OR (advertiser_id LIKE CONCAT('%%%s%%')) ", msg_body.content,msg_body.content)
+    local statuss_param = ""
+    if msg_body.status~="" then
+        statuss_param = "AND status = "..msg_body.status.." "
+    end
+
+    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 param = statuss_param..main_id_param..content_param
+    local sql = "SELECT COUNT(*) AS total FROM advertiser  WHERE 1=1 "..param
     local total = mysqldbx.query(sql)
-    sql = string.format("SELECT * FROM advertiser WHERE (advertiser_name LIKE CONCAT( '%%%s%%')) OR (advertiser_id LIKE CONCAT('%%%s%%')) ORDER BY id LIMIT %d OFFSET %d", msg_body.content, msg_body.content, page_size, offset)
+
+    sql = "SELECT * FROM advertiser  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

+ 61 - 1
service/backmgr/filter_task.lua

@@ -307,9 +307,69 @@ function M.search_tg_data(msg_body)
         end
     end
     
+
+
+    -----
+    local stat_cost_param = ""
+    if msg_body.stat_cost~="" then
+        if(msg_body.stat_cost == 0) then
+            stat_cost_param = " stat_cost ASC"
+        else
+            stat_cost_param = " stat_cost DESC"
+        end
+    end
+   
+    local show_cnt_param = ""
+    if msg_body.show_cnt~="" then
+        if(msg_body.show_cnt == 0) then
+            show_cnt_param = " comment_number ASC"
+        else
+            show_cnt_param = " comment_number DESC"
+        end
+    end
+
+    local click_cnt_param = ""
+    if msg_body.click_cnt~="" then
+        if(msg_body.click_cnt == 0) then
+            click_cnt_param = " click_cnt ASC"
+        else
+            click_cnt_param = " click_cnt DESC"
+        end
+    end
+    
+    local convert_cnt_param = ""
+    if msg_body.convert_cnt~="" then
+        if(msg_body.convert_cnt == 0) then
+            convert_cnt_param = " convert_cnt ASC"
+        else
+            convert_cnt_param = " convert_cnt DESC"
+        end
+    end
+
+
+    local cvr_param = ""
+    if msg_body.cvr~="" then
+        if(msg_body.cvr == 0) then
+            cvr_param = " cvr ASC"
+        else
+            cvr_param = " cvr DESC"
+        end
+    end
+    
+    local ctr_param = ""
+    if msg_body.ctr~="" then
+        if(msg_body.ctr == 0) then
+            ctr_param = " ctr ASC"
+        else
+            ctr_param = " ctr DESC"
+        end
+    end
+
+    local new_param = stat_cost_param..show_cnt_param..click_cnt_param..convert_cnt_param..cvr_param..ctr_param
+    -----
     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..signature_param..dy_id_1_param
 
-    local up_down_param = d_z_param..comment_param..forward_param..collect_param
+    local up_down_param = d_z_param..comment_param..forward_param..collect_param..new_param
 
     if up_down_param ~= "" then
         up_down_param = " ORDER BY " ..up_down_param