@@ -26,7 +26,16 @@ func ChainTransfer(eg *xorm.Engine, args map[string]string) map[string]string { | |||||
res["word"] = "" | res["word"] = "" | ||||
userProfile, _ := db.UserProfileFindByID(eg, args["uid"]) | userProfile, _ := db.UserProfileFindByID(eg, args["uid"]) | ||||
UnionId := "" | |||||
if userProfile != nil { | 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) | args["acc_taobao_share_id"] = zhios_third_party_utils.Int64ToStr(userProfile.AccTaobaoShareId) | ||||
if userProfile.AccJdCloudId == "" { | if userProfile.AccJdCloudId == "" { | ||||
userProfile.AccJdCloudId = userProfile.AccJdShareId | userProfile.AccJdCloudId = userProfile.AccJdShareId | ||||
@@ -36,7 +45,7 @@ func ChainTransfer(eg *xorm.Engine, args map[string]string) map[string]string { | |||||
} | } | ||||
switch args["provider"] { | switch args["provider"] { | ||||
case md.PVD_TB, md.PVD_TM: | 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 { | if err != nil { | ||||
return res | return res | ||||
} | } | ||||
@@ -77,7 +77,7 @@ func TBOrTmTurnChain(eg *xorm.Engine, dbName string, args map[string]string) (*m | |||||
var couponUrl = "" | var couponUrl = "" | ||||
if urls != nil { | 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 { | if err != nil { | ||||
fmt.Println("=======商品10", err) | fmt.Println("=======商品10", err) | ||||
@@ -231,7 +231,7 @@ func ConvertUrl(eg *xorm.Engine, args map[string]string) (*md.ConvertedUrls, err | |||||
var urls *md.ConvertedUrls | var urls *md.ConvertedUrls | ||||
switch args["provider"] { | switch args["provider"] { | ||||
case md.PVD_TB, md.PVD_TM: | 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 { | if err != nil { | ||||
return nil, err | 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 { | func CheckTaobaoWordGetId(eg *xorm.Engine, dbName string, s string, args map[string]string) string { | ||||
ak := db.SysCfgGetWithDb(eg, dbName, md.KEY_CFG_ZM_AK) | ak := db.SysCfgGetWithDb(eg, dbName, md.KEY_CFG_ZM_AK) | ||||
sk := db.SysCfgGetWithDb(eg, dbName, md.KEY_CFG_ZM_SK) | 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 { | if taobaoSdk == nil { | ||||
return "" | return "" | ||||
} | } | ||||
@@ -553,7 +553,7 @@ func CommGetGoods(eg *xorm.Engine, officialEg *xorm.Engine, tmp map[string]strin | |||||
return tcPrase, reqCount | return tcPrase, reqCount | ||||
} | } | ||||
func ReplaceTbAll(eg *xorm.Engine, url string, args map[string]string) (taoBaoWord, shortURL string) { | 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 { | if err != nil { | ||||
return | return | ||||
} | } | ||||
@@ -779,7 +779,7 @@ func CheckTaobao(eg *xorm.Engine, dbName, s string, args map[string]string) *md. | |||||
bizSceneId = "" | 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) | itemInfo, err := taobaoSdk.ItemDetailByLink(s, bizSceneId) | ||||
if itemInfo == nil || err != nil { | if itemInfo == nil || err != nil { | ||||
return 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) { | 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先请求淘宝 | //获取到传进来的id先请求淘宝 | ||||
//根据prodId获取对应产品信息 | //根据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 { | if err != nil { | ||||
//e.OutErr(c, e.ERR_SYSUNION_CONFIG, err) | //e.OutErr(c, e.ERR_SYSUNION_CONFIG, err) | ||||
@@ -25,6 +25,12 @@ func TurnChain(eg *xorm.Engine, officialEg *xorm.Engine, args map[string]string) | |||||
user, _ := db.UserFindByID(eg, args["uid"]) | user, _ := db.UserFindByID(eg, args["uid"]) | ||||
userProfile, _ := db.UserProfileFindByID(eg, user.Uid) | userProfile, _ := db.UserProfileFindByID(eg, user.Uid) | ||||
if userProfile != nil { | 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) | args["acc_taobao_share_id"] = zhios_third_party_utils.Int64ToStr(userProfile.AccTaobaoShareId) | ||||
if userProfile.AccJdCloudId == "" { | if userProfile.AccJdCloudId == "" { | ||||
userProfile.AccJdCloudId = userProfile.AccJdShareId | userProfile.AccJdCloudId = userProfile.AccJdShareId | ||||
@@ -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 | |||||
} |
@@ -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)"` | |||||
} |
@@ -2,6 +2,7 @@ package taobao | |||||
import ( | 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" | ||||
"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" | "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" | zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils" | ||||
"errors" | "errors" | ||||
@@ -9,12 +10,17 @@ import ( | |||||
"xorm.io/xorm" | "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 | var cfg *TB | ||||
@@ -27,7 +27,7 @@ type TaoBaoArgs struct { | |||||
func TaoBaoFeaturedList(eg *xorm.Engine, dbName, Platform string, AccTaobaoShareId int, postData map[string]string) []map[string]string { | func TaoBaoFeaturedList(eg *xorm.Engine, dbName, Platform string, AccTaobaoShareId int, postData map[string]string) []map[string]string { | ||||
var goods = make([]map[string]string, 0) | var goods = make([]map[string]string, 0) | ||||
sdk, err := NewTaobaoSDK(eg, dbName, Platform, AccTaobaoShareId) | |||||
sdk, err := NewTaobaoSDK(eg, dbName, Platform, AccTaobaoShareId, "") | |||||
if err != nil { | if err != nil { | ||||
return goods | 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 { | func TaoBaoSearchList(eg *xorm.Engine, dbName, Platform string, AccTaobaoShareId int, postData map[string]string) []map[string]string { | ||||
var goods = make([]map[string]string, 0) | var goods = make([]map[string]string, 0) | ||||
sdk, err := NewTaobaoSDK(eg, dbName, Platform, AccTaobaoShareId) | |||||
sdk, err := NewTaobaoSDK(eg, dbName, Platform, AccTaobaoShareId, "") | |||||
if err != nil { | if err != nil { | ||||
return goods | return goods | ||||
} | } | ||||