|
@@ -197,6 +197,7 @@ function M.tui_guang_zeng_liang(msg_body)
|
|
|
return true,res
|
|
|
end
|
|
|
|
|
|
+
|
|
|
--搜索推广数据
|
|
|
--oce_material_id 推广素材id
|
|
|
--book_platform 平台id
|
|
@@ -218,107 +219,59 @@ function M.search_tg_data(msg_body)
|
|
|
if not isok then
|
|
|
return false,string.format("缺少字段: %s.", key)
|
|
|
end
|
|
|
- local isFirst = false
|
|
|
local page_size = msg_body.page_size
|
|
|
local page_number = msg_body.page_number
|
|
|
local offset = (page_number - 1) * page_size
|
|
|
local product_param = ""
|
|
|
if msg_body.product_id~="" then
|
|
|
- isFirst = true
|
|
|
- product_param = string.format(" product_id = %d ",tonumber(msg_body.product_id))
|
|
|
+ product_param = string.format(" AND product_id = %d ",tonumber(msg_body.product_id))
|
|
|
end
|
|
|
|
|
|
|
|
|
local product_name_param = ""
|
|
|
if msg_body.product_name~="" then
|
|
|
- if isFirst==true then
|
|
|
- product_name_param = string.format("AND product_name = '%s' ",msg_body.product_name)
|
|
|
- else
|
|
|
- isFirst = true;
|
|
|
- product_name_param = string.format(" product_name = '%s' ",msg_body.product_name)
|
|
|
- end
|
|
|
+ product_name_param = string.format("AND product_name = '%s' ",msg_body.product_name)
|
|
|
end
|
|
|
|
|
|
local is_auto_param = ""
|
|
|
if msg_body.dy_id~="" then
|
|
|
- if isFirst==true then
|
|
|
- if msg_body.dy_id~=0 then
|
|
|
- is_auto_param = " AND dy_id != 0"
|
|
|
- else
|
|
|
- is_auto_param = " AND dy_id = 0"
|
|
|
- end
|
|
|
-
|
|
|
+ if msg_body.dy_id~=0 then
|
|
|
+ is_auto_param = " AND dy_id != 0"
|
|
|
else
|
|
|
- isFirst = true;
|
|
|
- if msg_body.dy_id~=0 then
|
|
|
- is_auto_param = " dy_id != 0"
|
|
|
- else
|
|
|
- is_auto_param = " dy_id = 0"
|
|
|
- end
|
|
|
-
|
|
|
+ is_auto_param = " AND dy_id = 0"
|
|
|
end
|
|
|
end
|
|
|
|
|
|
local material_id_param = ""
|
|
|
if msg_body.material_id~="" then
|
|
|
- if isFirst==true then
|
|
|
- material_id_param = string.format(" AND material_id = %d ",tonumber(msg_body.material_id))
|
|
|
- else
|
|
|
- isFirst = true;
|
|
|
- material_id_param = string.format(" material_id = %d ",tonumber(msg_body.material_id))
|
|
|
- end
|
|
|
+ material_id_param = string.format(" AND material_id = %d ",tonumber(msg_body.material_id))
|
|
|
end
|
|
|
|
|
|
local oce_material_param = ""
|
|
|
if msg_body.oce_material_id~="" then
|
|
|
- if isFirst == true then
|
|
|
- oce_material_param =string.format("AND oce_material_id = %d ",tonumber(msg_body.oce_material_id))
|
|
|
- else
|
|
|
- isFirst = true
|
|
|
- oce_material_param =string.format(" oce_material_id = %d ",tonumber(msg_body.oce_material_id))
|
|
|
- end
|
|
|
+ oce_material_param =string.format("AND oce_material_id = %d ",tonumber(msg_body.oce_material_id))
|
|
|
end
|
|
|
local tg_platform_param = ""
|
|
|
if msg_body.tg_platform_id~="" then
|
|
|
- if isFirst == true then
|
|
|
- tg_platform_param = "AND book_platform = "..msg_body.tg_platform_id.." "
|
|
|
- else
|
|
|
- isFirst = true
|
|
|
- tg_platform_param = " book_platform = "..msg_body.tg_platform_id.." "
|
|
|
- end
|
|
|
+ tg_platform_param = "AND book_platform = "..msg_body.tg_platform_id.." "
|
|
|
end
|
|
|
|
|
|
local date_param = ""
|
|
|
if msg_body.start_time_date~="" and msg_body.end_time_date~="" then
|
|
|
- if isFirst == true then
|
|
|
- date_param = " AND DATE(create_at) >= DATE(FROM_UNIXTIME(" .. (msg_body.start_time_date / 1000) .. ")) AND DATE(create_at) <= DATE(FROM_UNIXTIME(" .. (msg_body.end_time_date / 1000) .. "))"
|
|
|
- else
|
|
|
- isFirst = true
|
|
|
- date_param = " DATE(create_at) >= DATE(FROM_UNIXTIME(" .. (msg_body.start_time_date / 1000) .. ")) AND DATE(create_at) <= DATE(FROM_UNIXTIME(" .. (msg_body.end_time_date / 1000) .. "))"
|
|
|
- end
|
|
|
+ date_param = " AND DATE(create_at) >= DATE(FROM_UNIXTIME(" .. (msg_body.start_time_date / 1000) .. ")) AND DATE(create_at) <= DATE(FROM_UNIXTIME(" .. (msg_body.end_time_date / 1000) .. "))"
|
|
|
end
|
|
|
|
|
|
local sync_status_param = ""
|
|
|
|
|
|
if msg_body.sync_status~="" then
|
|
|
- if isFirst == true then
|
|
|
- sync_status_param = "AND sync_status = "..msg_body.sync_status.." "
|
|
|
- else
|
|
|
- isFirst = true
|
|
|
- sync_status_param = " sync_status = "..msg_body.sync_status.." "
|
|
|
- end
|
|
|
+ sync_status_param = "AND sync_status = "..msg_body.sync_status.." "
|
|
|
end
|
|
|
|
|
|
|
|
|
local status_param = ""
|
|
|
|
|
|
if msg_body.status~="" then
|
|
|
- if isFirst == true then
|
|
|
- status_param = "AND status = "..msg_body.status.." "
|
|
|
- else
|
|
|
- isFirst = true
|
|
|
- status_param = " status = "..msg_body.status.." "
|
|
|
- end
|
|
|
+ status_param = "AND status = "..msg_body.status.." "
|
|
|
end
|
|
|
|
|
|
|
|
@@ -360,10 +313,6 @@ function M.search_tg_data(msg_body)
|
|
|
|
|
|
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
|
|
|
|
|
|
- if param ~= "" then
|
|
|
- param = " WHERE "..param
|
|
|
- end
|
|
|
-
|
|
|
local up_down_param = d_z_param..comment_param..forward_param..collect_param
|
|
|
|
|
|
if up_down_param ~= "" then
|
|
@@ -374,11 +323,11 @@ function M.search_tg_data(msg_body)
|
|
|
|
|
|
|
|
|
|
|
|
- local sql = "SELECT * FROM video_material "..param..up_down_param..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
|
|
|
+ local sql = "SELECT * FROM video_material WHERE 1=1 "..param..up_down_param..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
|
|
|
|
|
|
local res = mysqldbx.query(sql)
|
|
|
|
|
|
- sql = "SELECT COUNT(*) AS total FROM video_material "..param.." ORDER BY id DESC "
|
|
|
+ sql = "SELECT COUNT(*) AS total FROM video_material WHERE 1=1 "..param.." ORDER BY id DESC "
|
|
|
|
|
|
local total = mysqldbx.query(sql)
|
|
|
|