904118851 8 months ago
parent
commit
8e571958c5
2 changed files with 53 additions and 7 deletions
  1. 7 7
      common/dbproxy/tg_main.lua
  2. 46 0
      common/dbproxy/tg_platform.lua

+ 7 - 7
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({"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({"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` (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 ('%s',%d,%d,'%s',%d,'%s','%s',%d,%d,%d,%d,'%s',%d,%d,%d,'%s')",
-       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` (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 ('%s',%d,%d,'%s',%d,%d,'%s',%d,'%s','%s',%d,%d,%d,%d,'%s',%d,%d,%d,'%s')",
+    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({"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({"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 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.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 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.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"}))
@@ -174,7 +174,7 @@ end
 
 --配置主体推广链接
 function M.tgLinkConfig(msg_body)
-    local isok ,key =  tools.checkData({"id","is_open","huichuan_id","chongzhi_id","kadian_id"},msg_body)
+    local isok ,key =  tools.checkData({"id","is_open","huichuan_id","chongzhi_id","kadian_id","f_chongzhi_id"},msg_body)
     if not isok then
         return false,string.format("缺少字段: %s.", key)
     end

+ 46 - 0
common/dbproxy/tg_platform.lua

@@ -184,6 +184,52 @@ function M.modifyChongZhiTemplate(msg_body)
     return true,obj
 end
 
+
+
+--添加复充值模板
+function M.addFChongZhiTemplate(msg_body)
+    local isok ,key =  tools.checkData({"name","id","value"},msg_body)
+    if not isok then
+        return false,string.format("缺少字段: %s.", key)
+    end
+    local sql = string.format("select f_chongzhi from `tg_platform` WHERE id = %d ",msg_body.id)
+    local res = mysqldbx.query(sql)
+    local obj = {}
+    if res[1].chongzhi~=nil then
+        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})
+    sql = string.format("UPDATE `tg_platform` SET  f_chongzhi = '%s'  WHERE id = %d ",
+    cjson.encode(obj),msg_body.id)
+    mysqldbx.query(sql)
+    return true, obj
+end
+
+--修改复充值模板
+function M.modifyFChongZhiTemplate(msg_body)
+    local isok ,key =  tools.checkData({"name","id","table_id","value"},msg_body)
+    if not isok then
+        return false,string.format("缺少字段: %s.", key)
+    end
+    local sql = string.format("select f_chongzhi from `tg_platform` WHERE id = %d ",msg_body.id)
+    local res = mysqldbx.query(sql)
+    local obj = {}
+    if res[1].chongzhi ~=nil then
+        obj = cjson.decode(res[1].chongzhi)
+    end
+    for i = 1, #obj, 1 do
+        if obj[i].id == msg_body.table_id then
+            obj[i].name = msg_body.name
+            obj[i].value = msg_body.value
+            break
+        end
+    end
+    sql = string.format("UPDATE `tg_platform` SET  f_chongzhi = '%s'  WHERE id = %d ",
+    cjson.encode(obj),msg_body.id)
+    mysqldbx.query(sql)
+    return true,obj
+end
 function M.getTotal()
     local sql = "SELECT COUNT(*) AS total FROM tg_platform"
     local res = mysqldbx.query(sql)