Browse Source

更新

master
huangjiajun 11 months ago
parent
commit
467bae29f3
7 changed files with 85 additions and 14 deletions
  1. +10
    -1
      chain_transfer/chain_transfer.go
  2. +6
    -6
      chain_transfer/svc/svc_turnchain.go
  3. +6
    -0
      chain_transfer/turn_chain.go
  4. +39
    -0
      db/db_taobao_user_relation.go
  5. +11
    -0
      db/model/taobao_user_relation.go
  6. +11
    -5
      taobao/base.go
  7. +2
    -2
      taobao/taobao.go

+ 10
- 1
chain_transfer/chain_transfer.go View File

@@ -26,7 +26,16 @@ func ChainTransfer(eg *xorm.Engine, args map[string]string) map[string]string {
res["word"] = ""
userProfile, _ := db.UserProfileFindByID(eg, args["uid"])

UnionId := ""
if userProfile != nil {
if args["provider"] == md.PVD_TB || args["provider"] == md.PVD_TM {
//新的渠道id 存储
relation := db.GetTaobaoUserRelationByUid(eg, userProfile.Uid)
if relation != nil {
userProfile.AccTaobaoShareId = relation.RelationId
UnionId = zhios_third_party_utils.IntToStr(relation.UnionId)
}
}
args["acc_taobao_share_id"] = zhios_third_party_utils.Int64ToStr(userProfile.AccTaobaoShareId)
if userProfile.AccJdCloudId == "" {
userProfile.AccJdCloudId = userProfile.AccJdShareId
@@ -36,7 +45,7 @@ func ChainTransfer(eg *xorm.Engine, args map[string]string) map[string]string {
}
switch args["provider"] {
case md.PVD_TB, md.PVD_TM:
taobaoSdk, err := taobao.NewTaobaoSDK(eg, args["master_id"], args["platform"], zhios_third_party_utils.StrToInt(args["acc_taobao_share_id"]))
taobaoSdk, err := taobao.NewTaobaoSDK(eg, args["master_id"], args["platform"], zhios_third_party_utils.StrToInt(args["acc_taobao_share_id"]), UnionId)
if err != nil {
return res
}


+ 6
- 6
chain_transfer/svc/svc_turnchain.go View File

@@ -77,7 +77,7 @@ func TBOrTmTurnChain(eg *xorm.Engine, dbName string, args map[string]string) (*m

var couponUrl = ""
if urls != nil {
taobaoSdk, err := taobao.NewTaobaoSDK(eg, dbName, args["platform"], zhios_third_party_utils.StrToInt(args["acc_taobao_share_id"]))
taobaoSdk, err := taobao.NewTaobaoSDK(eg, dbName, args["platform"], zhios_third_party_utils.StrToInt(args["acc_taobao_share_id"]), args["union_id"])
if err != nil {
fmt.Println("=======商品10", err)

@@ -231,7 +231,7 @@ func ConvertUrl(eg *xorm.Engine, args map[string]string) (*md.ConvertedUrls, err
var urls *md.ConvertedUrls
switch args["provider"] {
case md.PVD_TB, md.PVD_TM:
taobaoSdk, err := taobao.NewTaobaoSDK(eg, args["master_id"], args["platform"], zhios_third_party_utils.StrToInt(args["acc_taobao_share_id"]))
taobaoSdk, err := taobao.NewTaobaoSDK(eg, args["master_id"], args["platform"], zhios_third_party_utils.StrToInt(args["acc_taobao_share_id"]), args["union_id"])
if err != nil {
return nil, err
}
@@ -440,7 +440,7 @@ func TikTokUrl(eg *xorm.Engine, dbName string, gid, activityId string) string {
func CheckTaobaoWordGetId(eg *xorm.Engine, dbName string, s string, args map[string]string) string {
ak := db.SysCfgGetWithDb(eg, dbName, md.KEY_CFG_ZM_AK)
sk := db.SysCfgGetWithDb(eg, dbName, md.KEY_CFG_ZM_SK)
taobaoSdk, _ := taobao.NewTaobaoSDK(eg, dbName, args["platfrom"], zhios_third_party_utils.StrToInt(args["acc_taobao_share_id"]))
taobaoSdk, _ := taobao.NewTaobaoSDK(eg, dbName, args["platfrom"], zhios_third_party_utils.StrToInt(args["acc_taobao_share_id"]), args["union_id"])
if taobaoSdk == nil {
return ""
}
@@ -553,7 +553,7 @@ func CommGetGoods(eg *xorm.Engine, officialEg *xorm.Engine, tmp map[string]strin
return tcPrase, reqCount
}
func ReplaceTbAll(eg *xorm.Engine, url string, args map[string]string) (taoBaoWord, shortURL string) {
taobaoSdk, err := taobao.NewTaobaoSDK(eg, args["master_id"], args["platform"], zhios_third_party_utils.StrToInt(args["acc_taobao_share_id"]))
taobaoSdk, err := taobao.NewTaobaoSDK(eg, args["master_id"], args["platform"], zhios_third_party_utils.StrToInt(args["acc_taobao_share_id"]), args["union_id"])
if err != nil {
return
}
@@ -779,7 +779,7 @@ func CheckTaobao(eg *xorm.Engine, dbName, s string, args map[string]string) *md.
bizSceneId = ""

}
taobaoSdk, _ := taobao.NewTaobaoSDK(eg, args["master_id"], args["platform"], zhios_third_party_utils.StrToInt(args["acc_taobao_share_id"]))
taobaoSdk, _ := taobao.NewTaobaoSDK(eg, args["master_id"], args["platform"], zhios_third_party_utils.StrToInt(args["acc_taobao_share_id"]), args["union_id"])
itemInfo, err := taobaoSdk.ItemDetailByLink(s, bizSceneId)
if itemInfo == nil || err != nil {
return nil
@@ -1029,7 +1029,7 @@ func TikTokByGoodsID(eg *xorm.Engine, officialEg *xorm.Engine, tmp map[string]st
func TBByGoodsId(eg *xorm.Engine, officialEg *xorm.Engine, tmp map[string]string, goodsId, url string, mdData *md.MoreDetailResponse) (productDetail *md.ProductDetailResponse, pvd, couponShareURL, couponAmount string) {
//获取到传进来的id先请求淘宝
//根据prodId获取对应产品信息
taobaoSdk, err := taobao.NewTaobaoSDK(eg, tmp["master_id"], tmp["platform"], zhios_third_party_utils.StrToInt(tmp["acc_taobao_share_id"]))
taobaoSdk, err := taobao.NewTaobaoSDK(eg, tmp["master_id"], tmp["platform"], zhios_third_party_utils.StrToInt(tmp["acc_taobao_share_id"]), tmp["union_id"])

if err != nil {
//e.OutErr(c, e.ERR_SYSUNION_CONFIG, err)


+ 6
- 0
chain_transfer/turn_chain.go View File

@@ -25,6 +25,12 @@ func TurnChain(eg *xorm.Engine, officialEg *xorm.Engine, args map[string]string)
user, _ := db.UserFindByID(eg, args["uid"])
userProfile, _ := db.UserProfileFindByID(eg, user.Uid)
if userProfile != nil {
//新的渠道id 存储
relation := db.GetTaobaoUserRelationByUid(eg, userProfile.Uid)
if relation != nil {
userProfile.AccTaobaoShareId = relation.RelationId
args["union_id"] = zhios_third_party_utils.IntToStr(relation.UnionId)
}
args["acc_taobao_share_id"] = zhios_third_party_utils.Int64ToStr(userProfile.AccTaobaoShareId)
if userProfile.AccJdCloudId == "" {
userProfile.AccJdCloudId = userProfile.AccJdShareId


+ 39
- 0
db/db_taobao_user_relation.go View File

@@ -0,0 +1,39 @@
package db

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/db/model"
"xorm.io/xorm"
)

func GetTaobaoUserRelation(eg *xorm.Engine, unionId, uid int) *model.TaobaoUserRelation {
var data model.TaobaoUserRelation
get, _ := eg.Where("union_id=? and uid=?", unionId, uid).Get(&data)
if get == false {
return nil
}
return &data
}
func GetTaobaoUserRelationByUid(eg *xorm.Engine, uid int) *model.TaobaoUserRelation {
var data model.TaobaoUserRelation
get, _ := eg.Where(" uid=?", uid).Get(&data)
if get == false {
return nil
}
return &data
}
func TaobaoUserRelationExistByRelationID(Db *xorm.Engine, RelationID string) (bool, error) {
has, err := Db.Where("relation_id = ? ", RelationID).Exist(&model.TaobaoUserRelation{})

if err != nil {
return false, err
}
return has, nil
}
func TaobaoUserRelationExistBySpecialId(Db *xorm.Engine, RelationID string) (bool, error) {
has, err := Db.Where("special_id = ? ", RelationID).Exist(&model.TaobaoUserRelation{})

if err != nil {
return false, err
}
return has, nil
}

+ 11
- 0
db/model/taobao_user_relation.go View File

@@ -0,0 +1,11 @@
package model

type TaobaoUserRelation struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
Uid int `json:"uid" xorm:"default 0 unique(uid) INT(11)"`
UnionId int `json:"union_id" xorm:"default 0 unique(uid) INT(11)"`
RelationId int64 `json:"relation_id" xorm:"default 0 BIGINT(12)"`
SpecialId int64 `json:"special_id" xorm:"default 0 BIGINT(12)"`
Nickname string `json:"nickname" xorm:"not null default '' comment('淘宝昵称') VARCHAR(50)"`
Time int64 `json:"time" xorm:"not null default 0 comment('淘宝授权备案时间') BIGINT(11)"`
}

+ 11
- 5
taobao/base.go View File

@@ -2,6 +2,7 @@ package taobao

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/db"
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/db/model"
"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"
"errors"
@@ -9,12 +10,17 @@ import (
"xorm.io/xorm"
)

func NewTaobaoSDK(eg *xorm.Engine, dbName, Platform string, AccTaobaoShareId int) (*TB, error) {
func NewTaobaoSDK(eg *xorm.Engine, dbName, Platform string, AccTaobaoShareId int, UnionId string) (*TB, error) {
// 从联盟设置中获取淘宝配置

taobaoCfg, err := db.SysUnionByTaobaoByUseByAuth(eg, dbName)
if err != nil {
return nil, err
var taobaoCfg *model.SysUnionSet
var err error
if UnionId != "" {
taobaoCfg = db.SysUnionById(eg, UnionId)
} else {
taobaoCfg, err = db.SysUnionByTaobaoByUseByAuth(eg, dbName)
if err != nil {
return nil, err
}
}

var cfg *TB


+ 2
- 2
taobao/taobao.go View File

@@ -27,7 +27,7 @@ type TaoBaoArgs struct {

func TaoBaoFeaturedList(eg *xorm.Engine, dbName, Platform string, AccTaobaoShareId int, postData map[string]string) []map[string]string {
var goods = make([]map[string]string, 0)
sdk, err := NewTaobaoSDK(eg, dbName, Platform, AccTaobaoShareId)
sdk, err := NewTaobaoSDK(eg, dbName, Platform, AccTaobaoShareId, "")
if err != nil {
return goods
}
@@ -55,7 +55,7 @@ func TaoBaoFeaturedList(eg *xorm.Engine, dbName, Platform string, AccTaobaoShare
}
func TaoBaoSearchList(eg *xorm.Engine, dbName, Platform string, AccTaobaoShareId int, postData map[string]string) []map[string]string {
var goods = make([]map[string]string, 0)
sdk, err := NewTaobaoSDK(eg, dbName, Platform, AccTaobaoShareId)
sdk, err := NewTaobaoSDK(eg, dbName, Platform, AccTaobaoShareId, "")
if err != nil {
return goods
}


Loading…
Cancel
Save