|
- package svc
-
- import (
- "applet/app/cfg"
- offical "applet/app/db/official"
- "applet/app/utils/cache"
- "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/xiaoju"
- "github.com/tidwall/gjson"
- )
-
- // 小桔基本配置
- func XiaojuKey() map[string]string {
- param := map[string]string{
- "key": offical.SysCfgByKeyStr("xiaoju_key"),
- "sign_secret": offical.SysCfgByKeyStr("xiaoju_sign_secret"),
- "data_secret": offical.SysCfgByKeyStr("xiaoju_data_secret"),
- "secret": offical.SysCfgByKeyStr("xiaoju_secret"),
- "url": "https://gw.am.xiaojukeji.com/online/energy/v1/",
- }
- return param
- }
- func GetXiaojuToken(platformKey map[string]string) string {
- key := "zhiying_xiaoju_token"
- token, err := cache.GetString(key)
- if cfg.Prd == false {
- return token
- }
- if err != nil || token == "" {
- token1, _ := xiaoju.GetXiaojuToken(platformKey)
- token = gjson.Get(token1, "accessToken").String()
- if token != "" {
- availableTime := gjson.Get(token1, "availableTime").Int()
- cache.SetEx(key, token, int(availableTime-20))
- }
- }
- return token
-
- }
|