@@ -9,6 +9,8 @@ import ( | |||
zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils" | |||
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/zhimeng" | |||
"fmt" | |||
"github.com/tidwall/gjson" | |||
"strings" | |||
"time" | |||
"xorm.io/xorm" | |||
) | |||
@@ -84,6 +86,63 @@ func ChainTransfer(eg *xorm.Engine, args map[string]string) map[string]string { | |||
// 分享 | |||
if args["provider"] == md.PVD_TIKTOK { | |||
args["coupon_url"] = "https://haohuo.jinritemai.com/views/product/item2?id=" + args["gid"] | |||
if strings.Contains(args["gid"], "cid") { | |||
ex := strings.Split(args["gid"], "cid") | |||
if len(ex) == 2 { | |||
args["gid"] = ex[0] | |||
args["activityId"] = ex[1] | |||
} | |||
newTeamToken := "" | |||
selectionLibraryTeamKey, _ := db.SysCfgGetOne(eg, "selection_library_team_key") | |||
if selectionLibraryTeamKey != nil { | |||
newTeamToken = gjson.Get(selectionLibraryTeamKey.Val, "teamAccessToken").String() | |||
} | |||
appkey := "" | |||
secretKey := "" | |||
thirdZmAppKeyData, _ := db.SysCfgGetOne(eg, "third_zm_app_key") | |||
if thirdZmAppKeyData != nil { | |||
appkey = thirdZmAppKeyData.Val | |||
} | |||
thirdZmAppSecretData, _ := db.SysCfgGetOne(eg, "third_zm_app_secret") | |||
if thirdZmAppSecretData != nil { | |||
secretKey = thirdZmAppKeyData.Val | |||
} | |||
tikTokBase, _ := tik_tok.Base(eg, args["master_id"], "") | |||
detailUrl := "" | |||
if args["activityId"] != "" { | |||
postData := map[string]interface{}{} | |||
postData["gid"] = args["gid"] | |||
postData["appkey"] = appkey | |||
postData["secret_key"] = secretKey | |||
postData["category_id"] = args["activityId"] | |||
postData["p"] = "1" | |||
postData["size"] = "1" | |||
postData["token"] = newTeamToken | |||
list, _ := tik_tok.OwnTeamGoods(tikTokBase, postData) | |||
fmt.Println(list) | |||
if list != nil { | |||
for _, v := range *list { | |||
if v.GoodsID == args["gid"] { | |||
detailUrl = v.DetailURL | |||
} | |||
} | |||
} | |||
} | |||
if detailUrl != "" { | |||
postData := map[string]interface{}{ | |||
"product_url": detailUrl, | |||
"pick_extra": args["master_id"] + "_" + args["uid"], | |||
"newTeamToken": newTeamToken, | |||
} | |||
fmt.Println(postData) | |||
detailUrlData, err := tik_tok.OwnTeamUrl(tikTokBase, postData) | |||
fmt.Println(detailUrlData) | |||
if err == nil && detailUrlData["product_url"] != "" { | |||
args["coupon_url"] = detailUrlData["product_url"] | |||
} | |||
} | |||
} | |||
} | |||
case md.PVD_VIP: | |||
@@ -0,0 +1,67 @@ | |||
package tik_tok | |||
import ( | |||
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md" | |||
zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils" | |||
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/zhimeng" | |||
"fmt" | |||
"github.com/jinzhu/copier" | |||
) | |||
func OwnTeamGoods(tikTokBase *md.TikTokBase, tikTokArgs map[string]interface{}) (*[]zhimeng.TikTokData, error) { | |||
var data = make([]zhimeng.TikTokData, 0) | |||
var list = make([]TikTokGoods, 0) | |||
args := map[string]string{ | |||
"appkey": tikTokBase.ApiTeamAppKey, | |||
"appSecret": tikTokBase.ApiTeamAppSecret, | |||
"acctoken": zhios_third_party_utils.AnyToString(tikTokArgs["token"]), | |||
"activity_id": zhios_third_party_utils.AnyToString(tikTokArgs["category_id"]), | |||
"search_type": "0", | |||
"sort_type": "1", | |||
"status": "1", | |||
"page": zhios_third_party_utils.AnyToString(tikTokArgs["p"]), | |||
"count": zhios_third_party_utils.AnyToString(tikTokArgs["size"]), | |||
} | |||
if tikTokArgs["gid"] != "" { | |||
args["product_info"] = zhios_third_party_utils.AnyToString(tikTokArgs["gid"]) | |||
} | |||
for k, v := range args { | |||
if v == "<nil>" { | |||
args[k] = "" | |||
} | |||
} | |||
list, _, _ = ActivityProduct(args) | |||
if list == nil { | |||
return &data, nil | |||
} | |||
err := copier.Copy(&data, list) | |||
if err != nil { | |||
return &data, nil | |||
} | |||
return &data, nil | |||
} | |||
func OwnTeamUrl(tikTokBase *md.TikTokBase, tikTokArgs map[string]interface{}) (map[string]string, error) { | |||
args := map[string]string{ | |||
"appkey": tikTokBase.ApiTeamAppKey, | |||
"appSecret": tikTokBase.ApiTeamAppSecret, | |||
"acctoken": tikTokBase.TeamAccessToken, | |||
"product_url": zhios_third_party_utils.AnyToString(tikTokArgs["product_url"]), | |||
"pick_extra": zhios_third_party_utils.AnyToString(tikTokArgs["pick_extra"]), | |||
} | |||
if tikTokArgs["newTeamToken"] != "" && tikTokArgs["newTeamToken"] != nil { | |||
args["acctoken"] = zhios_third_party_utils.AnyToString(tikTokArgs["newTeamToken"]) | |||
} | |||
for k, v := range args { | |||
if v == "<nil>" { | |||
args[k] = "" | |||
} | |||
} | |||
fmt.Println("抖音", args) | |||
var data = make(map[string]string, 0) | |||
list := ProductUrl(args) | |||
if list == nil { | |||
return data, nil | |||
} | |||
return list, nil | |||
} |