904118851 8 meses atrás
pai
commit
f514833b44

+ 4 - 0
service/backmgr/init.lua

@@ -30,6 +30,8 @@ local promotion_audit_suggestions = require "promotion_audit_suggestions"
 local tg_butler = require "tg_butler"
 local tg_mini_program_platform = require "tg_mini_program_platform"
 local task_material_queue_queue = require "task_material_queue_queue"
+local video_product = require "video_product"
+local origin_data = require "origin_data"
 local status_200 = 200
 local CMD = {
     
@@ -58,6 +60,8 @@ CMD["promotion_audit_suggestions"] = promotion_audit_suggestions;
 CMD["tg_butler"] = tg_butler;
 CMD["tg_mini_program_platform"] = tg_mini_program_platform;
 CMD["task_material_queue_queue"] = task_material_queue_queue;
+CMD["video_product"] = video_product;
+CMD["origin_data"] = origin_data;
 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)

+ 40 - 0
service/backmgr/origin_data.lua

@@ -13,4 +13,44 @@ function M.delete_origin_data_by_time(msg_body)
     local delete_time_param = " AND DATE(created_at) >= DATE(FROM_UNIXTIME(" .. (msg_body.start_create_time / 1000) .. ")) AND DATE(created_at) <= DATE(FROM_UNIXTIME(" .. (msg_body.end_create_time / 1000) .. "))"
 end
 
+
+function M.search_origin_data(msg_body)
+    local isok ,key =  tools.checkData({"page_size","page_number","start_create_time","end_create_time","guajian_info","start_publish_time","end_publish_time"},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 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 date_param = ""
+    if msg_body.start_publish_time~="" and msg_body.end_publish_time~="" 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) .. "))"
+    end
+
+
+    local guajian_info_param = ""
+    if msg_body.guajian_info~="" then
+        guajian_info_param =  string.format(" AND  ( guajian_link LIKE CONCAT( '%%%s%%')) ",msg_body.guajian_info)
+    end
+
+    local param = date_param..create_date_param..guajian_info_param
+
+
+    local sql = "SELECT * FROM origin_data WHERE 1=1 "..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 origin_data WHERE 1=1 "..param
+
+    local total = mysqldbx.query(sql)
+
+    return true,res,total[1].total
+end
+
 return M

+ 4 - 4
service/backmgr/promotion_audit_suggestions.lua

@@ -43,7 +43,7 @@ function M.search_promotion_audit_suggestions(msg_body)
 
     local promotion_id_param = ""
     if msg_body.promotion_id~="" then
-        promotion_id_param =  " AND promotion_id = "..msg_body.promotion_id
+        promotion_id_param =  " AND promotion_id = "..tonumber(msg_body.promotion_id)
     end
 
     local material_type_param = ""
@@ -63,12 +63,12 @@ function M.search_promotion_audit_suggestions(msg_body)
 
     local product_id_param = ""
     if msg_body.product_id~="" then
-        product_id_param = " AND product_id = "..msg_body.product_id
+        product_id_param = " AND product_id = "..tonumber(msg_body.product_id)
     end
 
     local product_library_id_param = ""
     if msg_body.product_library_id~="" then
-        product_library_id_param = " AND product_library_id = "..msg_body.product_library_id
+        product_library_id_param = " AND product_library_id = "..tonumber(msg_body.product_library_id)
     end
 
     local create_date_param = ""
@@ -78,7 +78,7 @@ function M.search_promotion_audit_suggestions(msg_body)
 
     local param = create_date_param..advertiser_id_param..promotion_id_param..material_type_param..material_item_param..status_param..product_id_param..product_library_id_param
 
-    local sql = "SELECT * FROM promotion_audit_suggestions WHERE 1=1 "..param..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
+    local sql = "SELECT * FROM promotion_audit_suggestions WHERE 1=1 "..param.. " ORDER BY cost DESC "..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
    
     local list = mysqldbx.query(sql)
 

+ 54 - 0
service/backmgr/video_product.lua

@@ -0,0 +1,54 @@
+--书库
+local M = {}
+local mysqldbx = require "mysqldbx"
+local tools = require "tools"
+local skynet = require "skynet"
+local cjson = require "cjson"
+local config = require "run_config"
+local mysql = require "skynet.db.mysql"
+local db
+local mysqldtaskbx = {}
+--设置书别名
+function M.set_video_product_alias_name(msg_body)
+    local isok ,key =  tools.checkData({"id","alias_name"},msg_body)
+    if not isok then
+        return false,string.format("缺少字段: %s.", key)
+    end
+
+    local sql = string.format("UPDATE  `video_product` SET alias_name = '%s'  WHERE id = %d ",
+    msg_body.alias_name,msg_body.id)
+    local res = mysqldtaskbx.Singleton().query(sql)
+    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