|
@@ -0,0 +1,93 @@
|
|
|
+--计划队列
|
|
|
+local M = {}
|
|
|
+local mysqldbx = require "mysqldbx"
|
|
|
+local tools = require "tools"
|
|
|
+local skynet = require "skynet"
|
|
|
+local cjson = require "cjson"
|
|
|
+
|
|
|
+function M.set_sweight(msg_body)
|
|
|
+ local isok ,key = tools.checkData({"id_list","sweight"},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 task_material_queue_queue WHERE id IN (%s)",idString)
|
|
|
+ local isok,res;
|
|
|
+ res = mysqldbx.query(sql)
|
|
|
+
|
|
|
+ for i = 1, #res, 1 do
|
|
|
+ local id = res[i].id
|
|
|
+ sql = string.format("UPDATE task_material_queue_queue SET sweight = %d WHERE id =%d ",msg_body.sweight,id)
|
|
|
+ mysqldbx.query(sql)
|
|
|
+ end
|
|
|
+
|
|
|
+ return true,{}
|
|
|
+end
|
|
|
+
|
|
|
+function M.search_task_material_queue_queue(msg_body)
|
|
|
+ local isok ,key = tools.checkData({"page_size","page_number","start_create_time","end_create_time",
|
|
|
+ "tg_platform_id","advertiser_id","advertiser_name","product_id","product_name","material_id","status"},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 advertiser_id_param = ""
|
|
|
+ if msg_body.advertiser_id~="" then
|
|
|
+ advertiser_id_param = " AND advertiser_id = "..msg_body.advertiser_id
|
|
|
+ end
|
|
|
+
|
|
|
+ local advertiser_name_param = ""
|
|
|
+ if msg_body.advertiser_name~="" then
|
|
|
+ advertiser_name_param = string.format(" AND ( advertiser_name LIKE CONCAT( '%%%s%%')) ",msg_body.advertiser_name)
|
|
|
+ end
|
|
|
+
|
|
|
+ local product_id_param = ""
|
|
|
+ if msg_body.product_id~="" then
|
|
|
+ product_id_param = " AND product_id = "..msg_body.product_id
|
|
|
+ end
|
|
|
+
|
|
|
+ local product_name_param = ""
|
|
|
+ if msg_body.product_name~="" then
|
|
|
+ product_name_param = string.format(" AND ( product_name LIKE CONCAT( '%%%s%%')) ",msg_body.product_name)
|
|
|
+ end
|
|
|
+
|
|
|
+
|
|
|
+ local material_id_param = ""
|
|
|
+ if msg_body.material_id~="" then
|
|
|
+ material_id_param = " AND material_id = "..msg_body.material_id
|
|
|
+ end
|
|
|
+
|
|
|
+
|
|
|
+ local status_param = ""
|
|
|
+ if msg_body.status~="" then
|
|
|
+ status_param = " AND status = "..msg_body.status
|
|
|
+ end
|
|
|
+
|
|
|
+ local create_date_param = ""
|
|
|
+ if msg_body.start_create_time~="" and msg_body.end_create_time~="" then
|
|
|
+ create_date_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
|
|
|
+
|
|
|
+ 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 list = mysqldbx.query(sql)
|
|
|
+
|
|
|
+ sql = "SELECT COUNT(*) AS total FROM task_material_queue_queue WHERE 1=1 "..param
|
|
|
+
|
|
|
+ local total = mysqldbx.query(sql)
|
|
|
+
|
|
|
+ return true,list,total[1].total
|
|
|
+end
|
|
|
+
|
|
|
+return M
|