huangjiajun 1 vuosi sitten
vanhempi
commit
9cedaa70bd
27 muutettua tiedostoa jossa 1757 lisäystä ja 0 poistoa
  1. +261
    -0
      chain_transfer/chain_transfer.go
  2. +58
    -0
      db/db_taobao_relation_pid.go
  3. +23
    -0
      db/db_user.go
  4. +13
    -0
      db/model/taobao_relation_pid.go
  5. +32
    -0
      db/model/user.go
  6. +93
    -0
      db/model/user_profile.go
  7. +53
    -0
      haodanku/haodanku.go
  8. +29
    -0
      md/haodanku.go
  9. +233
    -0
      md/product_detail.go
  10. +5
    -0
      md/provider.go
  11. +11
    -0
      md/publisher_info.go
  12. +7
    -0
      md/taobao.go
  13. +34
    -0
      md/url.go
  14. +123
    -0
      taobao/taobao.go
  15. +60
    -0
      taobao/taobao_relation_pid.go
  16. +35
    -0
      taobao/word_create.go
  17. +28
    -0
      tik_tok/svc_tik_tok_convert.go
  18. +7
    -0
      zhimeng/jd.go
  19. +47
    -0
      zhimeng/jd_convert_url.go
  20. +40
    -0
      zhimeng/kuaishou_goods_url.go
  21. +50
    -0
      zhimeng/pdd_convert_url.go
  22. +8
    -0
      zhimeng/pdd_zhimeng.go
  23. +285
    -0
      zhimeng/sdk.go
  24. +53
    -0
      zhimeng/taobao_convert_url.go
  25. +50
    -0
      zhimeng/taobao_publisher_info_list.go
  26. +77
    -0
      zhimeng/tik_tok_goods_url.go
  27. +42
    -0
      zhimeng/vip_convert_url.go

+ 261
- 0
chain_transfer/chain_transfer.go Näytä tiedosto

@@ -0,0 +1,261 @@
package chain_transfer

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/haodanku"
"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/taobao"
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/tik_tok"
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"
"time"
"xorm.io/xorm"
)

/***
master_id 站长id
provider 渠道
gid 商品id
uid 用户id
*/
func ChainTransfer(eg *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 userProfile != nil {
args["acc_taobao_share_id"] = zhios_third_party_utils.Int64ToStr(userProfile.AccTaobaoShareId)
args["acc_jd_share_id"] = userProfile.AccJdCloudId
args["acc_pdd_self_id"] = userProfile.AccPddSelfId
}
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"]))
if err != nil {
return res
}
bizSceneId := "2"
tbItemInfo, err := taobaoSdk.ItemDetailById(args["gid"], bizSceneId)
if err != nil {
fmt.Println("=======商品1", err)

return res
}
if tbItemInfo != nil {
args["gid"] = zhios_third_party_utils.AnyToString(tbItemInfo.ItemID)
}
curls, err := ConvertUrl(eg, args)
if err != nil || curls == nil {
return res
}
//调用好单库
itemInfo, _ := haodanku.HaodankuDetail(args["gid"])
//如果优惠券高
if zhios_third_party_utils.StrToFloat64(itemInfo.CouponAmount) > zhios_third_party_utils.StrToFloat64(tbItemInfo.CouponAmount) && zhios_third_party_utils.StrToFloat64(itemInfo.CouponAmount) > 0 {
curls.ShortenURL = "https://uland.taobao.com/coupon/edetail?activityId=" + itemInfo.ActivityId + "&itemId=" + args["gid"] + "&pid=" + taobaoSdk.SharePromoIdWeb + "&nowake=1"
}
//如果是小程序 并且没有渠道id 就用会员运营id 和推广位
if zhios_third_party_utils.StrToInt(args["acc_taobao_share_id"]) == 0 {
if curls.NewPid != "" {
curls.ShortenURL = curls.ShortenURL + "&relationId=" + zhios_third_party_utils.Int64ToStr(curls.TbShareId)
}
} else {
curls.ShortenURL = curls.ShortenURL + "&relationId=" + args["acc_taobao_share_id"]
}

if curls.TaoBaoWord == "" {
// 生成淘口令
taokou, err := taobaoSdk.WordCreate(curls.ShortenURL, "12345")
if err != nil {
taokou = new(md.TaobaoWord)
}
curls.TaoBaoWord = taokou.Text
}
res["url"] = curls.ShortenURL
res["word"] = curls.TaoBaoWord
case md.PVD_JD:

case md.PVD_TIKTOK, md.PVD_KUAISHOU:
// 分享
if args["provider"] == md.PVD_TIKTOK {
args["coupon_url"] = "https://haohuo.jinritemai.com/views/product/item2?id=" + args["gid"]
}

case md.PVD_VIP:

}
if zhios_third_party_utils.InArr(args["provider"], []string{md.PVD_TB, md.PVD_TM}) == false {
curls, err := ConvertUrl(eg, args)
if err != nil || curls == nil {
return res
}
res["url"] = curls.ShortenURL
if curls.Content != "" && args["provider"] == md.PVD_TIKTOK {
res["word"] = curls.Content
}
}
return res
}

func ConvertUrl(eg *xorm.Engine, args map[string]string) (*md.ConvertedUrls, error) {
var (
err error
)
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"]))
if err != nil {
return nil, err
}
tb := taobaoSdk
var promoId = tb.SharePromoIdWeb
var promoId1 string
var taobaoShareId1 string
var IsWxTaobaoAuth bool
fmt.Println(IsWxTaobaoAuth)
if zhios_third_party_utils.StrToInt(args["acc_taobao_share_id"]) == 0 {
if tb.AppletIsAuth == "1" {
IsWxTaobaoAuth, taobaoShareId1, promoId1 = taobao.TaobaoRelationPid(eg, args)
if IsWxTaobaoAuth == false {
return nil, err
} else {
promoId = promoId1
}
}
}
thirdZmAppKeyData, err := db.SysCfgGetOne(eg, "third_zm_app_key")
if thirdZmAppKeyData == nil || err != nil {
return urls, err
}
thirdZmAppSecretData, err := db.SysCfgGetOne(eg, "third_zm_app_secret")
if thirdZmAppSecretData == nil || err != nil {
return urls, err
}
urls, err = zhimeng.TaobaoConvertUrl(thirdZmAppKeyData.Val,
thirdZmAppSecretData.Val, args["gid"], promoId, tb.UserSID, "", tb.Svc_AK)
if urls != nil {
if taobaoShareId1 != "" {
urls.TbShareId = zhios_third_party_utils.StrToInt64(taobaoShareId1)
}
if promoId1 != "" {
urls.NewPid = promoId1
}
}
case md.PVD_JD:
thirdZmAppKeyData, err := db.SysCfgGetOne(eg, "third_zm_app_key")
if thirdZmAppKeyData == nil || err != nil {
return urls, err
}
thirdZmAppSecretData, err := db.SysCfgGetOne(eg, "third_zm_app_secret")
if thirdZmAppSecretData == nil || err != nil {
return urls, err
}
// 初始化京东配置
pid := args["acc_jd_share_id"]
postData := make(map[string]interface{})
postData["gid"] = args["gid"]
postData["appkey"] = thirdZmAppKeyData.Val
postData["secret_key"] = thirdZmAppSecretData.Val
jdData, err := zhimeng.NewZhiMengJingDongSDK().
SelectFunction("getgoodsinfo").
WithArgs(postData).
Result()
mdData := &md.MoreDetailResponse{}
// to struct
couponUrl := ""
couponPrice := ""
err = jdData.ToStruct(mdData)
if err == nil && mdData != nil && mdData.CouponURL != "" {
couponUrl = mdData.CouponURL
couponPrice = mdData.CouponPrice
}
urls, err = zhimeng.JDConvertUrl(
thirdZmAppKeyData.Val,
thirdZmAppSecretData.Val,
args["gid"],
pid,
couponUrl,
couponPrice,
"")
case md.PVD_TIKTOK, md.PVD_KUAISHOU:
pid := "cloud_" + args["uid"]
thirdZmAppKeyData, err := db.SysCfgGetOne(eg, "third_zm_app_key")
if thirdZmAppKeyData == nil || err != nil {
return urls, err
}
thirdZmAppSecretData, err := db.SysCfgGetOne(eg, "third_zm_app_secret")
if thirdZmAppSecretData == nil || err != nil {
return urls, err
}
tikTokArgs := map[string]interface{}{
"appkey": thirdZmAppKeyData.Val,
"secret_key": thirdZmAppSecretData.Val,
"product_url": args["coupon_url"],
"external_info": pid,
}

if args["provider"] == md.PVD_TIKTOK {
tikTokArgs["need_qr_code"] = "0"

tikTokBase, _ := tik_tok.Base(eg, args["master_id"], "")
if zhios_third_party_utils.InArr(tikTokBase.AuthType, []string{"2", "3"}) {
if time.Now().Unix() > 1670055300 {
tikTokArgs["external_info"] = pid + "_" + args["master_id"]
}
urls, err = tik_tok.OwnTikTokUrl(tikTokBase, tikTokArgs)
} else {
tikTokArgs["external_info"] = pid + "_" + args["master_id"]
urls, err = zhimeng.TikTokUrl(tikTokArgs)
}

} else if args["provider"] == md.PVD_KUAISHOU {
tikTokArgs["gid"] = args["gid"]
tikTokArgs["linkType"] = "101"
tikTokArgs["genPoster"] = "0"
tikTokArgs["external_info"] = pid + "_" + args["master_id"]
urls, err = zhimeng.KuaiShouUrl(tikTokArgs)
}
case md.PVD_VIP:
thirdZmAppKeyData, err := db.SysCfgGetOne(eg, "third_zm_app_key")
if thirdZmAppKeyData == nil || err != nil {
return urls, err
}
thirdZmAppSecretData, err := db.SysCfgGetOne(eg, "third_zm_app_secret")
if thirdZmAppSecretData == nil || err != nil {
return urls, err
}
// 初始化vip配置
pid := args["master_id"] + "_vip_cloud_" + args["uid"]
openId := args["master_id"] + "_vip_" + args["uid"]
urls, err = zhimeng.VipConvertUrl(
thirdZmAppKeyData.Val,
thirdZmAppSecretData.Val,
args["gid"],
pid,
"", "", openId, "1")
case md.PVD_PDD:
pid := args["acc_pdd_self_id"]
thirdZmAppKeyData, err := db.SysCfgGetOne(eg, "third_zm_app_key")
if thirdZmAppKeyData == nil || err != nil {
return urls, err
}
thirdZmAppSecretData, err := db.SysCfgGetOne(eg, "third_zm_app_secret")
if thirdZmAppSecretData == nil || err != nil {
return urls, err
}
miniApp := "0"
isShares := "2"
urls, err = zhimeng.PDDConvertUrl(
thirdZmAppKeyData.Val,
thirdZmAppSecretData.Val,
args["gid"],
pid,
"",
miniApp,
"1", isShares)
}
return urls, err
}

+ 58
- 0
db/db_taobao_relation_pid.go Näytä tiedosto

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

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

func IsExistRelationPid(eg *xorm.Engine, uid, union_id int) *model.TaobaoRelationPid {
var data model.TaobaoRelationPid
exist, err := eg.Where("uid=? and union_id=?", uid, union_id).Get(&data)
if exist == false || err != nil {
return nil
}
return &data
}

func GetRelation(eg *xorm.Engine, unionId, count int) (string, int64) {
var data model.TaobaoRelation
get, err := eg.Where("union_id=? and count<?", unionId, count).OrderBy("id asc").Get(&data)
if get == false || err != nil {
return "", 0
}
return data.RelationId, data.Id
}

func GetRelationPid(eg *xorm.Engine, unionId int, pid []string, relationId string) *[]model.TaobaoRelationPid {
var data []model.TaobaoRelationPid
err := eg.In("pid", pid).Where("union_id=? and relation_id=?", unionId, relationId).OrderBy("id asc").Find(&data)
if err != nil {
return nil
}
return &data
}

// 批量订单id查找订单
func TaobaoRelationListByTaobaoIds(Db *xorm.Engine, unionId int, ids []int64) (*[]model.TaobaoRelation, error) {
var o []model.TaobaoRelation
if err := Db.In("relation_id", ids).Where("union_id=?", unionId).Find(&o); err != nil {
return nil, logx.Error(err)
}
return &o, nil
}
func TaobaoRelationListInsert(Db *xorm.Engine, m *model.TaobaoRelation) bool {
_, err := Db.InsertOne(m)
if err != nil {
logx.Warn(err)
return false
}
return true
}
func TaobaoRelationOrderUserByTbPids(eg *xorm.Engine, relationId, pid string, unionId int) *model.TaobaoRelationPid {
var m model.TaobaoRelationPid
get, err := eg.Where("relation_id=? and short_pid=? and union_id=?", relationId, pid, unionId).Get(&m)
if get == false || err != nil {
return nil
}
return &m
}

+ 23
- 0
db/db_user.go Näytä tiedosto

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

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

func UserFindByID(Db *xorm.Engine, id interface{}) (*model.User, error) {
var m model.User
if has, err := Db.Where("uid = ?", id).
Get(&m); err != nil || has == false {
return nil, err
}
return &m, nil
}

func UserProfileFindByID(Db *xorm.Engine, id interface{}) (*model.UserProfile, error) {
var m model.UserProfile
if has, err := Db.Where("uid = ?", id).Get(&m); err != nil || has == false {
return nil, err
}
return &m, nil
}

+ 13
- 0
db/model/taobao_relation_pid.go Näytä tiedosto

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

import "time"

type TaobaoRelationPid struct {
Id int64 `json:"id" xorm:"pk autoincr comment('主键') BIGINT(10)"`
Uid int `json:"uid" xorm:"not null default 0 comment('') INT(11)"`
RelationId string `json:"relation_id" xorm:"not null default '' unique(relation_id) VARCHAR(255)"`
Pid string `json:"pid" xorm:"not null default '' unique(relation_id) VARCHAR(255)"`
ShortPid string `json:"short_pid" xorm:"not null default '' VARCHAR(255)"`
Time time.Time `json:"time" xorm:"not null default 'CURRENT_TIMESTAMP' comment('') TIMESTAMP"`
UnionId int `json:"union_id" xorm:"not null default 0 comment('') INT(11)"`
}

+ 32
- 0
db/model/user.go Näytä tiedosto

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

import (
"time"
)

type User struct {
Uid int `json:"uid" xorm:"not null pk autoincr comment('主键ID') INT(10)"`
Username string `json:"username" xorm:"not null default '' comment('用户名') index VARCHAR(50)"`
Password string `json:"password" xorm:"not null default '' comment('密码') CHAR(32)"`
Passcode string `json:"passcode" xorm:"not null default '' comment('支付密码') CHAR(32)"`
Email string `json:"email" xorm:"not null default '' comment('邮箱') VARCHAR(128)"`
Phone string `json:"phone" xorm:"not null default '' comment('联系电话') index VARCHAR(20)"`
Nickname string `json:"nickname" xorm:"not null default '' comment('昵称') VARCHAR(20)"`
Level int `json:"level" xorm:"not null default 0 comment('用户等级id') INT(11)"`
IsStore int `json:"is_store" xorm:"not null default 0 comment('') INT(11)"`
InviteTotal int `json:"invite_total" xorm:"not null default 0 comment('直推邀请总人数') INT(11)"`
LevelArriveAt time.Time `json:"level_arrive_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('到达该等级的时间') TIMESTAMP"`
LevelExpireAt time.Time `json:"level_expire_at" xorm:"not null default '0000-00-00 00:00:00' comment('该等级过期时间') TIMESTAMP"`
CreateAt time.Time `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('创建时间') TIMESTAMP"`
UpdateAt time.Time `json:"update_at" xorm:"default 'CURRENT_TIMESTAMP' comment('最后修改资料时间') TIMESTAMP"`
LastLoginAt time.Time `json:"last_login_at" xorm:"default 'CURRENT_TIMESTAMP' comment('最近登录时间') TIMESTAMP"`
DeleteAt int `json:"delete_at" xorm:"not null default 0 comment('是否删除;0未删除;1已删除') TINYINT(1)"`
State int `json:"state" xorm:"not null default 1 comment('0未激活,1正常,2冻结') TINYINT(1)"`
LastLoginIp string `json:"last_login_ip" xorm:"not null default '' comment('最后登录IP') VARCHAR(64)"`
RegisterIp string `json:"register_ip" xorm:"not null default '' comment('注册IP') VARCHAR(64)"`
IsFake int `json:"is_fake" xorm:"not null default 0 comment('0真实 1虚拟') TINYINT(1)"`
IsMarketer int `json:"is_marketer" xorm:"not null default 0 comment('是否市商 0否 1是') TINYINT(1)"`
Zone string `json:"zone" xorm:"not null default '86' comment('区号') VARCHAR(100)"`
SalePhone string `json:"sale_phone" xorm:"not null default '' comment('') VARCHAR(100)"`
Platform string `json:"platform" xorm:"not null default '' comment('') VARCHAR(100)"`
}

+ 93
- 0
db/model/user_profile.go Näytä tiedosto

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

import (
"time"
)

type UserProfile struct {
Uid int `json:"uid" xorm:"not null pk comment('关联userID') INT(20)"`
ArkidUid int `json:"arkid_uid" xorm:"not null default 0 comment('Arkid 用户ID') INT(20)"`
ParentUid int `json:"parent_uid" xorm:"not null default 0 comment('上级ID') INT(20)"`
ArkidToken string `json:"arkid_token" xorm:"not null default '' comment('token') VARCHAR(2000)"`
AvatarUrl string `json:"avatar_url" xorm:"not null default '' comment('头像URL') VARCHAR(2000)"`
CustomInviteCode string `json:"custom_invite_code" xorm:"not null default '' comment('邀请码(自定义)') VARCHAR(16)"`
InviteCode string `json:"invite_code" xorm:"not null default '' comment('邀请码(系统)') VARCHAR(16)"`
Gender int `json:"gender" xorm:"not null default 2 comment('性别0女,1男,2未知') TINYINT(1)"`
Birthday int `json:"birthday" xorm:"not null default 0 comment('出生日期') INT(10)"`
AccWxId string `json:"acc_wx_id" xorm:"not null default '' comment('账户_微信id') VARCHAR(50)"`
AccWxOpenid string `json:"acc_wx_openid" xorm:"not null default '' comment('账户_微信openid') VARCHAR(80)"`
AccTaobaoNickname string `json:"acc_taobao_nickname" xorm:"not null default '' comment('淘宝昵称') VARCHAR(50)"`
AccTaobaoAuthTime int64 `json:"acc_taobao_auth_time" xorm:"not null default 0 comment('淘宝授权备案时间') BIGINT(11)"`
AccTaobaoShareId int64 `json:"acc_taobao_share_id" xorm:"not null default 0 comment('淘宝分享relationId,') index BIGINT(12)"`
AccTaobaoSelfId int64 `json:"acc_taobao_self_id" xorm:"not null default 0 comment('淘宝自购specialId') index BIGINT(12)"`
AccJdSelfId string `json:"acc_jd_self_id" xorm:"not null default '' comment('京东自购ID') index VARCHAR(50)"`
AccJdShareId string `json:"acc_jd_share_id" xorm:"not null default '' comment('京东分享ID') index VARCHAR(50)"`
AccJdCloudId string `json:"acc_jd_cloud_id" xorm:"not null default '' comment('京东分享ID') index VARCHAR(50)"`
AccJdFreeId string `json:"acc_jd_free_id" xorm:"not null default '' comment('京东新人免单ID') VARCHAR(50)"`
AccSuningSelfId string `json:"acc_suning_self_id" xorm:"not null default '' comment('苏宁自购ID') index VARCHAR(50)"`
AccSuningShareId string `json:"acc_suning_share_id" xorm:"not null default '' comment('苏宁分享ID') index VARCHAR(50)"`
AccSuningFreeId string `json:"acc_suning_free_id" xorm:"not null default '' comment('苏宁新人免单ID') VARCHAR(50)"`
AccPddSelfId string `json:"acc_pdd_self_id" xorm:"not null default '' comment('拼多多自购ID') index VARCHAR(50)"`
AccPddShareId string `json:"acc_pdd_share_id" xorm:"not null default '' comment('拼多多分享ID') index VARCHAR(50)"`
AccPddFreeId string `json:"acc_pdd_free_id" xorm:"not null default '' comment('拼多多新人免单ID') VARCHAR(50)"`
AccPddBind int `json:"acc_pdd_bind" xorm:"not null default 0 comment('拼多多是否授权绑定') TINYINT(1)"`
AccVipSelfId string `json:"acc_vip_self_id" xorm:"not null default '' comment('唯品会自购ID') index VARCHAR(50)"`
AccVipShareId string `json:"acc_vip_share_id" xorm:"not null default '' comment('唯品会分享ID') index VARCHAR(50)"`
AccVipFreeId string `json:"acc_vip_free_id" xorm:"not null default '' comment('唯品会新人免单ID') VARCHAR(50)"`
AccKaolaSelfId string `json:"acc_kaola_self_id" xorm:"not null default '' comment('考拉自购ID') index VARCHAR(50)"`
AccKaolaShareId string `json:"acc_kaola_share_id" xorm:"not null default '' comment('考拉分享ID') index VARCHAR(50)"`
AccKaolaFreeId string `json:"acc_kaola_free_id" xorm:"not null default '' comment('考拉新人免单ID') VARCHAR(50)"`
AccDuomaiShareId int64 `json:"acc_duomai_share_id" xorm:"not null pk default 0 comment('多麦联盟分享ID') BIGINT(12)"`
AccAlipay string `json:"acc_alipay" xorm:"not null default '' comment('支付宝账号') VARCHAR(50)"`
AccAlipayRealName string `json:"acc_alipay_real_name" xorm:"not null default '' comment('支付宝账号真实姓名') VARCHAR(50)"`
CertTime int `json:"cert_time" xorm:"not null default 0 comment('认证时间') INT(10)"`
CertName string `json:"cert_name" xorm:"not null default '' comment('证件上名字,也是真实姓名') VARCHAR(50)"`
CertNum string `json:"cert_num" xorm:"not null default '' comment('证件号码') VARCHAR(50)"`
CertState int `json:"cert_state" xorm:"not null default 0 comment('认证状态(0为未认证,1为认证中,2为已认证,3为认证失败)') TINYINT(1)"`
FinCommission string `json:"fin_commission" xorm:"not null default 0.0000 comment('累计佣金') DECIMAL(10,4)"`
FinValid string `json:"fin_valid" xorm:"not null default 0.0000 comment('可用余额,fin=>finance财务') DECIMAL(10,4)"`
FinInvalid string `json:"fin_invalid" xorm:"not null default 0.0000 comment('不可用余额,冻结余额') DECIMAL(10,4)"`
FinSelfOrderCount int `json:"fin_self_order_count" xorm:"not null default 0 comment('自购订单数,包括未完成') INT(11)"`
FinSelfOrderCountDone int `json:"fin_self_order_count_done" xorm:"not null default 0 comment('自购已完成订单') INT(11)"`
FinSelfRebate float32 `json:"fin_self_rebate" xorm:"not null default 0.000000 comment('累积自购获得返利金额') FLOAT(14,6)"`
FinTotal float32 `json:"fin_total" xorm:"not null default 0.000000 comment('累计总收益') FLOAT(14,6)"`
Lat float32 `json:"lat" xorm:"not null default 0.000000 comment('纬度') FLOAT(15,6)"`
Lng float32 `json:"lng" xorm:"not null default 0.000000 comment('经度') FLOAT(15,6)"`
Memo string `json:"memo" xorm:"not null default '' comment('用户简述备注') VARCHAR(2048)"`
Qq string `json:"qq" xorm:"not null default '' comment('') VARCHAR(255)"`
IsNew int `json:"is_new" xorm:"not null default 1 comment('是否是新用户') TINYINT(1)"`
IsVerify int `json:"is_verify" xorm:"not null default 0 comment('是否有效会员') TINYINT(1)"`
IsOrdered int `json:"is_ordered" xorm:"not null default 0 comment('是否已完成首单(0否,1是)') TINYINT(1)"`
FromWay string `json:"from_way" xorm:"not null default '' comment('注册来源:
no_captcha_phone:免验证码手机号注册;
manual_phone:手动手机验证码注册;
wx:微信授权;
wx_mp:小程序授权;
wx_pub:公众号授权;
wx_bind_phone:微信注册绑定手机号;
admin:管理员添加;taobao_bind_phone:淘宝注册绑定手机号,apple_bind_phone:苹果注册绑定手机号') VARCHAR(16)"`
HidOrder int `json:"hid_order" xorm:"not null default 0 comment('隐藏订单') TINYINT(3)"`
HidContact int `json:"hid_contact" xorm:"not null default 0 comment('隐藏联系方式') TINYINT(4)"`
NewMsgNotice int `json:"new_msg_notice" xorm:"not null default 1 comment('新消息通知') TINYINT(1)"`
WxAccount string `json:"wx_account" xorm:"not null default '' comment('微信号') VARCHAR(100)"`
WxQrcode string `json:"wx_qrcode" xorm:"not null default '' comment('微信二维码') VARCHAR(100)"`
ThirdPartyTaobaoOid string `json:"third_party_taobao_oid" xorm:"not null default '' comment('淘宝第三方登录openID') VARCHAR(100)"`
ThirdPartyTaobaoSid string `json:"third_party_taobao_sid" xorm:"not null default '' comment('淘宝第三方登录sID') VARCHAR(255)"`
ThirdPartyTaobaoAcctoken string `json:"third_party_taobao_acctoken" xorm:"not null default '' comment('淘宝第三方登录topaccesstoken') VARCHAR(100)"`
ThirdPartyTaobaoAuthcode string `json:"third_party_taobao_authcode" xorm:"not null default '' comment('淘宝第三方登录topAuthCode') VARCHAR(100)"`
ThirdPartyAppleToken string `json:"third_party_apple_token" xorm:"not null default '' comment('苹果第三方登录token') VARCHAR(1024)"`
ThirdPartyQqAccessToken string `json:"third_party_qq_access_token" xorm:"not null default '' comment('QQ第三方登录access_token') VARCHAR(255)"`
ThirdPartyQqExpiresIn string `json:"third_party_qq_expires_in" xorm:"not null default '' comment('QQ第三方登录expires_in(剩余时长)') VARCHAR(255)"`
ThirdPartyQqOpenid string `json:"third_party_qq_openid" xorm:"not null default '' comment('QQ第三方登陆openid(不变,用于认证)') VARCHAR(255)"`
ThirdPartyQqUnionid string `json:"third_party_qq_unionid" xorm:"not null default '' comment('QQ第三方登陆unionid') VARCHAR(255)"`
ThirdPartyWechatExpiresIn string `json:"third_party_wechat_expires_in" xorm:"not null default '' comment('微信第三方登录expires_in(剩余时长)') VARCHAR(255)"`
ThirdPartyWechatOpenid string `json:"third_party_wechat_openid" xorm:"not null default '' comment('微信第三方登陆openid(不变,用于认证)') VARCHAR(255)"`
ThirdPartyWechatUnionid string `json:"third_party_wechat_unionid" xorm:"not null default '' comment('微信第三方登陆unionid') VARCHAR(255)"`
ThirdPartyWechatMiniOpenid string `json:"third_party_wechat_mini_openid" xorm:"not null default '' comment('微信小程序登录open_id') VARCHAR(255)"`
ThirdPartyWechatH5Openid string `json:"third_party_wechat_h5_openid" xorm:"not null default '' comment('微信H5登录open_id') VARCHAR(255)"`
FreeRemainTime int `json:"free_remain_time" xorm:"not null default 0 comment('免单剩余次数') INT(11)"`
FreeCumulativeTime int `json:"free_cumulative_time" xorm:"not null default 0 comment('免单累计次数') INT(11)"`
IsDelete int `json:"is_delete" xorm:"not null default 0 comment('是否已删除') TINYINT(1)"`
UpdateAt time.Time `json:"update_at" xorm:"updated not null default CURRENT_TIMESTAMP comment('更新时间') TIMESTAMP"`
IsSet int `json:"is_set" xorm:"not null default 0 comment('用于一个客户生成关系链匹配的') INT(1)"`
}

+ 53
- 0
haodanku/haodanku.go Näytä tiedosto

@@ -2,8 +2,10 @@ package haodanku

import (
"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/taobao"
zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
"encoding/json"
"fmt"
"github.com/tidwall/gjson"
"strings"
)
@@ -137,3 +139,54 @@ func HaodankuTaobaoRankList(params map[string]string) []map[string]string {
}
return goods
}

// 好单库详情接口
func HaodankuDetail(Id string) (res *taobao.Material, err error) {
params := map[string]string{
"version": "v2.0.0",
"itemid": Id,
}
resp, err := SendReq("http://v2.api.haodanku.com/item_detail", params)
if err != nil {
return nil, err
}
var featuredList struct {
Data md.HDKDetailStruct `json:"data"`
}
zhios_third_party_utils.Unserialize(resp, &featuredList)
var imgs = strings.Split(featuredList.Data.TaobaoImage, ",")
var Shoptype int
if featuredList.Data.Shoptype == "B" {
Shoptype = 1
} else {
Shoptype = 0
}
if strings.Contains(featuredList.Data.Itempic, "http") == false {
featuredList.Data.Itempic = fmt.Sprintf("https:%s", featuredList.Data.Itempic)
}
var data = taobao.Material{
CommissionRate: zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.StrToFloat64(featuredList.Data.Tkrates) * 100),
ItemDescription: featuredList.Data.Itemdesc,
ItemID: featuredList.Data.Itemid,
Nick: featuredList.Data.Shopname,
PictURL: featuredList.Data.Itempic,
SellerID: featuredList.Data.UserId,
ShopTitle: featuredList.Data.Sellernick,
Title: featuredList.Data.Itemtitle,
TkTotalSales: featuredList.Data.Itemsale,
Volume: zhios_third_party_utils.StrToInt(featuredList.Data.Itemsale),
ZkFinalPrice: zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.StrToFloat64(featuredList.Data.Itemendprice) + utils.StrToFloat64(featuredList.Data.Couponmoney)),
ReservePrice: featuredList.Data.Itemprice,
CouponAmount: featuredList.Data.Couponmoney,
CouponEndTime: featuredList.Data.Couponendtime,
CouponStartTime: featuredList.Data.Couponstarttime,
ActivityId: featuredList.Data.Activityid,
UserType: Shoptype,
}
data.SmallImages = struct {
String []string `json:"string"`
}(struct{ String []string }{String: imgs})
res = &data

return res, nil
}

+ 29
- 0
md/haodanku.go Näytä tiedosto

@@ -138,3 +138,32 @@ type HDKGoodsTaobaoRankList struct {
PresaleTailEndTime int `json:"presale_tail_end_time"`
PresaleDiscountFeeText string `json:"presale_discount_fee_text"`
}

type HDKDetailStruct struct {
ID string `json:"id"`
Itemid string `json:"itemid"`
Itemtitle string `json:"itemtitle"`
Itemshorttitle string `json:"itemshorttitle"`
Itemdesc string `json:"itemdesc"`
Itemprice string `json:"itemprice"`
Itemendprice string `json:"itemendprice"`
Itemsale string `json:"itemsale"`
Todaysale string `json:"todaysale"`
Tkrates string `json:"tkrates"`
Tkmoney string `json:"tkmoney"`
Itempic string `json:"itempic"`
Shoptype string `json:"shoptype"`
Sellernick string `json:"sellernick"`
Shopname string `json:"shopname"`
Couponstarttime string `json:"couponstarttime"`
Couponendtime string `json:"couponendtime"`
Couponmoney string `json:"couponmoney"`
Couponexplain string `json:"couponexplain"`
Activityid string `json:"activityid"`
Couponurl string `json:"couponurl"`
TaobaoImage string `json:"taobao_image"`
ReturnRatio string `json:"return_ratio"`
RedpacketPrice string `json:"redpacket_price"`
EstimatePrice string `json:"estimate_price"`
UserId int `json:"userid"`
}

+ 233
- 0
md/product_detail.go Näytä tiedosto

@@ -0,0 +1,233 @@
package md

// DetailRequest is get the uri args to struct
type DetailRequest struct {
Provider string `uri:"provider" binding:"required"`
Gid string `uri:"gid" binding:"required"`
}

// DetailResponse is Detail response
type DetailResponse struct {
Provider string `json:"provider"`
Title string `json:"title"`
TitleColor string `json:"title_color"`
DownloadAPPIcon string `json:"download_app_icon"`
DownloadAPPBackgroundColor string `json:"download_app_background_color"`
DownloadAPPMain string `json:"download_app_main"`
DownloadAPPMainColor string `json:"download_app_main_color"`
DownloadAPPJump string `json:"download_app_jump"`
DownloadAPPJumpColor string `json:"download_app_jump_color"`
DownloadAPPJumpURL string `json:"download_app_jump_url"`
CurrentPrice string `json:"current_price"`
CurrentPriceColor string `json:"current_price_color"`
AfterCouponPrice string `json:"after_coupon_price"`
AfterCouponPriceColor string `json:"after_coupon_price_color"`
Point string `json:"point"`
PointColor string `json:"point_color"`
PointBackgroundColor string `json:"point_background_color"`
SoldCount string `json:"sold_count"`
SoldCountColor string `json:"sold_count_color"`
ProviderName string `json:"provider_name"`
ProviderNameColor string `json:"provider_name_color"`
ProviderNameBackgroundColor string `json:"provider_name_background_color"`
ProductName string `json:"product_name"`
ProductNameColor string `json:"product_name_color"`
ProductDiscountDescription string `json:"product_discount_description"`
ProductDiscountDescriptionColor string `json:"product_discount_description_color"`
ProductDiscountDescriptionBackgroundColor string `json:"product_discount_description_background_color"`
CommissionDescription string `json:"commission_description"`
CommissionDescriptionColor string `json:"commission_description_color"`
CommissionDescriptionBackgroundColor string `json:"commission_description_background_color"`
CouponAmount string `json:"coupon_amount"`
CouponTypeText string `json:"coupon_type_text"`
CouponURL string `json:"coupon_url"`
CouponEndTime string `json:"coupon_endtime"`
CouponColor string `json:"coupon_color"`
CouponBackground string `json:"coupon_background"`
ShopName string `json:"shop_name"`
ShopIcon string `json:"shop_icon"`
ImageList []string `json:"image_list"`
ImageDetailList []string `json:"image_detail_list"`
ButtonIndexIcon string `json:"button_index_icon"`
ButtonIndexColor string `json:"button_index_color"`
ButtonFavoriteIcon string `json:"button_favorite_icon"`
ButtonFavoriteColor string `json:"button_favorite_color"`
ButtonShare string `json:"button_share"`
ButtonShareColor string `json:"button_share_color"`
ButtonShareBackgroundColor string `json:"button_share_background_color"`
ButtonShareBackgroundColor2 string `json:"button_share_background_color2"`
ButtonSelfBuy string `json:"button_self_buy"`
ButtonSelfBuyColor string `json:"button_self_buy_color"`
ButtonSelfBuyBackgroundColor string `json:"button_self_buy_background_color"`
ButtonSelfBuyBackgroundColor2 string `json:"button_self_buy_background_color2"`
MoreDetail MoreDetailResponse `json:"more_detail"`
}

// MoreDetailResponse is for response detail
type MoreDetailResponse struct {
GID string `json:"gid"`
GoodsImg string `json:"goods_img"`
GoodsTitle string `json:"goods_title"`
GoodsCostPrice string `json:"goods_cost_price"` //原价
GoodsDesc string `json:"goods_desc"`
GoodsPrice string `json:"goods_price"`
GoodsMinImg string `json:"goods_min_img"`
GoodsImgList []string `json:"goods_img_list"`
GoodsSales string `json:"goods_sales"`
GoodURL string `json:"good_url"`
GoodMobileURL string `json:"good_mobile_url"`
CID string `json:"cid"`
CID1 string `json:"cid1"`
CID1Name string `json:"cid1_name"`
CID2 string `json:"cid2"`
CID2Name string `json:"cid2_name"`
CID3 string `json:"cid3"`
CID3Name string `json:"cid3_name"`
Commission string `json:"commission"`
CommissionRate string `json:"commission_rate"`
PublicCommissionRate string `json:"public_commission_rate"`
CouponURL string `json:"coupon_url"`
CouponRemain string `json:"conpon_remain"`
CouponTotal string `json:"coupon_total"`
CouponPrice string `json:"coupon_price"`
CouponStartTime string `json:"coupon_start_time"`
CouponEndTime string `json:"coupon_end_time"`
Discount string `json:"discount"`
DescPct string `json:"desc_pct"`
EvalCount string `json:"eval_count"`
StartTime string `json:"start_time"`
EndTime string `json:"end_time"`
ImageList []string `json:"img_list"`
DetailImgList []string `json:"detail_img_list"`
InOrderCount string `json:"inOrderCount"`
IsFreeFreightRisk string `json:"isFreeFreightRisk"`
IsSelfSale string `json:"isSelfSale"`
LowerPrice string `json:"lower_price"`
LowerPriceType string `json:"lower_price_type"`
LowestCouponPrice string `json:"lowestCouponPrice"`
LgstPct string `json:"lgst_pct"`
MallID string `json:"mall_id"`
MinGroupPrice string `json:"min_group_price"`
MinNormalPrice string `json:"min_normal_price"`
PCGoodsPrice string `json:"pc_goods_price"`
ShopID string `json:"shopId"`
ShopName string `json:"shop_name"`
StoreID string `json:"store_id"`
SourceType string `json:"sourceType"`
Score string `json:"score"`
ServPct string `json:"serv_pct"`
WlGoodsPrice string `json:"wl_goods_price"` //卷后价
AvgDesc string `json:"avg_desc"`
AvgLgst string `json:"avg_lgst"`
AvgServ string `json:"avg_serv"`
CateName string `json:"cate_name"`
ItemURL string `json:"item_url"`
GoodsSign string `json:"goods_sign"`
ShopLogo string `json:"shop_logo"`
UserType int `json:"user_type"`
Video []interface{} `json:"video"`
ShopTotalScore struct {
LogisticsScore struct {
Level string `json:"level"`
Score string `json:"score"`
Text string `json:"text"`
} `json:"logistics_score"`
ProductScore struct {
Level string `json:"level"`
Score string `json:"score"`
Text string `json:"text"`
} `json:"product_score"`
ServiceScore struct {
Level string `json:"level"`
Score string `json:"score"`
Text string `json:"text"`
} `json:"service_score"`
ShopScore struct {
Level string `json:"level"`
Score string `json:"score"`
Text string `json:"text"`
} `json:"shop_score"`
} `json:"shop_total_score"`
NextCommissionList struct {
SelfCommission float64 `json:"self_commission"`
SelfBuy float64 `json:"self_buy"`
ShareCommission float64 `json:"share_commission"`
} `json:"next_commission_list"`
}
type PlatformCss struct {
Name string `json:"name"`
Type string `json:"type"`
Icon string `json:"icon"`
}

// ProductDetailResponse productdetail
type ProductDetailResponse struct {
IsCanBuy string `json:"is_can_buy"` //是否能购买
IsShowCouponList string `json:"is_show_coupon_list"` //是否展示优惠券弹出
UserCouponAmount string `json:"user_coupon_amount"` //优惠券额度
GoodID string `json:"good_id"`
Provider string `json:"provider"`
OldProvider string `json:"old_provider"`
ProviderName string `json:"provider_name"`
Commission string `json:"commission"`
OldCommission string `json:"old_commission"`
ShareCommission string `json:"share_commission"`
SelfBuy string `json:"self_buy"` //自购省
CouponPrice string `json:"coupon_price"` //优惠卷价
ShopAvatar string `json:"shop_avatar"`
NewGoodsContent string `json:"new_goods_content"` //站内商品的文案
NewGoodsImgList string `json:"new_goods_img_list"` //站内商品的图片组
GoodsTitle string `json:"goods_title"` //商品标题
CommissionRate string `json:"commission_rate"`
WlGoodsPrice string `json:"wl_goods_price"` //卷后价
ModList []map[string]interface{} `json:"mod_list"`
ModGoodsDetailBgColor string `json:"mod_goods_detail_bg_color"`
SkuParam map[string]string `json:"sku_param"`
CopyUrlParam map[string]string `json:"copy_url_param"`
BackReq string `json:"back_req"`
SaveNow string `json:"save_now"`
}

// PddPopCss PddPopCss
type PddPopCss struct {
IsPop string `json:"is_pop"`
H5Url string `json:"no_open_app_url"`
MiniAPPID string `json:"mini_appid"`
MiniUrl string `json:"mini_url"`
OpenAppUrl string `json:"open_app_url"`
SchemaUrl string `json:"schema_url"`
Ico string `json:"ico"`
BtnIco string `json:"btn_ico"`
Title string `json:"title"`
Info string `json:"info"`
BtnStr string `json:"btn_str"`
}

//
type ProductDetailVoucher struct {
BgColor string `json:"bg_color"`
CateTag string `json:"cate_tag"`
Color string `json:"color"`
Data struct {
BrandID string `json:"brand_id"`
} `json:"data"`
FinalPrice string `json:"final_price"`
Info string `json:"info"`
IsJump string `json:"is_jump"`
Name string `json:"name"`
OfficialPrice string `json:"official_price"`
RequiredLogin string `json:"required_login"`
RequiredTaobaoAuth string `json:"required_taobao_auth"`
SaleStr string `json:"sale_str"`
SkipIdentifier string `json:"skip_identifier"`
SkipName string `json:"skip_name"`
SubBgColor string `json:"sub_bg_color"`
Tag string `json:"tag"`
Title string `json:"title"`
}

type GoodsProfit struct {
Commission float64 `json:"commission"`
Integral float64 `json:"integral"`
BlockIcons float64 `json:"block_icons"`
}

+ 5
- 0
md/provider.go Näytä tiedosto

@@ -32,9 +32,14 @@ const (
PVD_DIDI_ONLINE_CAR = "didi_online_car" //滴滴
PVD_DIDI_FREIGHT = "didi_freight" //滴滴
PVD_DIDI_CHAUFFEUR = "didi_chauffeur" //滴滴
KEY_CFG_ZM_AK = "third_zm_app_key"
KEY_CFG_ZM_SK = "third_zm_app_secret"
KEY_CFG_ZM_WEB_ID = "third_zm_web_id" // 智盟网站ID

)

var ZHIMENG_CFG_LIST = []string{KEY_CFG_ZM_AK, KEY_CFG_ZM_SK, KEY_CFG_ZM_WEB_ID}

var PVD_LIST = map[string]string{
PVD_TB: "淘宝",
PVD_JD: "京东",


+ 11
- 0
md/publisher_info.go Näytä tiedosto

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

// 会员备案信息

type PublisherInfo struct {
RelationId string // 渠道id
SpecialId string // 会员运营id
ExternalId string // 自定义参数
Rtag string // 备注

}

+ 7
- 0
md/taobao.go Näytä tiedosto

@@ -69,3 +69,10 @@ type TBSearchFeatureStruct struct {
WhiteImage string `json:"white_image"`
ZkFinalPrice string `json:"zk_final_price"`
}
type TaobaoWord struct {
Text string // 文本
Code string // 短码
}
type TaobaoWordGid struct {
Gid string // 商品id
}

+ 34
- 0
md/url.go Näytä tiedosto

@@ -0,0 +1,34 @@
package md

type ExtraData struct {
UnionId string `json:"unionId"`
Tc1 string `json:"tc1"`
Tc2 string `json:"tc2"`
}

// 转链后链接
type ConvertedUrls struct {
ItemId string `json:"item_id"`
NumGoodsId string `json:"num_goods_id"`
URL string `json:"url"` // 短链接
ShortenURL string `json:"open_app_url"` // 会打开app的长链接
NoOpenAppURL string `json:"no_open_app_url"` // 不会打开app的长链接
AppURL string `json:"app_url"` // app 链接 pinduoduo://
HasCoupon bool `json:"has_coupon"` // 是否有优惠券
CommissionRate string `json:"commission_rate"` // 利润比例
ShareURL string `json:"share_url"` // 分享的URL
WeChatTaobaoURL string `json:"wechat_taobao_url"` // 淘宝分享到微信用的url
WeChatMiniURL string `json:"wechat_mini_url"` // 微信小程序转链地址
WeChatMiniAPPID string `json:"wechat_mini_appid"` // 微信appid
PID string `json:"pid"` // 推广位
PvdId string `json:"pvd_id"` // 供应商联盟ID
TaoBaoWord string `json:"taobao_word"` // 淘口令TaoBaoWord string `json:"taobao_word"` // 淘口令
ExtraData ExtraData `json:"extraData"` //考拉用来跟踪用户的
TbShareId int64 `json:"tb_share_id"` //淘宝活动时的渠道id 组合方式
IsHasCouponAmount int `json:"is_has_coupon_amount"` //是否有优惠券额度
ClickUrl string `json:"click_url"`
QrcodeUrl string `json:"qrcode_url"`
Content string `json:"content"`
PvdName string `json:"pvd_name"`
NewPid string `json:"new_pid"`
}

+ 123
- 0
taobao/taobao.go Näytä tiedosto

@@ -3,6 +3,11 @@ package taobao
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"
"encoding/json"
"errors"
"fmt"
"github.com/syyongx/php2go"
"strings"
"xorm.io/xorm"
)

@@ -96,3 +101,121 @@ func (t *TB) TaoBaoSearchList(args map[string]string) (*[]Material, error) {
}
return list, nil
}

// 商品详情
func (t *TB) ItemDetailById(id, bizSceneId string) (*Material, error) {
if php2go.IsNumeric(id) {
return t.ItemDetailByLink("https://item.taobao.com/item.htm?id="+id, "2")
}
return t.ItemDetailByLink("https://uland.taobao.com/item/edetail?id="+id, "")
}

func (t *TB) ItemDetailByLink(l, bizSceneId string) (*Material, error) {
args := map[string]string{
"q": l,
"adzone_id": AdZoneId(t.SelfPromoIdWeb), // 默认使用安卓, 转链时候才要针对不同的渠道
"session": t.SID,
"page_size": "1",
"page_no": "1",
}
if bizSceneId == "2" {
args["biz_scene_id"] = "2"
}
method := TBK_DG_MTL_OPT
//判断是否跟随官方 需要换接口
if t.AuthType == 1 {
method = TBK_SC_MTL_OPT
Sid := t.UserSID
args["session"] = Sid
_, args["site_id"], args["adzone_id"] = SplitPid(t.SelfPromoIdWeb)
}
resp, err := send(args, method, t.Web_AK, t.Web_SK)
if err != nil {
return nil, err
}
fmt.Println("淘宝", args)
fmt.Println("淘宝", string(resp))
// todo 可能还需返回的说明, 里面包含详细介绍的图片
// "https://mdetail.tmall.com/templates/pages/desc?id=" + id
// "https://h5.m.taobao.com/app/detail/desc.html?type=1&f=&sellerType=B&_isH5Des=true#!id=" + id
// 如果是跟随官方 结构不一样

if t.AuthType == 1 {
var tmp scMaterialOptionalStruct
if err = json.Unmarshal(resp, &tmp); err != nil {
return nil, err
}
if len(tmp.TbkScMaterialOptionalResponse.ResultList.MapData) == 0 {
return nil, errors.New("没有数据")
}
data := tmp.TbkScMaterialOptionalResponse.ResultList.MapData[0]
itemID, ok := data.ItemID.(float64)
if ok {
data.ItemID = int64(itemID)
}
return &data, nil
} else {
var tmp wrapperStruct
if err = json.Unmarshal(resp, &tmp); err != nil {
return nil, err

}
if len(tmp.TbkDgMaterialOptionalResponse.ResultList.MapData) == 0 {
return nil, err
}
data := tmp.TbkDgMaterialOptionalResponse.ResultList.MapData[0]
itemID, ok := data.ItemID.(float64)
if ok {
data.ItemID = int64(itemID)
}
return &data, nil
}
}

func (t *TB) ItemDetailByIdKey(l, bizSceneId string) (*Material, error) {
l += "&"
l = strings.ReplaceAll(l, "?", "&")
ex := php2go.Explode("&id=", l)
id := ""
if len(ex) > 1 {
ex1 := php2go.Explode("&", ex[1])
if len(ex1) > 0 {
id = ex1[0]
}
}
if id == "" || id == "622130940777" {
return nil, errors.New("找不到商品")
}
args := map[string]string{
"num_iids": id,
"session": t.SID,
"platform": "2",
}
if bizSceneId == "2" {
//args["biz_scene_id"] = "2"
}
method := "taobao.tbk.item.info.get"
//判断是否跟随官方 需要换接口
if t.AuthType == 1 {
Sid := t.UserSID
args["session"] = Sid
}
resp, err := send(args, method, t.Web_AK, t.Web_SK)
if err != nil {
return nil, err
}
var tmp tbDetailStruct
if err = json.Unmarshal(resp, &tmp); err != nil {
return nil, err
}
if len(tmp.TbkItemInfoGetResponse.Results.NBbkItem) == 0 {
return nil, err
}
data := tmp.TbkItemInfoGetResponse.Results.NBbkItem[0]
data.ItemID = data.InputNumIid
itemID, ok := data.ItemID.(float64)
if ok {
data.ItemID = int64(itemID)
}
return &data, nil
}

+ 60
- 0
taobao/taobao_relation_pid.go Näytä tiedosto

@@ -0,0 +1,60 @@
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"
zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
"encoding/json"
"time"
"xorm.io/xorm"
)

func TaobaoRelationPid(eg *xorm.Engine, args map[string]string) (bool, string, string) {
mid := args["mid"]
uid := zhios_third_party_utils.StrToInt(args["uid"])
//查询方案 有多少个推广位
taobaoCfg, err := db.SysUnionByTaobaoByUseByAuth(eg, mid)
if err != nil || taobaoCfg == nil {
return false, "", ""
}
if taobaoCfg.AppletPid == "" {
return false, "", ""
}
relationList := db.IsExistRelationPid(eg, uid, taobaoCfg.Id)
if relationList != nil {
return true, relationList.RelationId, relationList.Pid
}
var r = make([]string, 0)
err = json.Unmarshal([]byte(taobaoCfg.AppletPid), &r)
if err != nil {
return false, "", ""
}
//查下还有没有渠道id绑定
relationId, lid := db.GetRelation(eg, taobaoCfg.Id, len(r))
if relationId == "" {
return false, "", ""
}
//查下哪个推广位没绑定的
pidList := db.GetRelationPid(eg, taobaoCfg.Id, r, relationId)
var pidMap = make([]string, 0)
for _, v := range *pidList {
pidMap = append(pidMap, v.Pid)
}
pid := ""
for _, v := range r {
if zhios_third_party_utils.InArr(v, pidMap) == false && pid == "" {
pid = v
}
}
if pid == "" {
return false, "", ""
}
var tmp = &model.TaobaoRelationPid{RelationId: relationId, Uid: uid, UnionId: taobaoCfg.Id, Pid: pid, ShortPid: AdZoneId(pid), Time: time.Now()}
_, err = eg.Insert(tmp)
if err != nil {
return false, "", ""
}
sql := `UPDATE taobao_relation set count=count+1 where id=? `
db.QueryNativeString(eg, sql, lid)
return true, relationId, pid
}

+ 35
- 0
taobao/word_create.go Näytä tiedosto

@@ -0,0 +1,35 @@
package taobao

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md"
"encoding/json"
)

// TODO 淘口令解析, 因为目前没有可用账号, 暂时搁置, 请查看智盟的接口
func (t *TB) WordCreate(url, text string) (*md.TaobaoWord, error) {
method := "taobao.tbk.tpwd.create"
args := map[string]string{
"text": text, // 长度大于5个字符
"url": url, // 口令跳转目标页, 如:https://uland.taobao.com/, 后面需要添加对应的relationId或者specialId
}
resp, err := send(args, method, t.Web_AK, t.Web_SK)
if err != nil {
return nil, err
}
var tmp struct {
TbkTpwdCreateResponse struct {
Data struct {
Model string `json:"model"`
PasswordSimple string `json:"password_simple"`
} `json:"data"`
} `json:"tbk_tpwd_create_response"`
}

if err = json.Unmarshal(resp, &tmp); err != nil {
return nil, err
}
return &md.TaobaoWord{
Text: tmp.TbkTpwdCreateResponse.Data.Model,
Code: tmp.TbkTpwdCreateResponse.Data.PasswordSimple,
}, nil
}

+ 28
- 0
tik_tok/svc_tik_tok_convert.go Näytä tiedosto

@@ -1,7 +1,9 @@
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"
"errors"
"fmt"
"github.com/syyongx/php2go"
"github.com/tidwall/gjson"
@@ -150,3 +152,29 @@ func RegimentalConvertUrl(args map[string]string) (map[string]string, string) {

return data, ""
}
func OwnTikTokUrl(tikTokBase *md.TikTokBase, tikTokArgs map[string]interface{}) (*md.ConvertedUrls, error) {
args := map[string]string{
"appkey": tikTokBase.ApiGoodsAppKey,
"appSecret": tikTokBase.ApiGoodsAppSecret,
"product_url": zhios_third_party_utils.AnyToString(tikTokArgs["product_url"]),
"external_info": zhios_third_party_utils.AnyToString(tikTokArgs["external_info"]),
"need_qr_code": zhios_third_party_utils.AnyToString(tikTokArgs["need_qr_code"]),
"pid": tikTokBase.GoodsPid,
"acctoken": tikTokBase.GoodsAccessToken,
}
fmt.Println("抖音", args)
url, err := GoodsConvertUrl(args)
if err != "" {
return nil, errors.New(err)
}
content, _ := php2go.Base64Decode(url["content"])
return &md.ConvertedUrls{
URL: url["deeplink"],
ShortenURL: url["deeplink"],
NoOpenAppURL: url["deeplink"],
AppURL: url["deeplink"],
ClickUrl: url["deeplink"],
QrcodeUrl: url["qr_code"],
Content: content,
}, nil
}

+ 7
- 0
zhimeng/jd.go Näytä tiedosto

@@ -36,3 +36,10 @@ func JdGoods(param map[string]interface{}) []map[string]string {
}
return goods
}

// NewZhiMengJingDongSDK is constructor
func NewZhiMengJingDongSDK() *SDK {
jd := &SDK{}
jd.Init(md.PVD_JD)
return jd
}

+ 47
- 0
zhimeng/jd_convert_url.go Näytä tiedosto

@@ -0,0 +1,47 @@
package zhimeng

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md"
"encoding/json"
"fmt"
)

// promoId一般使用自购ID拼装起来
func JDConvertUrl(appkey, appsecret, itemId, promoId, couponUrl, couponPrice, activityUrl string) (*md.ConvertedUrls, error) {
args := map[string]interface{}{
"appkey": appkey,
"secret_key": appsecret,
"gid": itemId,
"pid": promoId,
"coupon_url": couponUrl,
"activity_url": activityUrl,
}
fmt.Println("==========", args)
resp, err := Send("jd", "get_buy_url", args)
if err != nil {
return nil, err
}
var tmp struct {
Data struct {
URL string `json:"url"`
ClickUrl string `json:"click_url"`
} `json:"data"`
}
if err = json.Unmarshal(resp, &tmp); err != nil {
return nil, err
}
hasCoupon := false
if couponUrl != "" {
hasCoupon = true
}
return &md.ConvertedUrls{
ItemId: itemId,
URL: tmp.Data.URL,
ShortenURL: tmp.Data.URL,
NoOpenAppURL: tmp.Data.URL,
AppURL: tmp.Data.URL,
HasCoupon: hasCoupon,
CommissionRate: couponPrice,
ClickUrl: tmp.Data.ClickUrl,
}, nil
}

+ 40
- 0
zhimeng/kuaishou_goods_url.go Näytä tiedosto

@@ -0,0 +1,40 @@
package zhimeng

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md"
"encoding/json"
"github.com/syyongx/php2go"
)

func KuaiShouUrl(tikTokArgs map[string]interface{}) (*md.ConvertedUrls, error) {
args := map[string]interface{}{
"appkey": tikTokArgs["appkey"],
"secret_key": tikTokArgs["secret_key"],
"linkCarrierId": tikTokArgs["gid"],
"comments": tikTokArgs["external_info"],
"linkType": tikTokArgs["linkType"],
"genPoster": tikTokArgs["genPoster"],
}
resp, err := Send("kuaishou", "getUrls", args)
if err != nil {
return nil, err
}
var tmp struct {
Data TikTokUrlData `json:"data"`
}
if err = json.Unmarshal(resp, &tmp); err != nil {
return nil, err
}
content, _ := php2go.Base64Decode(tmp.Data.Content)
return &md.ConvertedUrls{
URL: tmp.Data.Deeplink,
ShortenURL: tmp.Data.Deeplink,
NoOpenAppURL: tmp.Data.Link,
AppURL: tmp.Data.Deeplink,
ClickUrl: tmp.Data.Deeplink,
QrcodeUrl: tmp.Data.QrCode,
Content: content,
WeChatMiniURL: tmp.Data.PageUrl,
WeChatMiniAPPID: tmp.Data.AppId,
}, nil
}

+ 50
- 0
zhimeng/pdd_convert_url.go Näytä tiedosto

@@ -0,0 +1,50 @@
package zhimeng

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md"
"encoding/json"
"fmt"
)

func PDDConvertUrl(ak, sk, itemId, promoId, couponPrice, isWxMini, isBindUrl, isShare string) (*md.ConvertedUrls, error) {
args := map[string]interface{}{
"appkey": ak,
"secret_key": sk,
"gid": itemId,
"goods_sign": itemId,
"pid": promoId,
"open_app": "", // 具体规则请看智盟
"link_type": "", // todo 这几项按理来说做成配置项
"generate_we_app": isWxMini, // 生成微信小程序链接
"generate_authority_url_onoff": isBindUrl,
"custom_parameters": promoId,
"is_share": isShare,
}
//generate_authority_url_onoff 0不会调授权链接 1会先跳授权链接
fmt.Println("拼多多:", args)
resp, err := Send("pdd", "get_buy_url", args)
if err != nil {
return nil, err
}
var tmp struct {
Data struct {
URL string `json:"url"`
OpenAppURL string `json:"open_app_url"`
NoOpenAppURL string `json:"no_open_app_url"`
SchemaURL string `json:"schema_url"`
PagePath string `json:"page_path"`
} `json:"data"`
}
if err = json.Unmarshal(resp, &tmp); err != nil {
return nil, err
}
return &md.ConvertedUrls{
ItemId: itemId,
URL: tmp.Data.URL,
ShortenURL: tmp.Data.NoOpenAppURL,
NoOpenAppURL: tmp.Data.OpenAppURL,
AppURL: tmp.Data.SchemaURL,
HasCoupon: false,
CommissionRate: couponPrice,
}, nil
}

+ 8
- 0
zhimeng/pdd_zhimeng.go Näytä tiedosto

@@ -0,0 +1,8 @@
package zhimeng

// NewZhiMengJingDongSDK is constructor
func NewZhiMengPDDSDK() *SDK {
pdd := &SDK{}
pdd.Init("pdd")
return pdd
}

+ 285
- 0
zhimeng/sdk.go Näytä tiedosto

@@ -0,0 +1,285 @@
package zhimeng

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md"
"encoding/json"
"errors"
"fmt"
"github.com/shopspring/decimal"
"github.com/tidwall/gjson"
"strings"
)

// SDK is zhimeng sdk
type SDK struct {
Action string
operation string
response []byte
SmsKey string
SmsSecret string
data interface{}
err error
}

// Init is init action
// In some condition, such as send Sms, need pass sms key and secret after 'action'
func (sdk *SDK) Init(action string, keys ...string) {
sdk.Action = action
//if keys[0] == "" || keys[1] == "" {
// sdk.err = errors.New("智盟短信未配置")
//}
if len(keys) > 1 {
sdk.SmsKey = keys[0]
sdk.SmsSecret = keys[1]
}

}

// SelectFunction is select api with operation
func (sdk *SDK) SelectFunction(operation string) *SDK {
sdk.operation = operation
return sdk
}

// WithSMSArgs is SMS
func (sdk *SDK) WithSMSArgs(args map[string]interface{}) *SDK {
res, err := SMSend(sdk.Action, sdk.operation, sdk.SmsKey, sdk.SmsSecret, args)
if err != nil {

}
sdk.response = res
return sdk
}

// WithArgs is post data to api
func (sdk *SDK) WithArgs(args map[string]interface{}) *SDK {
// args["appkey"] = svc.SysCfgGet(c, md.KEY_CFG_ZM_AK)
// args["secret_key"] = svc.SysCfgGet(c, md.KEY_CFG_ZM_SK)

res, err := Send(sdk.Action, sdk.operation, args)
if err != nil {
}
// for k, v := range args {
// fmt.Printf("%s:%v \n", k, v)
// }
fmt.Println("唯品会请求", args, string(res))
sdk.response = res
return sdk
}

// Result is response data from api , return interface{}
func (sdk *SDK) Result() (*SDK, error) {
if sdk.err != nil {
return nil, sdk.err
}
tmp := struct {
Msg string `json:"msg"`
Success int `json:"success"`
Data interface{} `json:"data"`
}{}
if err := json.Unmarshal(sdk.response, &tmp); err != nil {
return nil, err
}
if tmp.Success != StatusSuc {
return nil, errors.New("没有商品")
}

if gjson.GetBytes(sdk.response, "data").String() == "[]" {
return nil, errors.New("no result")
}

sdk.data = tmp.Data
return sdk, nil
}

// WithJDDetailImageList is insert jd detail image list when api response
func (sdk *SDK) WithJDDetailImageList(gid string) {
if len(sdk.response) == 0 || sdk.response == nil {
return
}
fmt.Println(gjson.GetBytes(sdk.response, "data").String())
if gjson.GetBytes(sdk.response, "data").String() == "[]" {
return
}
fmt.Println("debug", sdk.response)
data, ok := sdk.data.(map[string]interface{})
if !ok {
}
// debug
sdk.data = data
}

// ToObject is the interface is Slice and get the first item
func (sdk *SDK) ToObject() *SDK {
s, ok := sdk.ToInterface().([]interface{})
if !ok {
return sdk
}
sdk.data = s[len(s)-len(s)]
return sdk
}

// ToInterface is data to Interface
func (sdk *SDK) ToInterface() interface{} {
return sdk.data
}

// ToMapStringInterface is data to map[string]string
func (sdk *SDK) ToMapStringInterface(item interface{}) map[string]interface{} {
data, err := json.Marshal(item)
if err != nil {

}
m := make(map[string]interface{})
if err = json.Unmarshal(data, &m); err != nil {

}
for key, v := range m {
switch v.(type) {
case int:
t, ok := v.(string)
if !ok {
}
m[key] = t
case int32:
t, ok := v.(string)
if !ok {
}
m[key] = t
case int64:
t, ok := v.(string)
if !ok {
}
m[key] = t
case float64:
vstr := fmt.Sprintf("%v", v)
if strings.Contains(vstr, "e+") {
decimalNum, err := decimal.NewFromString(vstr)
if err != nil {

}
vstr = decimalNum.String()
}
m[key] = vstr
case nil:
m[key] = v
default:
m[key] = v
}
}
return m
}

// ToStruct is struct return
func (sdk *SDK) ToStruct(r *md.MoreDetailResponse) error {
// debug
data, err := json.Marshal(sdk.ToMapStringInterface(sdk.data))
if err != nil {
}
if err = json.Unmarshal(data, r); err != nil {
return err
}
return nil
}

// PddToMapStringInterface is data to map[string]string
func (sdk *SDK) PddToMapStringInterface(item interface{}) []map[string]interface{} {
data, err := json.Marshal(item)
if err != nil {
}
m1 := make([]map[string]interface{}, 10, 10)
if err = json.Unmarshal(data, &m1); err != nil {

}
for _, m := range m1 {
for key, v := range m {
switch v.(type) {
case int:
t, ok := v.(string)
if !ok {
}
m[key] = t
case int32:
t, ok := v.(string)
if !ok {
}
m[key] = t
case int64:
t, ok := v.(string)
if !ok {
}
m[key] = t
case float64:
vstr := fmt.Sprintf("%v", v)
if strings.Contains(vstr, "e+") {
decimalNum, err := decimal.NewFromString(vstr)
if err != nil {
}
vstr = decimalNum.String()
}
m[key] = vstr
case nil:
m[key] = v
default:
m[key] = v
}
}
}
return m1
}

// PddToStruct is struct return for Pdd data is list by one
func (sdk *SDK) PddToStruct(r *md.MoreDetailResponse) error {
// debug
data, err := json.Marshal(sdk.PddToMapStringInterface(sdk.data)[0])
if err != nil {
}
if err = json.Unmarshal(data, r); err != nil {
return err
}
return nil
}

// VipToMapStringInterface is data to map[string]string
func (sdk *SDK) VipToMapStringInterface() map[string]interface{} {
data, err := json.Marshal(sdk.data)
if err != nil {

}
m := make(map[string]interface{})
if err = json.Unmarshal(data, &m); err != nil {
}
for key, v := range m {
switch v.(type) {
case int:
t, ok := v.(string)
if !ok {
}
m[key] = t
case int32:
t, ok := v.(string)
if !ok {
}
m[key] = t
case int64:
t, ok := v.(string)
if !ok {
}
m[key] = t
case float64:
vstr := fmt.Sprintf("%v", v)
if strings.Contains(vstr, "e+") {
decimalNum, err := decimal.NewFromString(vstr)
if err != nil {
}
vstr = decimalNum.String()
}
m[key] = vstr
case nil:
m[key] = v
default:
m[key] = v
}
}
return m
}

+ 53
- 0
zhimeng/taobao_convert_url.go Näytä tiedosto

@@ -0,0 +1,53 @@
package zhimeng

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md"
"encoding/json"
"fmt"
"github.com/syyongx/php2go"
)

// 转链后, 可以通过链接拼装&relationId(int)或者&externalId(string)(二选一)进行订单获取
func TaobaoConvertUrl(appkey, appsecret, itemId, tbPid, tbSid string, tbExternalId, tbAppKey string) (*md.ConvertedUrls, error) {
args := map[string]interface{}{
"appkey": appkey,
"secret_key": appsecret,
"gid": itemId,
"new_external_id": tbExternalId, //自定义参数 只有要生成备案链接用
"pid": tbPid,
"tb_app_key": tbAppKey,
"session": tbSid, //tbSid
}
fmt.Println(args)
if php2go.IsNumeric(itemId) {
args["biz_scene_id"] = "2"
}
resp, err := Send("agent_tb", "url", args)
if err != nil {
return nil, err
}
var tmp struct {
Success int `json:"success"`
Data struct {
HaveCoupon string `json:"have_coupon"`
URL string `json:"url"`
MaxCommissionRate string `json:"max_commission_rate"`
} `json:"data"`
}
if err = json.Unmarshal(resp, &tmp); err != nil {
return nil, err
}
var hasCoupon bool
if tmp.Data.HaveCoupon == "1" {
hasCoupon = true
}
return &md.ConvertedUrls{
ItemId: itemId,
URL: tmp.Data.URL,
ShortenURL: tmp.Data.URL,
NoOpenAppURL: tmp.Data.URL,
AppURL: tmp.Data.URL,
HasCoupon: hasCoupon,
CommissionRate: tmp.Data.MaxCommissionRate,
}, nil
}

+ 50
- 0
zhimeng/taobao_publisher_info_list.go Näytä tiedosto

@@ -0,0 +1,50 @@
package zhimeng

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md"
"encoding/json"
"errors"
)

//会员id
func TaobaoPublisherRelationInfoList(appkey, appsecret, tbSid, p, tbAppKey string) (*[]md.PublisherInfo, error) {
args := map[string]interface{}{
"appkey": appkey,
"secret_key": appsecret,
"session": tbSid,
"p": p,
"tb_app_key": tbAppKey,
}
resp, err := Send("agent_tb", "publisher_info_relation_list", args)
if err != nil {
return nil, err
}
var tmp struct {
Data []struct {
RelationId string `json:"relation_id"`
SpecialId string `json:"special_id"`
ExternalId string `json:"external_id"`
Rtag string `json:"rtag"`
} `json:"data"`
}
if err = json.Unmarshal(resp, &tmp); err != nil {
return nil, err
}
if len(tmp.Data) == 0 {
return nil, errors.New("没有商品")
}

var (
res []md.PublisherInfo
)
for _, v := range tmp.Data {

res = append(res, md.PublisherInfo{
RelationId: v.RelationId,
SpecialId: v.SpecialId,
ExternalId: v.ExternalId,
Rtag: v.Rtag,
})
}
return &res, nil
}

+ 77
- 0
zhimeng/tik_tok_goods_url.go Näytä tiedosto

@@ -0,0 +1,77 @@
package zhimeng

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md"
"encoding/json"
"github.com/syyongx/php2go"
)

type TikTokUrlData struct {
Deeplink string `json:"deeplink"`
Content string `json:"content"`
QrCode string `json:"qr_code"`
Link string `json:"link"`
AppId string `json:"app_id"`
PageUrl string `json:"page_url"`
}

func TikTokUrl(tikTokArgs map[string]interface{}) (*md.ConvertedUrls, error) {
args := map[string]interface{}{
"appkey": tikTokArgs["appkey"],
"secret_key": tikTokArgs["secret_key"],
"product_url": tikTokArgs["product_url"],
"external_info": tikTokArgs["external_info"],
"need_qr_code": tikTokArgs["need_qr_code"],
}
resp, err := Send("tik_tok", "getUrls", args)
if err != nil {
return nil, err
}
var tmp struct {
Data TikTokUrlData `json:"data"`
}
if err = json.Unmarshal(resp, &tmp); err != nil {
return nil, err
}
content, _ := php2go.Base64Decode(tmp.Data.Content)
return &md.ConvertedUrls{
URL: tmp.Data.Deeplink,
ShortenURL: tmp.Data.Deeplink,
NoOpenAppURL: tmp.Data.Deeplink,
AppURL: tmp.Data.Deeplink,
ClickUrl: tmp.Data.Deeplink,
QrcodeUrl: tmp.Data.QrCode,
Content: content,
}, nil
}

func TikTokActUrl(tikTokArgs map[string]interface{}) (*md.ConvertedUrls, error) {
args := map[string]interface{}{
"appkey": tikTokArgs["appkey"],
"secret_key": tikTokArgs["secret_key"],
"activity_id": tikTokArgs["material_id"],
"mix_activity_id": tikTokArgs["material_id"],
"need_qr_code": tikTokArgs["need_qr_code"],
"external_info": tikTokArgs["external_info"],
}
resp, err := Send("tik_tok", "getActUrls", args)
if err != nil {
return nil, err
}
var tmp struct {
Data TikTokUrlData `json:"data"`
}
if err = json.Unmarshal(resp, &tmp); err != nil {
return nil, err
}
content, _ := php2go.Base64Decode(tmp.Data.Content)
return &md.ConvertedUrls{
URL: tmp.Data.Deeplink,
ShortenURL: tmp.Data.Deeplink,
NoOpenAppURL: tmp.Data.Deeplink,
AppURL: tmp.Data.Deeplink,
ClickUrl: tmp.Data.Deeplink,
QrcodeUrl: tmp.Data.QrCode,
Content: content,
}, nil
}

+ 42
- 0
zhimeng/vip_convert_url.go Näytä tiedosto

@@ -0,0 +1,42 @@
package zhimeng

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md"
"encoding/json"
)

// todo
func VipConvertUrl(ak, sk, itemId, pid, couponPrice, adCode, openId, realCall string) (*md.ConvertedUrls, error) {
args := map[string]interface{}{
"appkey": ak,
"secret_key": sk,
"gid": itemId,
"pid": pid,
"adCode": adCode,
"openId": openId,
"realCall": realCall,
}
resp, err := Send("wph_new", "url", args)
if err != nil {
return nil, err
}
var tmp struct {
Data struct {
URL string `json:"url"`
DeepUrl string `json:"deep_url"`
VipWxUrl string `json:"vipWxUrl"`
} `json:"data"`
}
if err = json.Unmarshal(resp, &tmp); err != nil {
return nil, err
}
return &md.ConvertedUrls{
ItemId: itemId,
URL: tmp.Data.URL,
ShortenURL: tmp.Data.URL,
NoOpenAppURL: tmp.Data.URL,
AppURL: tmp.Data.DeepUrl,
HasCoupon: false,
CommissionRate: couponPrice,
}, nil
}

Ladataan…
Peruuta
Tallenna