904118851 8 months ago
parent
commit
ae0ecf0c6c

+ 6 - 6
common/dbproxy/tg_main.lua

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

+ 16 - 12
common/dbproxy/tg_platform.lua

@@ -49,7 +49,7 @@ end
 
 --添加回传规则
 function M.addHuiChuanRule(msg_body)
-    local isok ,key =  tools.checkData({"name","id","value"},msg_body)
+    local isok ,key =  tools.checkData({"name","id","value","mini_program_platform_id"},msg_body)
     if not isok then
         return false,string.format("缺少字段: %s.", key)
     end
@@ -60,7 +60,7 @@ function M.addHuiChuanRule(msg_body)
         obj = cjson.decode(res[1].huichuan)
     end
     local id = #obj+1
-    table.insert(obj,id,{id=id,name=msg_body.name,value=msg_body.value})
+    table.insert(obj,id,{id=id,name=msg_body.name,value=msg_body.value,mini_program_platform_id=msg_body.mini_program_platform_id})
     sql = string.format("UPDATE `tg_platform` SET  huichuan = '%s'  WHERE id = %d ",
     cjson.encode(obj),msg_body.id)
     mysqldbx.query(sql)
@@ -70,7 +70,7 @@ end
 
 --修改回传规则
 function M.modifyHuiChuanRule(msg_body)
-    local isok ,key =  tools.checkData({"name","id","value","table_id"},msg_body)
+    local isok ,key =  tools.checkData({"name","id","value","table_id","mini_program_platform_id"},msg_body)
     if not isok then
         return false,string.format("缺少字段: %s.", key)
     end
@@ -84,6 +84,7 @@ function M.modifyHuiChuanRule(msg_body)
         if obj[i].id == msg_body.table_id then
             obj[i].name = msg_body.name
             obj[i].value = msg_body.value
+            obj[i].mini_program_platform_id = msg_body.mini_program_platform_id
             break
         end
     end
@@ -96,7 +97,7 @@ end
 
 --添加收费卡点
 function M.addShouFeiKaDian(msg_body)
-    local isok ,key =  tools.checkData({"name","id","value"},msg_body)
+    local isok ,key =  tools.checkData({"name","id","value","mini_program_platform_id"},msg_body)
     if not isok then
         return false,string.format("缺少字段: %s.", key)
     end
@@ -107,7 +108,7 @@ function M.addShouFeiKaDian(msg_body)
         obj = cjson.decode(res[1].kadian)
     end
     local id = #obj+1
-    table.insert(obj,id,{id=id,name=msg_body.name,value=msg_body.value})
+    table.insert(obj,id,{id=id,name=msg_body.name,value=msg_body.value,mini_program_platform_id=msg_body.mini_program_platform_id})
     sql = string.format("UPDATE `tg_platform` SET  kadian = '%s'  WHERE id = %d ",
     cjson.encode(obj),msg_body.id)
     mysqldbx.query(sql)
@@ -116,7 +117,7 @@ end
 
 --修改收费卡点
 function M.modifyShouFeiKaDian(msg_body)
-    local isok ,key =  tools.checkData({"name","id","table_id","value"},msg_body)
+    local isok ,key =  tools.checkData({"name","id","table_id","value","mini_program_platform_id"},msg_body)
     if not isok then
         return false,string.format("缺少字段: %s.", key)
     end
@@ -130,6 +131,7 @@ function M.modifyShouFeiKaDian(msg_body)
         if obj[i].id == msg_body.table_id then
             obj[i].name = msg_body.name
             obj[i].value = msg_body.value
+            obj[i].mini_program_platform_id = msg_body.mini_program_platform_id
             break
         end
     end
@@ -141,7 +143,7 @@ end
 
 --添加充值模板
 function M.addChongZhiTemplate(msg_body)
-    local isok ,key =  tools.checkData({"name","id","value"},msg_body)
+    local isok ,key =  tools.checkData({"name","id","value","mini_program_platform_id"},msg_body)
     if not isok then
         return false,string.format("缺少字段: %s.", key)
     end
@@ -152,7 +154,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,value=msg_body.value})
+    table.insert(obj,id,{id=id,name=msg_body.name,value=msg_body.value,mini_program_platform_id=msg_body.mini_program_platform_id})
     sql = string.format("UPDATE `tg_platform` SET  chongzhi = '%s'  WHERE id = %d ",
     cjson.encode(obj),msg_body.id)
     mysqldbx.query(sql)
@@ -161,7 +163,7 @@ end
 
 --修改充值模板
 function M.modifyChongZhiTemplate(msg_body)
-    local isok ,key =  tools.checkData({"name","id","table_id","value"},msg_body)
+    local isok ,key =  tools.checkData({"name","id","table_id","value","mini_program_platform_id"},msg_body)
     if not isok then
         return false,string.format("缺少字段: %s.", key)
     end
@@ -175,6 +177,7 @@ function M.modifyChongZhiTemplate(msg_body)
         if obj[i].id == msg_body.table_id then
             obj[i].name = msg_body.name
             obj[i].value = msg_body.value
+            obj[i].mini_program_platform_id = msg_body.mini_program_platform_id
             break
         end
     end
@@ -188,7 +191,7 @@ end
 
 --添加复充值模板
 function M.addFChongZhiTemplate(msg_body)
-    local isok ,key =  tools.checkData({"name","id","value"},msg_body)
+    local isok ,key =  tools.checkData({"name","id","value","mini_program_platform_id"},msg_body)
     if not isok then
         return false,string.format("缺少字段: %s.", key)
     end
@@ -199,7 +202,7 @@ function M.addFChongZhiTemplate(msg_body)
         obj = cjson.decode(res[1].f_chongzhi)
     end
     local id = #obj+1
-    table.insert(obj,id,{id=id,name=msg_body.name,value=msg_body.value})
+    table.insert(obj,id,{id=id,name=msg_body.name,value=msg_body.value,mini_program_platform_id=msg_body.mini_program_platform_id})
     sql = string.format("UPDATE `tg_platform` SET  f_chongzhi = '%s'  WHERE id = %d ",
     cjson.encode(obj),msg_body.id)
     mysqldbx.query(sql)
@@ -208,7 +211,7 @@ end
 
 --修改复充值模板
 function M.modifyFChongZhiTemplate(msg_body)
-    local isok ,key =  tools.checkData({"name","id","table_id","value"},msg_body)
+    local isok ,key =  tools.checkData({"name","id","table_id","value","mini_program_platform_id"},msg_body)
     if not isok then
         return false,string.format("缺少字段: %s.", key)
     end
@@ -222,6 +225,7 @@ function M.modifyFChongZhiTemplate(msg_body)
         if obj[i].id == msg_body.table_id then
             obj[i].name = msg_body.name
             obj[i].value = msg_body.value
+            obj[i].mini_program_platform_id = msg_body.mini_program_platform_id
             break
         end
     end

+ 1 - 1
service/backmgr/task_material_queue_queue.lua

@@ -79,7 +79,7 @@ function M.search_task_material_queue_queue(msg_body)
 
     local param = tg_platform_id_param..advertiser_id_param..advertiser_name_param..product_id_param..product_name_param..material_id_param..status_param..create_date_param
 
-    local sql = "SELECT * FROM task_material_queue_queue WHERE 1=1 "..param..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
+    local sql = "SELECT * FROM task_material_queue_queue WHERE 1=1 "..param.." ORDER BY id DESC "..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
    
     local list = mysqldbx.query(sql)
 

+ 15 - 17
service/backmgr/tg_butler.lua

@@ -5,26 +5,24 @@ local tools = require "tools"
 local skynet = require "skynet"
 local cjson = require "cjson"
 
-function M.add_butler(msg_body)
-    local isok ,key =  tools.checkData({"butler_name","butler_id","mail"},msg_body)
-    if not isok then
-        return false,string.format("缺少字段: %s.", key)
-    end
-    local sql = string.format("INSERT INTO `tg_butler` (butler_name,butler_id,mail)  VALUES ('%s',%d,'%s')",
-    msg_body.butler_name, msg_body.butler_id, msg_body.mail)
-    mysqldbx.query(sql)
-    return true
-end
+-- function M.add_butler(msg_body)
+--     local isok ,key =  tools.checkData({"butler_name","butler_id","mail"},msg_body)
+--     if not isok then
+--         return false,string.format("缺少字段: %s.", key)
+--     end
+--     local sql = string.format("INSERT INTO `tg_butler` (butler_name,butler_id,mail)  VALUES ('%s',%d,'%s')",
+--     msg_body.butler_name, msg_body.butler_id, msg_body.mail)
+--     mysqldbx.query(sql)
+--     return true
+-- end
 
 function M.modify_butler(msg_body)
-    local isok ,key =  tools.checkData({"butler_name","butler_id","mail","id"},msg_body)
+    local isok ,key =  tools.checkData({"cc_account_id","mail","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_butler` SET butler_name = '%s' , butler_id = %d ,mail = '%s'  WHERE id = %d ",
-    msg_body.butler_name,msg_body.butler_id,msg_body.mail,msg_body.id)
+    local sql = string.format("UPDATE  `advertiser_butler` SET cc_account_id = %d ,email = '%s'  WHERE id = %d ",
+    msg_body.cc_account_id,msg_body.mail,msg_body.id)
     mysqldbx.query(sql)
     return true
 end
@@ -39,11 +37,11 @@ function M.search_butler(msg_body)
     local offset = (page_number - 1) * page_size
 
 
-    local sql = "SELECT * FROM tg_butler WHERE 1=1 "..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
+    local sql = "SELECT * FROM advertiser_butler WHERE 1=1 "..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
    
     local list = mysqldbx.query(sql)
 
-    sql = "SELECT   COUNT(*) AS total  FROM tg_butler WHERE 1=1  "
+    sql = "SELECT   COUNT(*) AS total  FROM advertiser_butler WHERE 1=1  "
 
     local total = mysqldbx.query(sql)
 

+ 70 - 14
service/backmgr/video_product_material.lua

@@ -4,9 +4,12 @@ local mysqldbx = require "mysqldbx"
 local tools = require "tools"
 local skynet = require "skynet"
 local cjson = require "cjson"
-
+local mysql = require "skynet.db.mysql"
+local config = require "run_config"
+local db
+local mysqldtaskbx = {}
 function M.set_status(msg_body)
-    local isok ,key =  tools.checkData({"id_list","is_download","d_z_number"},msg_body)
+    local isok ,key =  tools.checkData({"id_list","is_download"},msg_body)
     if not isok then
         return false,string.format("缺少字段: %s.", key)
     end
@@ -14,12 +17,32 @@ function M.set_status(msg_body)
     local idString = table.concat(msg_body.id_list, ",")
     local sql = string.format("SELECT * FROM video_product_material WHERE id IN (%s)",idString)
     local isok,res;
-    res = mysqldbx.query(sql)
+    res = mysqldtaskbx.Singleton().query(sql)
 
     for i = 1, #res, 1 do
         local id =   res[i].id
-        sql = string.format("UPDATE  video_product_material SET is_download = %d , d_z_number = %d WHERE id =%d ",msg_body.is_download,msg_body.d_z_number,id)
-        mysqldbx.query(sql)
+        sql = string.format("UPDATE  video_product_material SET is_download = %d  WHERE id =%d ",msg_body.is_download,id)
+        mysqldtaskbx.Singleton().query(sql)
+    end
+
+    return true,{}
+end
+
+function M.set_d_z_number(msg_body)
+    local isok ,key =  tools.checkData({"id_list","d_z_number"},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_product_material WHERE id IN (%s)",idString)
+    local isok,res;
+    res = mysqldtaskbx.Singleton().query(sql)
+
+    for i = 1, #res, 1 do
+        local id =   res[i].id
+        sql = string.format("UPDATE  video_product_material SET  d_z_number = %d WHERE id =%d ",msg_body.d_z_number,id)
+        mysqldtaskbx.Singleton().query(sql)
     end
 
     return true,{}
@@ -28,8 +51,8 @@ end
 function M.search_video_product_material(msg_body)
     local isok ,key =  tools.checkData({"page_size",
     "page_number",
-    "start_yun_fabu_time",
-    "end_yun_fabu_time",
+    "start_create_time",
+    "end_create_time",
     "dy_id",
     "product_id",
     "product_name",
@@ -91,20 +114,21 @@ function M.search_video_product_material(msg_body)
         cleaning_status_param = " AND cleaning_status = "..msg_body.cleaning_status
     end
 
-    local yun_fabu_time_date_param = ""
-    if msg_body.start_yun_fabu_time~="" and msg_body.end_yun_fabu_time~="" then
-        yun_fabu_time_date_param = " AND DATE(yun_fabu_time) >= DATE(FROM_UNIXTIME(" .. (msg_body.start_yun_fabu_time / 1000) .. ")) AND DATE(yun_fabu_time) <= DATE(FROM_UNIXTIME(" .. (msg_body.end_yun_fabu_time / 1000) .. "))"
+
+    local create_date_param = ""
+    if msg_body.start_create_time~="" and msg_body.end_create_time~="" then
+        create_date_param = " AND DATE(create_at) >= DATE(FROM_UNIXTIME(" .. (msg_body.start_create_time / 1000) .. ")) AND DATE(create_at) <= DATE(FROM_UNIXTIME(" .. (msg_body.end_create_time / 1000) .. "))"
     end
 
-    local param = dy_id_param..product_id_param..product_name_param..book_platform_param..title_param..is_download_param..status_param..yun_fabu_time_date_param..cleaning_status_param
+    local param = dy_id_param..product_id_param..product_name_param..book_platform_param..title_param..is_download_param..status_param..create_date_param..cleaning_status_param
 
     local sql = "SELECT * FROM video_product_material WHERE dy_id!=0  "..param..  " ORDER BY update_time DESC "..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
    
-    local list = mysqldbx.query(sql)
+    local list =  mysqldtaskbx.Singleton().query(sql)
 
     sql = "SELECT   COUNT(*) AS total  FROM video_product_material  WHERE dy_id!=0  "..param
 
-    local total = mysqldbx.query(sql)
+    local total = mysqldtaskbx.Singleton().query(sql)
 
     return true,list,total[1].total
 end
@@ -117,8 +141,40 @@ function M.delete_video_product_material(msg_body)
     for i = 1, #msg_body.id_list, 1 do
         local id = msg_body.id_list[i]
         local sql = string.format("DELETE FROM video_product_material WHERE id = %d ",id)
-        mysqldbx.query(sql)
+        mysqldtaskbx.Singleton().query(sql)
     end
     return true, {}
 end
+
+
+function mysqldtaskbx.start()
+    local function on_connect(db)
+        db:query("set charset utf8mb4");
+    end
+    local conf = config.db_cnf.book_server.mysqldb_task_cnf
+    db = mysql.connect{
+        host=conf.ip,
+        port=conf.port,
+        database=conf.db,
+        user=conf.user,
+        password=conf.password,
+        charset="utf8mb4",
+        max_packet_size = 1024 * 1024,
+        on_connect = on_connect
+    }
+    if not db then
+       skynet.error("mysql connect fail")
+    end
+end
+
+function mysqldtaskbx.Singleton()
+    if db == nil then
+        mysqldtaskbx.start()
+    end
+    return mysqldtaskbx
+end
+function mysqldtaskbx.query(sql)
+    return db:query(sql)
+end
+
 return M