Browse Source

抖音穿山甲

master
huangjiajun 10 months ago
parent
commit
52d301e9c7
5 changed files with 426 additions and 28 deletions
  1. +8
    -16
      chain_transfer/chain_transfer.go
  2. +4
    -10
      chain_transfer/svc/svc_turnchain.go
  3. +73
    -2
      csjplatform/order.go
  4. +2
    -0
      md/url.go
  5. +339
    -0
      taobao/convert_url.go

+ 8
- 16
chain_transfer/chain_transfer.go View File

@@ -67,24 +67,16 @@ func ChainTransfer(eg *xorm.Engine, args map[string]string) map[string]string {
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)
if strings.Contains(curls.ShortenURL, "uland.") {
if strings.Contains(curls.ShortenURL, "?") {
curls.ShortenURL += "&activityId=" + itemInfo.ActivityId
} else {
curls.ShortenURL += "?activityId=" + itemInfo.ActivityId
}
}
} 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
if curls.Tkl != "" {
curls.TaoBaoWord = curls.Tkl
}
res["url"] = curls.ShortenURL
res["word"] = curls.TaoBaoWord


+ 4
- 10
chain_transfer/svc/svc_turnchain.go View File

@@ -260,6 +260,9 @@ func ConvertUrl(eg *xorm.Engine, args map[string]string) (*md.ConvertedUrls, err
} else {
promoId = promoId1
}
if taobaoShareId1 != "" {
args["acc_taobao_share_id"] = taobaoShareId1
}
}
}
thirdZmAppKeyData, err := db.SysCfgGetOne(eg, "third_zm_app_key")
@@ -270,16 +273,7 @@ func ConvertUrl(eg *xorm.Engine, args map[string]string) (*md.ConvertedUrls, err
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
}
}
urls, err = taobaoSdk.WnConvertUrlSC(args["gid"], "4", promoId, args["acc_taobao_share_id"])
case md.PVD_JDS:
thirdZmAppKeyData, err := db.SysCfgGetOne(eg, "third_zm_app_key")
if thirdZmAppKeyData == nil || err != nil {


+ 73
- 2
csjplatform/order.go View File

@@ -1,7 +1,6 @@
package csjplatform

import (
"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"
"encoding/json"
"github.com/tidwall/gjson"
@@ -40,7 +39,7 @@ func OrderList(args map[string]string) map[string]interface{} {
}
for _, v := range tmpList {

tmp := tik_tok.CommOrder(v, statusArr, "dk")
tmp := CommOrder(v, statusArr, "dk")
if tmp["oid"] == "" {
continue
}
@@ -49,3 +48,75 @@ func OrderList(args map[string]string) map[string]interface{} {
data["order"] = orderTmp
return data
}
func CommOrder(v interface{}, statusArr map[string]string, types string) map[string]string {
tmp := make(map[string]string)
goods := v.(map[string]interface{})
pidInfo, ok := goods["pid_info"].(map[string]interface{})
mediaTypeName := ""
if ok == false {
return tmp
}
mediaTypeName = zhios_third_party_utils.AnyToString(pidInfo["media_type_name"])
tmp = map[string]string{
"pid": zhios_third_party_utils.AnyToString(pidInfo["pid"]),
"oid": zhios_third_party_utils.AnyToString(goods["order_id"]),
"info": zhios_third_party_utils.AnyToString(goods["product_name"]),
"num": zhios_third_party_utils.AnyToString(goods["item_num"]),
"type": zhios_third_party_utils.AnyToString(mediaTypeName),
"product_id": zhios_third_party_utils.AnyToString(goods["product_id"]),
"product_img": zhios_third_party_utils.AnyToString(goods["product_img"]),
"payment": zhios_third_party_utils.AnyToString(zhios_third_party_utils.AnyToFloat64(goods["total_pay_amount"]) / 100),
"status": statusArr[zhios_third_party_utils.AnyToString(goods["flow_point"])],
"create_time": zhios_third_party_utils.Int64ToStr(zhios_third_party_utils.TimeStdParseUnix(zhios_third_party_utils.AnyToString(goods["pay_success_time"]))),
"update_time": zhios_third_party_utils.Int64ToStr(zhios_third_party_utils.TimeStdParseUnix(zhios_third_party_utils.AnyToString(goods["update_time"]))),
"refund_time": "",
"lm_js_time": "",
"mid": "",
}
external_info := zhios_third_party_utils.AnyToString(pidInfo["external_info"])
tmp["is_share"] = "0"
split := strings.Split(external_info, "_")
if len(split) > 1 {
if split[0] == "s" {
tmp["is_share"] = "1"
}
if split[0] == "cloud" {
tmp["is_share"] = "3"
}
if split[0] == "f" {
tmp["is_share"] = "2"
}
if split[0] == "sef" {
tmp["is_share"] = "4"
}
if split[0] == "sharesef" {
tmp["is_share"] = "5"
}
if split[0] == "moref" {
tmp["is_share"] = "6"
}
tmp["uid"] = split[1]
if len(split) == 3 {
tmp["mid"] = split[2]
}
}
if tmp["type"] == "Live" || tmp["type"] == "Activity" || tmp["type"] == "Mix" || tmp["type"] == "ActivityMaterial" || types == "dk" {
tmp["commission"] = zhios_third_party_utils.AnyToString(zhios_third_party_utils.AnyToFloat64(goods["ads_estimated_commission"]) / 100)
if zhios_third_party_utils.AnyToFloat64(goods["ads_real_commission"]) > 0 {
tmp["commission"] = zhios_third_party_utils.AnyToString(zhios_third_party_utils.AnyToFloat64(goods["ads_real_commission"]) / 100)
}
}
if tmp["type"] == "ProductDetail" && types == "" {
tmp["commission"] = zhios_third_party_utils.AnyToString(zhios_third_party_utils.AnyToFloat64(goods["estimated_commission"]) / 100)
if zhios_third_party_utils.AnyToFloat64(goods["real_commission"]) > 0 {
tmp["commission"] = zhios_third_party_utils.AnyToString(zhios_third_party_utils.AnyToFloat64(goods["real_commission"]) / 100)
}
}
if zhios_third_party_utils.AnyToString(goods["refund_time"]) != "" {
tmp["refund_time"] = zhios_third_party_utils.Int64ToStr(zhios_third_party_utils.TimeStdParseUnix(zhios_third_party_utils.AnyToString(goods["pay_success_time"])))
}
if zhios_third_party_utils.AnyToString(goods["settle_time"]) != "" {
tmp["lm_js_time"] = zhios_third_party_utils.Int64ToStr(zhios_third_party_utils.TimeStdParseUnix(zhios_third_party_utils.AnyToString(goods["settle_time"])))
}
return tmp
}

+ 2
- 0
md/url.go View File

@@ -8,6 +8,8 @@ type ExtraData struct {

// 转链后链接
type ConvertedUrls struct {
Tkl string `json:"tkl"`
ShortTkl string `json:"short_tkl"`
ItemId string `json:"item_id"`
ItemUrl string `json:"item_url"`
NumGoodsId string `json:"num_goods_id"`


+ 339
- 0
taobao/convert_url.go View File

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

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

type UrlInfo struct {
CategoryID int `json:"category_id"`
CouponClickURL string `json:"coupon_click_url"`
CouponEndTime string `json:"coupon_end_time"`
CouponInfo string `json:"coupon_info"`
CouponRemainCount int `json:"coupon_remain_count"`
CouponStartTime string `json:"coupon_start_time"`
CouponTotalCount int `json:"coupon_total_count"`
ItemID string `json:"item_id"`
ItemURL string `json:"item_url"`
MaxCommissionRate string `json:"max_commission_rate"`
MinCommissionRate string `json:"min_commission_rate"`
RewardInfo int `json:"reward_info"`
}

// 淘宝转链
func (t *TB) ConvertUrlSC(itemId, pid, externalId string) (*md.ConvertedUrls, error) {
method := "taobao.tbk.privilege.get"
_, siteId, adZoneId := SplitPid(pid)
args := map[string]string{
"item_id": itemId,
"session": t.UserSID, // 一般用站长就可以转链
"adzone_id": adZoneId,
"platform": "2",
"site_id": siteId,
}

if php2go.IsNumeric(itemId) {
args["biz_scene_id"] = "2"
}
if externalId != "" {
args["external_id"] = externalId
}
resp, err := send(args, method, t.Svc_AK, t.Svc_SK)
if err != nil {
return nil, err
}
var tmp struct {
TbkPrivilegeGetResponse struct {
Result struct {
Data UrlInfo `json:"data"`
} `json:"result"`
RequestID string `json:"request_id"`
} `json:"tbk_privilege_get_response"`
}
if err = json.Unmarshal(resp, &tmp); err != nil {
return nil, err
}
url := tmp.TbkPrivilegeGetResponse.Result.Data.ItemURL
hasCoupon := false
itemUrl := tmp.TbkPrivilegeGetResponse.Result.Data.ItemURL
maxCommissionRate := tmp.TbkPrivilegeGetResponse.Result.Data.MaxCommissionRate
if tmp.TbkPrivilegeGetResponse.Result.Data.CouponClickURL != "" {
hasCoupon = true
url = tmp.TbkPrivilegeGetResponse.Result.Data.CouponClickURL
}
return &md.ConvertedUrls{
ItemId: itemId,
URL: url,
ItemUrl: itemUrl,
ShortenURL: url,
NoOpenAppURL: url,
AppURL: url,
HasCoupon: hasCoupon,
CommissionRate: maxCommissionRate,
}, nil
}

func (t *TB) WnConvertUrlSC(itemId, types, pid, externalId string) (*md.ConvertedUrls, error) {
method := "taobao.tbk.sc.general.link.convert"
_, siteId, adZoneId := SplitPid(pid)
args := map[string]string{
"session": t.UserSID, // 一般用站长就可以转链
"adzone_id": adZoneId,
"platform": "2",
"site_id": siteId,
}
if types == "1" || types == "4" { // 商品ID列表
args["item_id_list"] = itemId
args["biz_scene_id"] = "1"
if php2go.IsNumeric(itemId) {
args["biz_scene_id"] = "2"
}
if externalId != "" && types == "1" {
args["relation_id"] = externalId
}
if externalId != "" && types == "4" {
args["external_id"] = externalId
}
}
if types == "2" { //物料列表,可以为url或淘口令
args["material_list"] = itemId
if externalId != "" {
args["relation_id"] = externalId
}
}

if types == "3" { // 会场ID列表
args["page_id_list"] = itemId
if externalId != "" {
args["relation_id"] = externalId
}
}

resp, err := send(args, method, t.Svc_AK, t.Svc_SK)
if err != nil {
return nil, err
}
var tmp struct {
TbkScGeneralLinkConvertResponse struct {
Data struct {
MaterialUrlList struct {
MaterialUrlList []struct {
Msg string `json:"msg"`
Code int `json:"code"`
PromotionInfoDto struct {
CommissionRate string `json:"commission_rate"`
} `json:"promotion_info_dto"`
CouponInfoDto struct {
CouponEndTime string `json:"coupon_end_time"`
ActivityId string `json:"activity_id"`
CouponRemainCount int `json:"coupon_remain_count"`
CouponAmount string `json:"coupon_amount"`
CouponStartTime string `json:"coupon_start_time"`
CouponDesc string `json:"coupon_desc"`
CouponType int `json:"coupon_type"`
} `json:"coupon_info_dto"`
LinkInfoDto struct {
CouponLongUrl string `json:"coupon_long_url"`
MaterialType int `json:"material_type"`
TpwdOriginUrl string `json:"tpwd_origin_url"`
MaterialId string `json:"material_id"`
CpsLongUrl string `json:"cps_long_url"`
CpsShortTpwd string `json:"cps_short_tpwd"`
TkBizType int `json:"tk_biz_type"`
CouponShortTpwd string `json:"coupon_short_tpwd"`
CpsShortUrl string `json:"cps_short_url"`
CouponShortUrl string `json:"coupon_short_url"`
CouponFullTpwd string `json:"coupon_full_tpwd"`
CpsFullTpwd string `json:"cps_full_tpwd"`
} `json:"link_info_dto"`
} `json:"material_url_list"`
} `json:"material_url_list"`
ShopUrlList struct {
ShopUrlList []struct {
Msg string `json:"msg"`
Code int `json:"code"`
LinkInfoDto struct {
MaterialType int `json:"material_type"`
SellerId string `json:"seller_id"`
CpsLongUrl string `json:"cps_long_url"`
CpsShortTpwd string `json:"cps_short_tpwd"`
CpsShortUrl string `json:"cps_short_url"`
CpsFullTpwd string `json:"cps_full_tpwd"`
} `json:"link_info_dto"`
} `json:"shop_url_list"`
} `json:"shop_url_list"`
EventUrlList struct {
EventUrlList []struct {
Msg string `json:"msg"`
Code int `json:"code"`
LinkInfoDto struct {
MaterialType int `json:"material_type"`
PageId string `json:"page_id"`
CpsLongUrl string `json:"cps_long_url"`
CpsShortTpwd string `json:"cps_short_tpwd"`
CpsShortUrl string `json:"cps_short_url"`
CpsFullTpwd string `json:"cps_full_tpwd"`
} `json:"link_info_dto"`
} `json:"event_url_list"`
} `json:"event_url_list"`
ItemUrlList struct {
ItemUrlList []struct {
Msg string `json:"msg"`
Code int `json:"code"`
PromotionInfoDto struct {
CommissionRate string `json:"commission_rate"`
} `json:"promotion_info_dto"`
CouponInfoDto struct {
CouponEndTime string `json:"coupon_end_time"`
ActivityId string `json:"activity_id"`
CouponRemainCount int `json:"coupon_remain_count"`
CouponAmount string `json:"coupon_amount"`
CouponStartTime string `json:"coupon_start_time"`
CouponDesc string `json:"coupon_desc"`
} `json:"coupon_info_dto"`
LinkInfoDto struct {
CouponLongUrl string `json:"coupon_long_url"`
MaterialType int `json:"material_type"`
ItemId string `json:"item_id"`
CpsLongUrl string `json:"cps_long_url"`
CpsShortTpwd string `json:"cps_short_tpwd"`
CouponShortTpwd string `json:"coupon_short_tpwd"`
CpsShortUrl string `json:"cps_short_url"`
CouponShortUrl string `json:"coupon_short_url"`
CouponFullTpwd string `json:"coupon_full_tpwd"`
CpsFullTpwd string `json:"cps_full_tpwd"`
} `json:"link_info_dto"`
} `json:"item_url_list"`
} `json:"item_url_list"`
} `json:"data"`
BizErrorDesc int `json:"biz_error_desc"`
ResultMsg string `json:"result_msg"`
} `json:"tbk_sc_general_link_convert_response"`
}
if err = json.Unmarshal(resp, &tmp); err != nil {
return nil, err
}
url := ""
hasCoupon := false
itemUrl := ""
maxCommissionRate := ""
tkl := ""
shortTkl := ""
isitem := 0
for _, v := range tmp.TbkScGeneralLinkConvertResponse.Data.ItemUrlList.ItemUrlList {
url = v.LinkInfoDto.CouponLongUrl
tkl = v.LinkInfoDto.CouponFullTpwd
shortTkl = v.LinkInfoDto.CouponShortTpwd
if url == "" {
url = v.LinkInfoDto.CpsLongUrl
tkl = v.LinkInfoDto.CpsFullTpwd
shortTkl = v.LinkInfoDto.CpsShortTpwd
}
if v.LinkInfoDto.CouponLongUrl != "" {
hasCoupon = true
}
itemId = v.LinkInfoDto.ItemId
itemUrl = url
isitem = 1
maxCommissionRate = v.PromotionInfoDto.CommissionRate
}

for _, v := range tmp.TbkScGeneralLinkConvertResponse.Data.MaterialUrlList.MaterialUrlList {
url = v.LinkInfoDto.CouponLongUrl
tkl = v.LinkInfoDto.CouponFullTpwd
shortTkl = v.LinkInfoDto.CouponShortTpwd
if url == "" {
url = v.LinkInfoDto.CpsLongUrl
tkl = v.LinkInfoDto.CpsFullTpwd
shortTkl = v.LinkInfoDto.CpsShortTpwd
}
if v.LinkInfoDto.CouponLongUrl != "" {
hasCoupon = true
}
//1—单品 2—店铺 3—会场 4-承接开放 5-优惠券
if v.Code == 0 && (v.LinkInfoDto.MaterialType == 1 || v.LinkInfoDto.MaterialType == 0) {
itemId = v.LinkInfoDto.MaterialId
isitem = 1
}
itemUrl = url
maxCommissionRate = v.PromotionInfoDto.CommissionRate
}
if isitem == 0 && len(tmp.TbkScGeneralLinkConvertResponse.Data.MaterialUrlList.MaterialUrlList) > 0 {
itemId = ""
}
for _, v := range tmp.TbkScGeneralLinkConvertResponse.Data.EventUrlList.EventUrlList {
url = v.LinkInfoDto.CpsLongUrl
tkl = v.LinkInfoDto.CpsFullTpwd
shortTkl = v.LinkInfoDto.CpsShortTpwd
itemUrl = url
}
return &md.ConvertedUrls{
Tkl: tkl,
ShortTkl: shortTkl,
ItemId: itemId,
URL: url,
ItemUrl: itemUrl,
ShortenURL: url,
NoOpenAppURL: url,
AppURL: url,
HasCoupon: hasCoupon,
CommissionRate: maxCommissionRate,
}, nil
}

type T struct {
TbkScActivityInfoGetResponse struct {
Data struct {
ClickUrl string `json:"click_url"`
PageEndTime string `json:"page_end_time"`
PageName string `json:"page_name"`
PageStartTime string `json:"page_start_time"`
TerminalType string `json:"terminal_type"`
} `json:"data"`
RequestId string `json:"request_id"`
} `json:"tbk_sc_activity_info_get_response"`
}

func (t *TB) ActivityConvertUrlSC(activityMaterialId, pid string, relationId int64) (*md.OfficialRecommendUrl, error) {
method := "taobao.tbk.sc.activity.info.get"
_, siteId, adZoneId := SplitPid(pid)
args := map[string]string{
"activity_material_id": activityMaterialId,
"session": t.UserSID, // 一般用站长就可以转链
"adzone_id": adZoneId,
"platform": "2",
"site_id": siteId,
}
if relationId > 0 {
args["relation_id"] = strconv.FormatInt(relationId, 10)
}
resp, err := send(args, method, t.Svc_AK, t.Svc_SK)
if err != nil {
return nil, err
}
var tmp struct {
TbkScActivityInfoGetResponse struct {
Data struct {
WxQrcodeUrl string `json:"wx_qrcode_url"`
WxMiniprogramPath string `json:"wx_miniprogram_path"`
Url string `json:"click_url"`
ShortClickurl string `json:"short_click_url"`
} `json:"data"`
} `json:"tbk_sc_activity_info_get_response"`
}
if err = json.Unmarshal(resp, &tmp); err != nil {
return nil, err
}

url := tmp.TbkScActivityInfoGetResponse.Data.Url
if tmp.TbkScActivityInfoGetResponse.Data.ShortClickurl != "" {
url = tmp.TbkScActivityInfoGetResponse.Data.ShortClickurl
}
return &md.OfficialRecommendUrl{
WxQrcodeUrl: tmp.TbkScActivityInfoGetResponse.Data.WxQrcodeUrl,
WxMiniprogramPath: tmp.TbkScActivityInfoGetResponse.Data.WxMiniprogramPath,
Url: url,
}, nil
}

Loading…
Cancel
Save