|
@@ -7,31 +7,31 @@ local cjson = require "cjson"
|
|
|
local config = require "run_config"
|
|
|
|
|
|
function M.add_tg_main_price_template(msg_body)
|
|
|
- local isok ,key = tools.checkData({"name","tg_main_id","cpa_bid","custom_budget","no_bid_budget","tg_main_name","status"},msg_body)
|
|
|
+ local isok ,key = tools.checkData({"roi_goal","tf_end_time","name","tg_main_id","cpa_bid","custom_budget","no_bid_budget","tg_main_name","status"},msg_body)
|
|
|
if not isok then
|
|
|
return false,string.format("缺少字段: %s.", key)
|
|
|
end
|
|
|
- local sql_param = "INSERT INTO `tg_main_price_template` (name,tg_main_id,cpa_bid,custom_budget,no_bid_budget,tg_main_name,status) "
|
|
|
- local sql = sql_param..string.format(" VALUES ('%s',%d,%d,%d,%d,'%s',%d) ",
|
|
|
- msg_body.name,msg_body.tg_main_id,msg_body.cpa_bid,msg_body.custom_budget,msg_body.no_bid_budget,msg_body.tg_main_name,msg_body.status)
|
|
|
+ local sql_param = "INSERT INTO `tg_main_price_template` (roi_goal,tf_end_time,name,tg_main_id,cpa_bid,custom_budget,no_bid_budget,tg_main_name,status) "
|
|
|
+ local sql = sql_param..string.format(" VALUES (%d,%d,'%s',%d,%d,%d,%d,'%s',%d) ",
|
|
|
+ msg_body.roi_goal,msg_body.tf_end_time,msg_body.name,msg_body.tg_main_id,msg_body.cpa_bid,msg_body.custom_budget,msg_body.no_bid_budget,msg_body.tg_main_name,msg_body.status)
|
|
|
mysqldbx.query(sql)
|
|
|
return true
|
|
|
end
|
|
|
|
|
|
function M.modify_tg_main_price_template(msg_body)
|
|
|
- local isok ,key = tools.checkData({"id","name","tg_main_id","cpa_bid","custom_budget","no_bid_budget","tg_main_name","status"},msg_body)
|
|
|
+ local isok ,key = tools.checkData({"roi_goal","tf_end_time","id","name","tg_main_id","cpa_bid","custom_budget","no_bid_budget","tg_main_name","status"},msg_body)
|
|
|
if not isok then
|
|
|
return false,string.format("缺少字段: %s.", key)
|
|
|
end
|
|
|
- local sql = string.format("UPDATE `tg_main_price_template` SET name = '%s' ,tg_main_id = %d , cpa_bid = %d , custom_budget = %d , no_bid_budget = %d , tg_main_name = '%s' , status = %d WHERE id = %d ",
|
|
|
- msg_body.name,msg_body.tg_main_id,msg_body.cpa_bid,msg_body.custom_budget,msg_body.no_bid_budget
|
|
|
+ local sql = string.format("UPDATE `tg_main_price_template` SET roi_goal = %d , tf_end_time = %d , name = '%s' ,tg_main_id = %d , cpa_bid = %d , custom_budget = %d , no_bid_budget = %d , tg_main_name = '%s' , status = %d WHERE id = %d ",
|
|
|
+ msg_body.roi_goal,msg_body.tf_end_time,msg_body.name,msg_body.tg_main_id,msg_body.cpa_bid,msg_body.custom_budget,msg_body.no_bid_budget
|
|
|
,msg_body.tg_main_name,msg_body.status,msg_body.id)
|
|
|
mysqldbx.query(sql)
|
|
|
return true
|
|
|
end
|
|
|
|
|
|
function M.search_tg_main_price_template(msg_body)
|
|
|
- local isok ,key = tools.checkData({"page_size","page_number","name","status","tg_main_name","cpa_bid","tg_main_id"},msg_body)
|
|
|
+ local isok ,key = tools.checkData({"min_tf_end_time","max_tf_end_time","page_size","page_number","name","status","tg_main_name","cpa_bid","tg_main_id"},msg_body)
|
|
|
if not isok then
|
|
|
return false,string.format("缺少字段: %s.", key)
|
|
|
end
|
|
@@ -39,6 +39,11 @@ function M.search_tg_main_price_template(msg_body)
|
|
|
local page_number = msg_body.page_number
|
|
|
local offset = (page_number - 1) * page_size
|
|
|
|
|
|
+ local tf_end_time_param = ""
|
|
|
+ if msg_body.min_tf_end_time~="" and msg_body.max_tf_end_time~="" then
|
|
|
+ tf_end_time_param = string.format(" AND tf_end_time >=%d AND tf_end_time <=%d ", msg_body.min_tf_end_time,msg_body.max_tf_end_time)
|
|
|
+ end
|
|
|
+
|
|
|
local name_param = ""
|
|
|
if msg_body.name~="" then
|
|
|
name_param = string.format(" AND (name LIKE '%%%s%%' ) ",msg_body.name)
|
|
@@ -64,7 +69,7 @@ function M.search_tg_main_price_template(msg_body)
|
|
|
cpa_bid_param = string.format(" AND cpa_bid LIKE '%%%d%%' ", msg_body.cpa_bid)
|
|
|
end
|
|
|
|
|
|
- local param = name_param..tg_main_name_param..status_param..cpa_bid_param..tg_main_id_param
|
|
|
+ local param = tf_end_time_param..name_param..tg_main_name_param..status_param..cpa_bid_param..tg_main_id_param
|
|
|
|
|
|
local sql = "SELECT * FROM tg_main_price_template WHERE 1=1 "..param..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
|
|
|
|