Bladeren bron

抖音穿山甲

master
huangjiajun 10 maanden geleden
bovenliggende
commit
47d00c5d61
5 gewijzigde bestanden met toevoegingen van 163 en 33 verwijderingen
  1. +10
    -7
      chain_transfer/chain_transfer.go
  2. +143
    -26
      chain_transfer/svc/svc_turnchain.go
  3. +8
    -0
      db/offical/db_sys_cfg.go
  4. +1
    -0
      md/md_chain.go
  5. +1
    -0
      zhimeng/tik_tok_goods.go

+ 10
- 7
chain_transfer/chain_transfer.go Bestand weergeven

@@ -20,12 +20,15 @@ provider 渠道
gid 商品id
uid 用户id
*/
func ChainTransfer(eg *xorm.Engine, args map[string]string) map[string]string {
func ChainTransfer(eg *xorm.Engine, officialEg *xorm.Engine, args map[string]string) map[string]string {
var res = make(map[string]string)
res["url"] = ""
res["word"] = ""
userProfile, _ := db.UserProfileFindByID(eg, args["uid"])

if strings.Contains(args["gid"], "csjp") {
args["gid"] = strings.ReplaceAll(args["gid"], "csjp", "")
args["provider"] = "csjp"
}
UnionId := ""
if userProfile != nil {
if args["provider"] == md.PVD_TB || args["provider"] == md.PVD_TM {
@@ -60,7 +63,7 @@ func ChainTransfer(eg *xorm.Engine, args map[string]string) map[string]string {
if tbItemInfo != nil {
args["gid"] = zhios_third_party_utils.AnyToString(tbItemInfo.ItemID)
}
curls, err := svc.ConvertUrl(eg, args)
curls, err := svc.ConvertUrl(eg, officialEg, args)
if err != nil || curls == nil {
return res
}
@@ -83,9 +86,9 @@ func ChainTransfer(eg *xorm.Engine, args map[string]string) map[string]string {
res["word"] = curls.TaoBaoWord
case md.PVD_JDS:

case md.PVD_TIKTOK, md.PVD_KUAISHOU:
case md.PVD_TIKTOK, md.PVD_KUAISHOU, "csjp":
// 分享
if args["provider"] == md.PVD_TIKTOK {
if args["provider"] == md.PVD_TIKTOK || args["provider"] == "csjp" {
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")
@@ -150,7 +153,7 @@ func ChainTransfer(eg *xorm.Engine, args map[string]string) map[string]string {

}
if zhios_third_party_utils.InArr(args["provider"], []string{md.PVD_TB, md.PVD_TM}) == false {
curls, err := svc.ConvertUrl(eg, args)
curls, err := svc.ConvertUrl(eg, officialEg, args)
if err != nil || curls == nil {
return res
}
@@ -158,7 +161,7 @@ func ChainTransfer(eg *xorm.Engine, args map[string]string) map[string]string {
if args["provider"] == md.PVD_KUAISHOU {
res["url"] = curls.NoOpenAppURL
}
if args["provider"] == md.PVD_TIKTOK {
if args["provider"] == md.PVD_TIKTOK || args["provider"] == "csjp" {
res["url"] = curls.H5Url
if curls.Content != "" {
res["word"] = curls.Content


+ 143
- 26
chain_transfer/svc/svc_turnchain.go Bestand weergeven

@@ -26,7 +26,7 @@ import (
)

//转链主入口
func TurnChainFeatures(eg *xorm.Engine, tikTokBase map[string]string, user *model.User) (*md.ConvertedUrls, error) {
func TurnChainFeatures(eg *xorm.Engine, officialEg *xorm.Engine, tikTokBase map[string]string, user *model.User) (*md.ConvertedUrls, error) {
pvd := tikTokBase["pvd"]
dbName := tikTokBase["master_id"]
goodsId := tikTokBase["gid"]
@@ -63,9 +63,9 @@ func TurnChainFeatures(eg *xorm.Engine, tikTokBase map[string]string, user *mode
goodsId = ex[0]
}
tikTokBase["gid"] = goodsId
urls, err = TikTokTurnChain(eg, dbName, tikTokBase)
urls, err = TikTokTurnChain(eg, officialEg, dbName, tikTokBase)
case md.PVD_TB, md.PVD_TM:
urls, err = TBOrTmTurnChain(eg, dbName, tikTokBase)
urls, err = TBOrTmTurnChain(eg, officialEg, dbName, tikTokBase)
case md.PVD_JD:
urls, err = JDTurnChain(eg, dbName, tikTokBase)

@@ -76,8 +76,8 @@ func TurnChainFeatures(eg *xorm.Engine, tikTokBase map[string]string, user *mode
}
return urls, err
}
func TBOrTmTurnChain(eg *xorm.Engine, dbName string, args map[string]string) (*md.ConvertedUrls, error) {
urls, err := ConvertUrl(eg, args)
func TBOrTmTurnChain(eg *xorm.Engine, officialEg *xorm.Engine, dbName string, args map[string]string) (*md.ConvertedUrls, error) {
urls, err := ConvertUrl(eg, officialEg, args)
if err != nil {
return nil, err
}
@@ -197,9 +197,13 @@ func PDDTurnChain(eg *xorm.Engine, dbName string, args map[string]string) (*md.C
return urls, nil
}

func TikTokTurnChain(eg *xorm.Engine, dbName string, args map[string]string) (*md.ConvertedUrls, error) {
func TikTokTurnChain(eg *xorm.Engine, officialEg *xorm.Engine, dbName string, args map[string]string) (*md.ConvertedUrls, error) {
couponShareURL := ""
itemUrl := args["itemUrl"]
if strings.Contains(args["gid"], "csjp") {
args["provider"] = "csjp"
args["gid"] = strings.ReplaceAll(args["gid"], "csjp", "")
}
if itemUrl != "" && (strings.Contains(itemUrl, "ins_activity_param=") || strings.Contains(itemUrl, "pick_source=")) || (zhios_third_party_utils.StrToInt(args["tik_activity_id"]) > 0) {
tikTokBase, _ := tik_tok.Base(eg, dbName, "")
if zhios_third_party_utils.StrToInt(args["tik_activity_id"]) > 0 {
@@ -225,13 +229,13 @@ func TikTokTurnChain(eg *xorm.Engine, dbName string, args map[string]string) (*m
couponShareURL = "https://haohuo.jinritemai.com/views/product/item2?id=" + args["gid"]
}
args["coupon_url"] = couponShareURL
urls, err := ConvertUrl(eg, args)
urls, err := ConvertUrl(eg, officialEg, args)
if err != nil {
return nil, err
}
return urls, nil
}
func ConvertUrl(eg *xorm.Engine, args map[string]string) (*md.ConvertedUrls, error) {
func ConvertUrl(eg *xorm.Engine, officialEg *xorm.Engine, args map[string]string) (*md.ConvertedUrls, error) {
var (
err error
)
@@ -309,7 +313,7 @@ func ConvertUrl(eg *xorm.Engine, args map[string]string) (*md.ConvertedUrls, err
couponUrl,
couponPrice,
"")
case md.PVD_TIKTOK, md.PVD_KUAISHOU:
case md.PVD_TIKTOK, md.PVD_KUAISHOU, "csjp":
pid := "cloud_" + args["uid"]
thirdZmAppKeyData, err := db.SysCfgGetOne(eg, "third_zm_app_key")
if thirdZmAppKeyData == nil || err != nil {
@@ -340,6 +344,29 @@ func ConvertUrl(eg *xorm.Engine, args map[string]string) (*md.ConvertedUrls, err
urls, err = zhimeng.TikTokUrl(tikTokArgs)
}

} else if args["provider"] == "csjp" {
tikTokArgs["need_qr_code"] = "0"
tikTokArgs["external_info"] = pid + "_" + args["master_id"]
base := Base(eg, officialEg, args["master_id"], "")
args := map[string]string{
"app_id": base["app_id"],
"app_secret": base["app_secret"],
"product_url": zhios_third_party_utils.AnyToString(tikTokArgs["product_url"]),
"external_info": zhios_third_party_utils.AnyToString(tikTokArgs["external_info"]),
"share_type": "1,3,5",
}
send := ""
send, err = tik_tok.CsjpGoodsLink(args)
urls = &md.ConvertedUrls{
URL: gjson.Get(send, "data.dy_deeplink").String(),
ShortenURL: gjson.Get(send, "data.dy_deeplink").String(),
NoOpenAppURL: gjson.Get(send, "data.dy_deeplink").String(),
AppURL: gjson.Get(send, "data.dy_deeplink").String(),
ClickUrl: gjson.Get(send, "data.dy_deeplink").String(),
H5Url: gjson.Get(send, "data.dy_share_link").String(),
QrcodeUrl: gjson.Get(send, "data.dy_qr_code").String(),
Content: gjson.Get(send, "data.dy_password").String(),
}
} else if args["provider"] == md.PVD_KUAISHOU {
tikTokArgs["gid"] = args["gid"]
tikTokArgs["linkType"] = "101"
@@ -412,6 +439,27 @@ func ConvertUrl(eg *xorm.Engine, args map[string]string) (*md.ConvertedUrls, err
}
return urls, err
}
func Base(eg *xorm.Engine, officialEg *xorm.Engine, dbName, unionId string) map[string]string {
var cfg *model.SysUnionSet
if zhios_third_party_utils.StrToInt(unionId) == 0 {
cfg, _ = db.SysUnionByTikTokByUseByAuth(eg, dbName)
} else {
cfg = db.SysUnionById(eg, unionId)
}
tikTokCsjpAppId := offical.SysCfgByKeyStr(officialEg, "tik_tok_csjp_app_id")
tikTokCsjpAppSecret := offical.SysCfgByKeyStr(officialEg, "tik_tok_csjp_app_secret")
var tmp = map[string]string{
"app_id": tikTokCsjpAppId,
"app_secret": tikTokCsjpAppSecret,
}
if cfg != nil && cfg.AuthType == 2 {
tmp = map[string]string{
"app_id": gjson.Get(cfg.KeyData, "appId").String(),
"app_secret": gjson.Get(cfg.KeyData, "appSecret").String(),
}
}
return tmp
}

func TikTokUrl(eg *xorm.Engine, dbName string, gid, activityId string) string {
tikTokBase, _ := tik_tok.Base(eg, dbName, "")
@@ -484,7 +532,7 @@ func CommGetGoods(eg *xorm.Engine, officialEg *xorm.Engine, tmp map[string]strin
tikTokBase[k1] = v1
}
tikTokBase["itemUrl"] = countUrl
urls, err = TurnChainFeatures(eg, tikTokBase, user)
urls, err = TurnChainFeatures(eg, officialEg, tikTokBase, user)
if err != nil || urls == nil {
return tcPrase, reqCount
}
@@ -622,7 +670,7 @@ func FindTaobaoWord(eg *xorm.Engine, officialEg *xorm.Engine, tmp map[string]str
tikTokBase[k1] = v1
}
tikTokBase["itemUrl"] = reqCount
urls, err := TurnChainFeatures(eg, tikTokBase, user)
urls, err := TurnChainFeatures(eg, officialEg, tikTokBase, user)
if err != nil || urls == nil {
return "", "", "", ""
}
@@ -642,12 +690,16 @@ func FindTaobaoWord(eg *xorm.Engine, officialEg *xorm.Engine, tmp map[string]str
if strings.Contains(reqCount, "dou音") || strings.Contains(reqCount, "buydouke") || (strings.Contains(reqCount, "抖音") || strings.Contains(reqCount, "douyin")) && strings.Contains(reqCount, "【") {
info := CheckTikTokWord(eg, officialEg, dbName, reqCount, user, 0)
activityId := ""
pvd1 := md.PVD_TIKTOK
if info != nil {
if info.Pvd == md.PVD_TIKTOKLIFE {
return md.PVD_TIKTOKLIFE, info.ItemId, info.Word, info.Url
}
goodsId = info.ItemId
activityId = info.ActivityId
if info.IsCsjp == "1" {
pvd1 = "csjp"
}
}
var curls = new(md.ConvertedUrls)
var err error
@@ -679,9 +731,9 @@ func FindTaobaoWord(eg *xorm.Engine, officialEg *xorm.Engine, tmp map[string]str
args["gid"] = ""
args["coupon_url"] = reqCount
args["master_id"] = dbName
args["provider"] = md.PVD_TIKTOK
args["provider"] = pvd1
args["uid"] = zhios_third_party_utils.IntToStr(user.Uid)
curls, err = ConvertUrl(eg, args)
curls, err = ConvertUrl(eg, officialEg, args)
}
if err != nil {
return "", "", "", ""
@@ -761,20 +813,20 @@ func FindTaobaoWord(eg *xorm.Engine, officialEg *xorm.Engine, tmp map[string]str
}
}
if strings.Contains(strings.ToLower(reqCount), "taobao.com") || strings.Contains(strings.ToLower(reqCount), "tmall.com") {
taobaoWord := CheckTaobao(eg, dbName, reqCount, goodsParam)
taobaoWord := CheckTaobao(eg, officialEg, dbName, reqCount, goodsParam)
if taobaoWord != nil {
return md.PVD_TB, taobaoWord.ItemId, "", ""
}
}
if strings.Contains(reqCount, "s.click.Taobao") {
taobaoWord := CheckTaobao(eg, dbName, reqCount, goodsParam)
taobaoWord := CheckTaobao(eg, officialEg, dbName, reqCount, goodsParam)
if taobaoWord != nil {
return md.PVD_TB, taobaoWord.ItemId, "", ""
}
}
return
}
func CheckTaobao(eg *xorm.Engine, dbName, s string, args map[string]string) *md.ItemParseInfo {
func CheckTaobao(eg *xorm.Engine, officialEg *xorm.Engine, dbName, s string, args map[string]string) *md.ItemParseInfo {
bizSceneId := "2"
taobaoSdk, _ := taobao.NewTaobaoSDK(eg, args["master_id"], args["platform"], zhios_third_party_utils.StrToInt(args["acc_taobao_share_id"]), args["union_id"])
if taobaoSdk == nil {
@@ -798,7 +850,7 @@ func CheckTaobao(eg *xorm.Engine, dbName, s string, args map[string]string) *md.
couponUrl := itemInfo.URL
//调用好单库
//hdkItemInfo, itemInfo, providers := GetHdkDtkGoods(c, itemInfo, md.PVD_DTK)
convertUrl, err := ConvertUrl(eg, args)
convertUrl, err := ConvertUrl(eg, officialEg, args)
if err == nil && convertUrl != nil {
couponUrl = convertUrl.ShortenURL
}
@@ -814,6 +866,74 @@ func CheckTaobao(eg *xorm.Engine, dbName, s string, args map[string]string) *md.
ShopName: itemInfo.Nick,
}
}
func CsjpGoodsKlNew(eg *xorm.Engine, officialEg *xorm.Engine, dbName string, tikTokArgs map[string]interface{}) (*zhimeng.TikTokDetailData, error) {
base := Base(eg, officialEg, dbName, "")
if base["app_id"] == "" {
return nil, nil
}
args := map[string]string{
"app_id": base["app_id"],
"app_secret": base["app_secret"],
"command": tikTokArgs["content"].(string),
}
for k, v := range args {
if v == "<nil>" {
args[k] = ""
}
}
var data = zhimeng.TikTokDetailData{}
goods := tik_tok.CsjpKeyword(args)
if goods.ActivityId != "" {
data.ActivityId = goods.ActivityId
return &data, nil
}

if goods.GoodsID == "" {
return nil, nil
}
err := copier.Copy(&data, goods)
if err != nil {
return nil, nil
}
if zhios_third_party_utils.StrToFloat64(data.YhqPrice) > 0 {
data.Price = data.CostPrice
}
data.GoodsID += "csjp"
return &data, nil
}

func getFirstTikTokGoodsKl(eg *xorm.Engine, officialEg *xorm.Engine, dbName string, tikTokBase *md.TikTokBase, postData map[string]interface{}) (*zhimeng.TikTokDetailData, error) {
tikTokFirstGoods := db.SysCfgGetWithDb(eg, dbName, "tik_tok_first_goods")
var err error
var itemData *zhimeng.TikTokDetailData
isCsjp := "0"
if tikTokFirstGoods != "1" {
if zhios_third_party_utils.InArr(tikTokBase.AuthType, []string{"2", "3"}) {
itemData, err = tik_tok.OwnTikTokGoodsKlNew(tikTokBase, postData)
} else {
itemData, err = zhimeng.TikTokGoodsKlNew(postData)
}
if err != nil || itemData == nil || itemData.GoodsID == "" {
itemData, err = CsjpGoodsKlNew(eg, officialEg, dbName, postData)
isCsjp = "1"
}
} else {
itemData, err = CsjpGoodsKlNew(eg, officialEg, dbName, postData)
isCsjp = "1"
if err != nil || itemData == nil || itemData.GoodsID == "" {
if zhios_third_party_utils.InArr(tikTokBase.AuthType, []string{"2", "3"}) {
itemData, err = tik_tok.OwnTikTokGoodsKlNew(tikTokBase, postData)
} else {
itemData, err = zhimeng.TikTokGoodsKlNew(postData)
}
isCsjp = "0"
}
}
if itemData != nil {
itemData.IsCsjp = isCsjp
}
return itemData, err
}

func CheckTikTokWord(eg *xorm.Engine, officialEg *xorm.Engine, dbName, s string, user *model.User, isChange int) *md.ItemParseInfo {
var postData = map[string]interface{}{}
@@ -822,17 +942,12 @@ func CheckTikTokWord(eg *xorm.Engine, officialEg *xorm.Engine, dbName, s string,
postData["content"] = s
now := time.Now()
tikTokBase, _ := tik_tok.Base(eg, dbName, "")
var itemData *zhimeng.TikTokDetailData
var err error
if zhios_third_party_utils.InArr(tikTokBase.AuthType, []string{"2", "3"}) {
itemData, err = tik_tok.OwnTikTokGoodsKlNew(tikTokBase, postData)
} else {
itemData, err = zhimeng.TikTokGoodsKlNew(postData)
}
itemData, err := getFirstTikTokGoodsKl(eg, officialEg, dbName, tikTokBase, postData)
fmt.Println("1", time.Since(now))
provider := md.PVD_TIKTOK
word := s
url := ""
isCsjp := "0"
if err != nil || itemData == nil {
tikTokOpenUid := offical.MasterListCfgGetOneData(officialEg, "0", "tik_tok_open_uid")
tikTokOpenPid := offical.MasterListCfgGetOneData(officialEg, "0", "tik_tok_open_pid")
@@ -870,6 +985,7 @@ func CheckTikTokWord(eg *xorm.Engine, officialEg *xorm.Engine, dbName, s string,
if itemData.GoodsID == "" {
return nil
}
isCsjp = itemData.IsCsjp
couponUrl := ""
if user != nil {
if isChange == 1 {
@@ -878,7 +994,7 @@ func CheckTikTokWord(eg *xorm.Engine, officialEg *xorm.Engine, dbName, s string,
args["master_id"] = dbName
args["provider"] = provider
args["uid"] = zhios_third_party_utils.IntToStr(user.Uid)
convertUrl, err := ConvertUrl(eg, args)
convertUrl, err := ConvertUrl(eg, officialEg, args)
if err == nil && convertUrl != nil {
couponUrl = convertUrl.AppURL
word = convertUrl.Content
@@ -888,6 +1004,7 @@ func CheckTikTokWord(eg *xorm.Engine, officialEg *xorm.Engine, dbName, s string,
fmt.Println("2", time.Since(now))

return &md.ItemParseInfo{
IsCsjp: isCsjp,
Url: url,
Pvd: provider,
Word: word,
@@ -953,7 +1070,7 @@ func CheckKuaishouWord(eg *xorm.Engine, officialEg *xorm.Engine, dbName string,
args["master_id"] = dbName
args["provider"] = provider
args["uid"] = zhios_third_party_utils.IntToStr(user.Uid)
convertUrl, err := ConvertUrl(eg, args)
convertUrl, err := ConvertUrl(eg, officialEg, args)
if err == nil && convertUrl != nil {
couponUrl = convertUrl.AppURL
word = convertUrl.Content


+ 8
- 0
db/offical/db_sys_cfg.go Bestand weergeven

@@ -13,3 +13,11 @@ func SysCfgByKey(engine *xorm.Engine, key string) string {
}
return data.V
}
func SysCfgByKeyStr(engine *xorm.Engine, key string) string {
var data model.SysCfg
get, err := engine.Where("k=?", key).Get(&data)
if get == false || err != nil {
return ""
}
return data.V
}

+ 1
- 0
md/md_chain.go Bestand weergeven

@@ -49,6 +49,7 @@ type TurnGoods struct {
}

type ItemParseInfo struct {
IsCsjp string `json:"is_csjp"`
ItemId string `json:"item_id"` // 商品ID
Title string `json:"title"` // 标题
CategoryId string `json:"category_id"` // 目录ID


+ 1
- 0
zhimeng/tik_tok_goods.go Bestand weergeven

@@ -45,6 +45,7 @@ type TikTokData struct {
}

type TikTokDetailData struct {
IsCsjp string `json:"is_csjp"`
Commission string `json:"commission"`
PublicCommission string `json:"public_commission"`
CostPrice string `json:"cost_price"`


Laden…
Annuleren
Opslaan