diff --git a/src/HttpServer/jsonconf/AidsConfig.json b/src/HttpServer/jsonconf/AidsConfig.json new file mode 100644 index 0000000..2985503 --- /dev/null +++ b/src/HttpServer/jsonconf/AidsConfig.json @@ -0,0 +1,32 @@ +[ + { + "appname": "douyin_lite", + "taskid": 0, + "taskkey": "", + "description": "" + }, + { + "appname": "novelapp", + "taskid": 1305, + "taskkey": "daily_cs_game", + "description": "天天CS金币版" + }, + { + "appname": "Reading", + "taskid": 1305, + "taskkey": "daily_cs_game", + "description": "天天CS金币版" + }, + { + "appname": "novel_fm", + "taskid": 0, + "taskkey": "", + "description": "" + }, + { + "appname": "news_article_lite", + "taskid": 20010, + "taskkey": "game_cs", + "description": "天天CS金币版" + } +] \ No newline at end of file diff --git a/src/HttpServer/jsonconf/jsonconf.go b/src/HttpServer/jsonconf/jsonconf.go index 8631512..8fe332a 100644 --- a/src/HttpServer/jsonconf/jsonconf.go +++ b/src/HttpServer/jsonconf/jsonconf.go @@ -27,10 +27,18 @@ type GoldChestConfig struct { Reward int `json:"reward"` } +type AidsConfig struct { + AppName string `json:"appname"` + TaskID int `json:"taskid"` + TaskKey string `json:"taskkey"` + Description string `json:"description"` +} + type GameConfig struct { SignCfg []SignConfig GunConfig []GoldGunsConfig BoxConfig []GoldChestConfig + AidsCfg []AidsConfig } func GetJsonConf() *GameConfig { @@ -78,6 +86,19 @@ func GetGoldChestConfig(boxid int) *GoldChestConfig { return rt } +func GetAidsConfig(appname string) *AidsConfig { + + var rt *AidsConfig + for _, val := range g_jsonconf.AidsCfg { + if val.AppName == appname { + rt = &val + break + } + } + + return rt +} + func file_get_contents(path string) ([]byte, error) { f, err := os.Open(path) if err != nil { @@ -128,6 +149,19 @@ func LoadJsonConf() error { return err } + path = "../jsonconf/AidsConfig.json" + content, err = file_get_contents(path) + if err != nil { + logger.Info("loadJsonConf failed1,err=%v", err) + return err + } + + err = json.Unmarshal([]byte(content), &g_jsonconf.AidsCfg) + if err != nil { + logger.Info("loadJsonConf failed1,err=%v", err) + return err + } + logger.Info("loadJsonConf success pconf=%v,err=%v", *g_jsonconf, err) return err } diff --git a/src/HttpServer/logic/datadef.go b/src/HttpServer/logic/datadef.go index 4dd8fd0..725b132 100644 --- a/src/HttpServer/logic/datadef.go +++ b/src/HttpServer/logic/datadef.go @@ -8,6 +8,10 @@ type AddcointotoutiaoReq struct { Description string `json:"description"` Bonus_type string `json:"bonus_type"` GlobalID int64 `json:"global_id"` + TaskID int `json:"task_id"` + Extra struct { + TaskKey string `json:"task_key"` + } `json:"extra"` } type AddcointotoutiaoResp struct { @@ -15,7 +19,7 @@ type AddcointotoutiaoResp struct { Errmsg string `json:"errmsg"` Data int `json:"data"` Extra_ADD int `json:"gold_coin_extra_add"` - Extra_Limit bool `json:"gold_coin_extra_limit"` + Extra_Limit bool `json:"gold_coin_extra_limit"` } type GetAccessTokenResp struct { @@ -62,6 +66,7 @@ type GetcurpropertyResp struct { type FetchproteryboxReq struct { Openid string `json:"openid"` Device_id int `json:"device_id"` + AppName string `json:"appname"` } type FetchproteryboxData struct { @@ -100,6 +105,7 @@ type AddgoldReq struct { Device_id int `json:"device_id"` Gold_num int `json:"gold_num"` Gold_Type int `json:"gold_type"` + AppName string `json:"appname"` } type AddgoldData struct { @@ -134,6 +140,7 @@ type QuersigndataResp struct { type DosignReq struct { Openid string `json:"openid"` Device_id int `json:"device_id"` + AppName string `json:"appname"` } type DosignData struct { diff --git a/src/HttpServer/logic/function.go b/src/HttpServer/logic/function.go index 71a7376..bbc0e9d 100644 --- a/src/HttpServer/logic/function.go +++ b/src/HttpServer/logic/function.go @@ -9,11 +9,13 @@ import ( "crypto/tls" "encoding/json" "errors" - "github.com/astaxie/beego/httplib" + "fmt" "io/ioutil" "net/http" "strconv" "time" + + "github.com/astaxie/beego/httplib" ) func SetHeader(w http.ResponseWriter) { @@ -273,7 +275,7 @@ func GetCoinFromToutiao(openid string, deviceid int) (int, error) { return tmp.Data, nil } -func AddCoinToTouTiao(openid string, deviceid, amount int, descr string, btype string) (int, int, int, bool, error) { +func AddCoinToTouTiao(openid string, deviceid, amount int, descr string, btype string, appname string) (int, int, int, bool, error) { gold_coin_extra_add := 0 gold_coin_extra_limit := false @@ -299,6 +301,16 @@ func AddCoinToTouTiao(openid string, deviceid, amount int, descr string, btype s //reqdata.Device_id = deviceid reqdata.Open_id = openid reqdata.GlobalID = globalid + + aidconfig := jsonconf.GetAidsConfig(appname) + if aidconfig != nil { + reqdata.TaskID = aidconfig.TaskID + reqdata.Extra.TaskKey = aidconfig.TaskKey + if aidconfig.Description != "" { + reqdata.Description = fmt.Sprintf("%s+%d", aidconfig.Description, amount) + } + } + logger.Info("AddCoinToTouTiao req=%v", reqdata) bys, err := json.Marshal(&reqdata) if err != nil { diff --git a/src/HttpServer/logic/logic.go b/src/HttpServer/logic/logic.go index bb30aa4..55cd9e4 100644 --- a/src/HttpServer/logic/logic.go +++ b/src/HttpServer/logic/logic.go @@ -208,6 +208,7 @@ func HandlerDosign(w http.ResponseWriter, data string) { resp.RetMsg = "success" var rdata DosignReq err := json.Unmarshal([]byte(data), &rdata) + for { if err != nil { logger.Info("json decode HandlerDosign data failed:%v,for:%v", err, data) @@ -250,7 +251,7 @@ func HandlerDosign(w http.ResponseWriter, data string) { } //加金币 - _, sumgold, extragold, extralimit, err := AddCoinToTouTiao(rdata.Openid, 1, cfg.Reward, "签到奖励", "other") + _, sumgold, extragold, extralimit, err := AddCoinToTouTiao(rdata.Openid, 1, cfg.Reward, "签到奖励", "other", rdata.AppName) if err != nil { logger.Info(" HandlerAddgold AddCoinToTouTiao failed:%v,for:%v", err, data) resp.RetMsg = "调用头条接口失败" @@ -344,7 +345,7 @@ func HandlerAddgold(w http.ResponseWriter, data string) { break } - addnum, sumnum, extragold, extralimit, err := AddCoinToTouTiao(rdata.Openid, 1, rdata.Gold_num, "闯关送金币", "other") + addnum, sumnum, extragold, extralimit, err := AddCoinToTouTiao(rdata.Openid, 1, rdata.Gold_num, "闯关送金币", "other", rdata.AppName) if err != nil { logger.Info(" HandlerAddgold property failed:%v,for:%v", err, data) resp.RetMsg = "调用头条接口失败" @@ -479,7 +480,7 @@ func HandlerFetchproterybox(w http.ResponseWriter, data string) { } //加金币 - addgold, sumgold, extragold, extralimit, err := AddCoinToTouTiao(rdata.Openid, 1, cfg.Reward, "每日领取宝箱奖励", "other") + addgold, sumgold, extragold, extralimit, err := AddCoinToTouTiao(rdata.Openid, 1, cfg.Reward, "每日领取宝箱奖励", "other", rdata.AppName) if err != nil { logger.Info(" HandlerFetchproterybox property failed:%v,for:%v", err, data) resp.RetMsg = "调用头条接口失败" -- libgit2 0.21.0