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 @@ |
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 | 33 | \ No newline at end of file | ... | ... |
src/HttpServer/jsonconf/jsonconf.go
... | ... | @@ -27,10 +27,18 @@ type GoldChestConfig struct { |
27 | 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 | 37 | type GameConfig struct { |
31 | 38 | SignCfg []SignConfig |
32 | 39 | GunConfig []GoldGunsConfig |
33 | 40 | BoxConfig []GoldChestConfig |
41 | + AidsCfg []AidsConfig | |
34 | 42 | } |
35 | 43 | |
36 | 44 | func GetJsonConf() *GameConfig { |
... | ... | @@ -78,6 +86,19 @@ func GetGoldChestConfig(boxid int) *GoldChestConfig { |
78 | 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 | 102 | func file_get_contents(path string) ([]byte, error) { |
82 | 103 | f, err := os.Open(path) |
83 | 104 | if err != nil { |
... | ... | @@ -128,6 +149,19 @@ func LoadJsonConf() error { |
128 | 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 | 165 | logger.Info("loadJsonConf success pconf=%v,err=%v", *g_jsonconf, err) |
132 | 166 | return err |
133 | 167 | } | ... | ... |
src/HttpServer/logic/datadef.go
... | ... | @@ -8,6 +8,10 @@ type AddcointotoutiaoReq struct { |
8 | 8 | Description string `json:"description"` |
9 | 9 | Bonus_type string `json:"bonus_type"` |
10 | 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 | 17 | type AddcointotoutiaoResp struct { |
... | ... | @@ -15,7 +19,7 @@ type AddcointotoutiaoResp struct { |
15 | 19 | Errmsg string `json:"errmsg"` |
16 | 20 | Data int `json:"data"` |
17 | 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 | 25 | type GetAccessTokenResp struct { |
... | ... | @@ -62,6 +66,7 @@ type GetcurpropertyResp struct { |
62 | 66 | type FetchproteryboxReq struct { |
63 | 67 | Openid string `json:"openid"` |
64 | 68 | Device_id int `json:"device_id"` |
69 | + AppName string `json:"appname"` | |
65 | 70 | } |
66 | 71 | |
67 | 72 | type FetchproteryboxData struct { |
... | ... | @@ -100,6 +105,7 @@ type AddgoldReq struct { |
100 | 105 | Device_id int `json:"device_id"` |
101 | 106 | Gold_num int `json:"gold_num"` |
102 | 107 | Gold_Type int `json:"gold_type"` |
108 | + AppName string `json:"appname"` | |
103 | 109 | } |
104 | 110 | |
105 | 111 | type AddgoldData struct { |
... | ... | @@ -134,6 +140,7 @@ type QuersigndataResp struct { |
134 | 140 | type DosignReq struct { |
135 | 141 | Openid string `json:"openid"` |
136 | 142 | Device_id int `json:"device_id"` |
143 | + AppName string `json:"appname"` | |
137 | 144 | } |
138 | 145 | |
139 | 146 | type DosignData struct { | ... | ... |
src/HttpServer/logic/function.go
... | ... | @@ -9,11 +9,13 @@ import ( |
9 | 9 | "crypto/tls" |
10 | 10 | "encoding/json" |
11 | 11 | "errors" |
12 | - "github.com/astaxie/beego/httplib" | |
12 | + "fmt" | |
13 | 13 | "io/ioutil" |
14 | 14 | "net/http" |
15 | 15 | "strconv" |
16 | 16 | "time" |
17 | + | |
18 | + "github.com/astaxie/beego/httplib" | |
17 | 19 | ) |
18 | 20 | |
19 | 21 | func SetHeader(w http.ResponseWriter) { |
... | ... | @@ -273,7 +275,7 @@ func GetCoinFromToutiao(openid string, deviceid int) (int, error) { |
273 | 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 | 280 | gold_coin_extra_add := 0 |
279 | 281 | gold_coin_extra_limit := false |
... | ... | @@ -299,6 +301,16 @@ func AddCoinToTouTiao(openid string, deviceid, amount int, descr string, btype s |
299 | 301 | //reqdata.Device_id = deviceid |
300 | 302 | reqdata.Open_id = openid |
301 | 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 | 314 | logger.Info("AddCoinToTouTiao req=%v", reqdata) |
303 | 315 | bys, err := json.Marshal(&reqdata) |
304 | 316 | if err != nil { | ... | ... |
src/HttpServer/logic/logic.go
... | ... | @@ -208,6 +208,7 @@ func HandlerDosign(w http.ResponseWriter, data string) { |
208 | 208 | resp.RetMsg = "success" |
209 | 209 | var rdata DosignReq |
210 | 210 | err := json.Unmarshal([]byte(data), &rdata) |
211 | + | |
211 | 212 | for { |
212 | 213 | if err != nil { |
213 | 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 | 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 | 255 | if err != nil { |
255 | 256 | logger.Info(" HandlerAddgold AddCoinToTouTiao failed:%v,for:%v", err, data) |
256 | 257 | resp.RetMsg = "调用头条接口失败" |
... | ... | @@ -344,7 +345,7 @@ func HandlerAddgold(w http.ResponseWriter, data string) { |
344 | 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 | 349 | if err != nil { |
349 | 350 | logger.Info(" HandlerAddgold property failed:%v,for:%v", err, data) |
350 | 351 | resp.RetMsg = "调用头条接口失败" |
... | ... | @@ -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 | 484 | if err != nil { |
484 | 485 | logger.Info(" HandlerFetchproterybox property failed:%v,for:%v", err, data) |
485 | 486 | resp.RetMsg = "调用头条接口失败" | ... | ... |