Commit 35b0ac74801f7b4fd937c3ebd72d4d8d0a6442ec
1 parent
f87be31a
Exists in
master
发放金币新增区分端
Showing
5 changed files
with
92 additions
and
6 deletions
Show diff stats
@@ -0,0 +1,32 @@ | @@ -0,0 +1,32 @@ | ||
1 | +[ | ||
2 | + { | ||
3 | + "appname": "douyin_lite", | ||
4 | + "taskid": 0, | ||
5 | + "taskkey": "", | ||
6 | + "description": "" | ||
7 | + }, | ||
8 | + { | ||
9 | + "appname": "novelapp", | ||
10 | + "taskid": 1305, | ||
11 | + "taskkey": "daily_cs_game", | ||
12 | + "description": "天天CS金币版" | ||
13 | + }, | ||
14 | + { | ||
15 | + "appname": "Reading", | ||
16 | + "taskid": 1305, | ||
17 | + "taskkey": "daily_cs_game", | ||
18 | + "description": "天天CS金币版" | ||
19 | + }, | ||
20 | + { | ||
21 | + "appname": "novel_fm", | ||
22 | + "taskid": 0, | ||
23 | + "taskkey": "", | ||
24 | + "description": "" | ||
25 | + }, | ||
26 | + { | ||
27 | + "appname": "news_article_lite", | ||
28 | + "taskid": 20010, | ||
29 | + "taskkey": "game_cs", | ||
30 | + "description": "天天CS金币版" | ||
31 | + } | ||
32 | +] | ||
0 | \ No newline at end of file | 33 | \ No newline at end of file |
src/HttpServer/jsonconf/jsonconf.go
@@ -27,10 +27,18 @@ type GoldChestConfig struct { | @@ -27,10 +27,18 @@ type GoldChestConfig struct { | ||
27 | Reward int `json:"reward"` | 27 | Reward int `json:"reward"` |
28 | } | 28 | } |
29 | 29 | ||
30 | +type AidsConfig struct { | ||
31 | + AppName string `json:"appname"` | ||
32 | + TaskID int `json:"taskid"` | ||
33 | + TaskKey string `json:"taskkey"` | ||
34 | + Description string `json:"description"` | ||
35 | +} | ||
36 | + | ||
30 | type GameConfig struct { | 37 | type GameConfig struct { |
31 | SignCfg []SignConfig | 38 | SignCfg []SignConfig |
32 | GunConfig []GoldGunsConfig | 39 | GunConfig []GoldGunsConfig |
33 | BoxConfig []GoldChestConfig | 40 | BoxConfig []GoldChestConfig |
41 | + AidsCfg []AidsConfig | ||
34 | } | 42 | } |
35 | 43 | ||
36 | func GetJsonConf() *GameConfig { | 44 | func GetJsonConf() *GameConfig { |
@@ -78,6 +86,19 @@ func GetGoldChestConfig(boxid int) *GoldChestConfig { | @@ -78,6 +86,19 @@ func GetGoldChestConfig(boxid int) *GoldChestConfig { | ||
78 | return rt | 86 | return rt |
79 | } | 87 | } |
80 | 88 | ||
89 | +func GetAidsConfig(appname string) *AidsConfig { | ||
90 | + | ||
91 | + var rt *AidsConfig | ||
92 | + for _, val := range g_jsonconf.AidsCfg { | ||
93 | + if val.AppName == appname { | ||
94 | + rt = &val | ||
95 | + break | ||
96 | + } | ||
97 | + } | ||
98 | + | ||
99 | + return rt | ||
100 | +} | ||
101 | + | ||
81 | func file_get_contents(path string) ([]byte, error) { | 102 | func file_get_contents(path string) ([]byte, error) { |
82 | f, err := os.Open(path) | 103 | f, err := os.Open(path) |
83 | if err != nil { | 104 | if err != nil { |
@@ -128,6 +149,19 @@ func LoadJsonConf() error { | @@ -128,6 +149,19 @@ func LoadJsonConf() error { | ||
128 | return err | 149 | return err |
129 | } | 150 | } |
130 | 151 | ||
152 | + path = "../jsonconf/AidsConfig.json" | ||
153 | + content, err = file_get_contents(path) | ||
154 | + if err != nil { | ||
155 | + logger.Info("loadJsonConf failed1,err=%v", err) | ||
156 | + return err | ||
157 | + } | ||
158 | + | ||
159 | + err = json.Unmarshal([]byte(content), &g_jsonconf.AidsCfg) | ||
160 | + if err != nil { | ||
161 | + logger.Info("loadJsonConf failed1,err=%v", err) | ||
162 | + return err | ||
163 | + } | ||
164 | + | ||
131 | logger.Info("loadJsonConf success pconf=%v,err=%v", *g_jsonconf, err) | 165 | logger.Info("loadJsonConf success pconf=%v,err=%v", *g_jsonconf, err) |
132 | return err | 166 | return err |
133 | } | 167 | } |
src/HttpServer/logic/datadef.go
@@ -8,6 +8,10 @@ type AddcointotoutiaoReq struct { | @@ -8,6 +8,10 @@ type AddcointotoutiaoReq struct { | ||
8 | Description string `json:"description"` | 8 | Description string `json:"description"` |
9 | Bonus_type string `json:"bonus_type"` | 9 | Bonus_type string `json:"bonus_type"` |
10 | GlobalID int64 `json:"global_id"` | 10 | GlobalID int64 `json:"global_id"` |
11 | + TaskID int `json:"task_id"` | ||
12 | + Extra struct { | ||
13 | + TaskKey string `json:"task_key"` | ||
14 | + } `json:"extra"` | ||
11 | } | 15 | } |
12 | 16 | ||
13 | type AddcointotoutiaoResp struct { | 17 | type AddcointotoutiaoResp struct { |
@@ -15,7 +19,7 @@ type AddcointotoutiaoResp struct { | @@ -15,7 +19,7 @@ type AddcointotoutiaoResp struct { | ||
15 | Errmsg string `json:"errmsg"` | 19 | Errmsg string `json:"errmsg"` |
16 | Data int `json:"data"` | 20 | Data int `json:"data"` |
17 | Extra_ADD int `json:"gold_coin_extra_add"` | 21 | Extra_ADD int `json:"gold_coin_extra_add"` |
18 | - Extra_Limit bool `json:"gold_coin_extra_limit"` | 22 | + Extra_Limit bool `json:"gold_coin_extra_limit"` |
19 | } | 23 | } |
20 | 24 | ||
21 | type GetAccessTokenResp struct { | 25 | type GetAccessTokenResp struct { |
@@ -62,6 +66,7 @@ type GetcurpropertyResp struct { | @@ -62,6 +66,7 @@ type GetcurpropertyResp struct { | ||
62 | type FetchproteryboxReq struct { | 66 | type FetchproteryboxReq struct { |
63 | Openid string `json:"openid"` | 67 | Openid string `json:"openid"` |
64 | Device_id int `json:"device_id"` | 68 | Device_id int `json:"device_id"` |
69 | + AppName string `json:"appname"` | ||
65 | } | 70 | } |
66 | 71 | ||
67 | type FetchproteryboxData struct { | 72 | type FetchproteryboxData struct { |
@@ -100,6 +105,7 @@ type AddgoldReq struct { | @@ -100,6 +105,7 @@ type AddgoldReq struct { | ||
100 | Device_id int `json:"device_id"` | 105 | Device_id int `json:"device_id"` |
101 | Gold_num int `json:"gold_num"` | 106 | Gold_num int `json:"gold_num"` |
102 | Gold_Type int `json:"gold_type"` | 107 | Gold_Type int `json:"gold_type"` |
108 | + AppName string `json:"appname"` | ||
103 | } | 109 | } |
104 | 110 | ||
105 | type AddgoldData struct { | 111 | type AddgoldData struct { |
@@ -134,6 +140,7 @@ type QuersigndataResp struct { | @@ -134,6 +140,7 @@ type QuersigndataResp struct { | ||
134 | type DosignReq struct { | 140 | type DosignReq struct { |
135 | Openid string `json:"openid"` | 141 | Openid string `json:"openid"` |
136 | Device_id int `json:"device_id"` | 142 | Device_id int `json:"device_id"` |
143 | + AppName string `json:"appname"` | ||
137 | } | 144 | } |
138 | 145 | ||
139 | type DosignData struct { | 146 | type DosignData struct { |
src/HttpServer/logic/function.go
@@ -9,11 +9,13 @@ import ( | @@ -9,11 +9,13 @@ import ( | ||
9 | "crypto/tls" | 9 | "crypto/tls" |
10 | "encoding/json" | 10 | "encoding/json" |
11 | "errors" | 11 | "errors" |
12 | - "github.com/astaxie/beego/httplib" | 12 | + "fmt" |
13 | "io/ioutil" | 13 | "io/ioutil" |
14 | "net/http" | 14 | "net/http" |
15 | "strconv" | 15 | "strconv" |
16 | "time" | 16 | "time" |
17 | + | ||
18 | + "github.com/astaxie/beego/httplib" | ||
17 | ) | 19 | ) |
18 | 20 | ||
19 | func SetHeader(w http.ResponseWriter) { | 21 | func SetHeader(w http.ResponseWriter) { |
@@ -273,7 +275,7 @@ func GetCoinFromToutiao(openid string, deviceid int) (int, error) { | @@ -273,7 +275,7 @@ func GetCoinFromToutiao(openid string, deviceid int) (int, error) { | ||
273 | return tmp.Data, nil | 275 | return tmp.Data, nil |
274 | } | 276 | } |
275 | 277 | ||
276 | -func AddCoinToTouTiao(openid string, deviceid, amount int, descr string, btype string) (int, int, int, bool, error) { | 278 | +func AddCoinToTouTiao(openid string, deviceid, amount int, descr string, btype string, appname string) (int, int, int, bool, error) { |
277 | 279 | ||
278 | gold_coin_extra_add := 0 | 280 | gold_coin_extra_add := 0 |
279 | gold_coin_extra_limit := false | 281 | gold_coin_extra_limit := false |
@@ -299,6 +301,16 @@ func AddCoinToTouTiao(openid string, deviceid, amount int, descr string, btype s | @@ -299,6 +301,16 @@ func AddCoinToTouTiao(openid string, deviceid, amount int, descr string, btype s | ||
299 | //reqdata.Device_id = deviceid | 301 | //reqdata.Device_id = deviceid |
300 | reqdata.Open_id = openid | 302 | reqdata.Open_id = openid |
301 | reqdata.GlobalID = globalid | 303 | reqdata.GlobalID = globalid |
304 | + | ||
305 | + aidconfig := jsonconf.GetAidsConfig(appname) | ||
306 | + if aidconfig != nil { | ||
307 | + reqdata.TaskID = aidconfig.TaskID | ||
308 | + reqdata.Extra.TaskKey = aidconfig.TaskKey | ||
309 | + if aidconfig.Description != "" { | ||
310 | + reqdata.Description = fmt.Sprintf("%s+%d", aidconfig.Description, amount) | ||
311 | + } | ||
312 | + } | ||
313 | + | ||
302 | logger.Info("AddCoinToTouTiao req=%v", reqdata) | 314 | logger.Info("AddCoinToTouTiao req=%v", reqdata) |
303 | bys, err := json.Marshal(&reqdata) | 315 | bys, err := json.Marshal(&reqdata) |
304 | if err != nil { | 316 | if err != nil { |
src/HttpServer/logic/logic.go
@@ -208,6 +208,7 @@ func HandlerDosign(w http.ResponseWriter, data string) { | @@ -208,6 +208,7 @@ func HandlerDosign(w http.ResponseWriter, data string) { | ||
208 | resp.RetMsg = "success" | 208 | resp.RetMsg = "success" |
209 | var rdata DosignReq | 209 | var rdata DosignReq |
210 | err := json.Unmarshal([]byte(data), &rdata) | 210 | err := json.Unmarshal([]byte(data), &rdata) |
211 | + | ||
211 | for { | 212 | for { |
212 | if err != nil { | 213 | if err != nil { |
213 | logger.Info("json decode HandlerDosign data failed:%v,for:%v", err, data) | 214 | logger.Info("json decode HandlerDosign data failed:%v,for:%v", err, data) |
@@ -250,7 +251,7 @@ func HandlerDosign(w http.ResponseWriter, data string) { | @@ -250,7 +251,7 @@ func HandlerDosign(w http.ResponseWriter, data string) { | ||
250 | } | 251 | } |
251 | 252 | ||
252 | //加金币 | 253 | //加金币 |
253 | - _, sumgold, extragold, extralimit, err := AddCoinToTouTiao(rdata.Openid, 1, cfg.Reward, "签到奖励", "other") | 254 | + _, sumgold, extragold, extralimit, err := AddCoinToTouTiao(rdata.Openid, 1, cfg.Reward, "签到奖励", "other", rdata.AppName) |
254 | if err != nil { | 255 | if err != nil { |
255 | logger.Info(" HandlerAddgold AddCoinToTouTiao failed:%v,for:%v", err, data) | 256 | logger.Info(" HandlerAddgold AddCoinToTouTiao failed:%v,for:%v", err, data) |
256 | resp.RetMsg = "调用头条接口失败" | 257 | resp.RetMsg = "调用头条接口失败" |
@@ -344,7 +345,7 @@ func HandlerAddgold(w http.ResponseWriter, data string) { | @@ -344,7 +345,7 @@ func HandlerAddgold(w http.ResponseWriter, data string) { | ||
344 | break | 345 | break |
345 | } | 346 | } |
346 | 347 | ||
347 | - addnum, sumnum, extragold, extralimit, err := AddCoinToTouTiao(rdata.Openid, 1, rdata.Gold_num, "闯关送金币", "other") | 348 | + addnum, sumnum, extragold, extralimit, err := AddCoinToTouTiao(rdata.Openid, 1, rdata.Gold_num, "闯关送金币", "other", rdata.AppName) |
348 | if err != nil { | 349 | if err != nil { |
349 | logger.Info(" HandlerAddgold property failed:%v,for:%v", err, data) | 350 | logger.Info(" HandlerAddgold property failed:%v,for:%v", err, data) |
350 | resp.RetMsg = "调用头条接口失败" | 351 | resp.RetMsg = "调用头条接口失败" |
@@ -479,7 +480,7 @@ func HandlerFetchproterybox(w http.ResponseWriter, data string) { | @@ -479,7 +480,7 @@ func HandlerFetchproterybox(w http.ResponseWriter, data string) { | ||
479 | } | 480 | } |
480 | 481 | ||
481 | //加金币 | 482 | //加金币 |
482 | - addgold, sumgold, extragold, extralimit, err := AddCoinToTouTiao(rdata.Openid, 1, cfg.Reward, "每日领取宝箱奖励", "other") | 483 | + addgold, sumgold, extragold, extralimit, err := AddCoinToTouTiao(rdata.Openid, 1, cfg.Reward, "每日领取宝箱奖励", "other", rdata.AppName) |
483 | if err != nil { | 484 | if err != nil { |
484 | logger.Info(" HandlerFetchproterybox property failed:%v,for:%v", err, data) | 485 | logger.Info(" HandlerFetchproterybox property failed:%v,for:%v", err, data) |
485 | resp.RetMsg = "调用头条接口失败" | 486 | resp.RetMsg = "调用头条接口失败" |