@@ -889,7 +889,7 @@ func FindTaobaoWord(eg *xorm.Engine, officialEg *xorm.Engine, tmp map[string]str | |||||
return | return | ||||
} | } | ||||
func CheckTaobao(eg *xorm.Engine, officialEg *xorm.Engine, dbName, s string, args map[string]string) *md.ItemParseInfo { | func CheckTaobao(eg *xorm.Engine, officialEg *xorm.Engine, dbName, s string, args map[string]string) *md.ItemParseInfo { | ||||
bizSceneId := "2" | |||||
bizSceneId := "" | |||||
taobaoSdk, _ := taobao.NewTaobaoSDK(eg, args["master_id"], args["platform"], zhios_third_party_utils.StrToInt(args["acc_taobao_share_id"]), args["union_id"]) | taobaoSdk, _ := taobao.NewTaobaoSDK(eg, args["master_id"], args["platform"], zhios_third_party_utils.StrToInt(args["acc_taobao_share_id"]), args["union_id"]) | ||||
if taobaoSdk == nil { | if taobaoSdk == nil { | ||||
return nil | return nil | ||||
@@ -1224,7 +1224,7 @@ func TBByGoodsId(eg *xorm.Engine, officialEg *xorm.Engine, tmp map[string]string | |||||
} | } | ||||
var itemInfo *taobao.Material | var itemInfo *taobao.Material | ||||
if goodsId != "" { | if goodsId != "" { | ||||
itemInfo, err = taobaoSdk.ItemDetailById(goodsId, "2") | |||||
itemInfo, err = taobaoSdk.ItemDetailById(goodsId, "") | |||||
} else { | } else { | ||||
itemInfo, err = taobaoSdk.ItemDetailByLink(url, "") | itemInfo, err = taobaoSdk.ItemDetailByLink(url, "") | ||||
} | } | ||||
@@ -27,8 +27,8 @@ const ( | |||||
// TODO 物料id查找 https://market.m.taobao.com/app/qn/toutiao-new/index-pc.html#/detail/10628875?_k=gpov9a | // TODO 物料id查找 https://market.m.taobao.com/app/qn/toutiao-new/index-pc.html#/detail/10628875?_k=gpov9a | ||||
// 淘宝业务, op for operation 操作, tbk for taobaoke, | // 淘宝业务, op for operation 操作, tbk for taobaoke, | ||||
TBK_SC_MTL_OPT = "taobao.tbk.sc.material.optional" // 淘宝客-服务商-物料搜索 | |||||
TBK_DG_MTL_OPT = "taobao.tbk.dg.material.optional" // 淘宝客-推广者-物料搜索 | |||||
TBK_SC_MTL_OPT = "taobao.tbk.sc.material.optional.upgrade" // 淘宝客-服务商-物料搜索 | |||||
TBK_DG_MTL_OPT = "taobao.tbk.dg.material.optional.upgrade" // 淘宝客-推广者-物料搜索 | |||||
TB_SVC_AK = "33970476" | TB_SVC_AK = "33970476" | ||||
TB_SVC_SK = "2d46abef05a0d05d7ddcd3af2d540d2b" | TB_SVC_SK = "2d46abef05a0d05d7ddcd3af2d540d2b" | ||||
TB_SVC_TIME = "2022-08-09 10:58:00" | TB_SVC_TIME = "2022-08-09 10:58:00" | ||||
@@ -14,6 +14,7 @@ type Material struct { | |||||
CategoryName string `json:"category_name"` | CategoryName string `json:"category_name"` | ||||
CommissionRate string `json:"commission_rate"` | CommissionRate string `json:"commission_rate"` | ||||
CommissionType string `json:"commission_type"` | CommissionType string `json:"commission_type"` | ||||
GoodsCoupon string `json:"goods_coupon"` | |||||
CouponID string `json:"coupon_id"` | CouponID string `json:"coupon_id"` | ||||
CouponInfo string `json:"coupon_info"` | CouponInfo string `json:"coupon_info"` | ||||
CouponRemainCount int `json:"coupon_remain_count"` | CouponRemainCount int `json:"coupon_remain_count"` | ||||
@@ -56,6 +57,91 @@ type Material struct { | |||||
CouponStartTime string `json:"coupon_start_time,omitempty"` | CouponStartTime string `json:"coupon_start_time,omitempty"` | ||||
InputNumIid interface{} `json:"input_num_iid"` | InputNumIid interface{} `json:"input_num_iid"` | ||||
} | } | ||||
type scTbkScMaterialOptionalUpgradeResponse struct { | |||||
TbkScMaterialOptionalUpgradeResponse struct { | |||||
TotalResults int `json:"total_results"` | |||||
ResultList struct { | |||||
MapData []NewMarterial `json:"map_data"` | |||||
} `json:"result_list"` | |||||
UvidMsg string `json:"uvid_msg"` | |||||
} `json:"tbk_sc_material_optional_upgrade_response"` | |||||
} | |||||
type NewMarterial struct { | |||||
ItemBasicInfo struct { | |||||
BrandName string `json:"brand_name"` | |||||
CategoryId int `json:"category_id"` | |||||
CategoryName string `json:"category_name"` | |||||
LevelOneCategoryId int `json:"level_one_category_id"` | |||||
LevelOneCategoryName string `json:"level_one_category_name"` | |||||
PictUrl string `json:"pict_url"` | |||||
SellerId int64 `json:"seller_id"` | |||||
ShopTitle string `json:"shop_title"` | |||||
ShortTitle string `json:"short_title"` | |||||
SubTitle string `json:"sub_title"` | |||||
Title string `json:"title"` | |||||
UserType int `json:"user_type"` | |||||
Volume int `json:"volume"` | |||||
TkTotalSales string `json:"tk_total_sales"` | |||||
WhiteImage string `json:"white_image"` | |||||
SmallImages struct { | |||||
String []string `json:"string"` | |||||
} `json:"small_images"` | |||||
} `json:"item_basic_info"` | |||||
ItemId string `json:"item_id"` | |||||
PresaleInfo struct { | |||||
PresaleDeposit string `json:"presale_deposit"` | |||||
} `json:"presale_info"` | |||||
PricePromotionInfo struct { | |||||
FinalPromotionPathList struct { | |||||
FinalPromotionPathMapData []struct { | |||||
PromotionDesc string `json:"promotion_desc"` | |||||
PromotionEndTime string `json:"promotion_end_time"` | |||||
PromotionFee string `json:"promotion_fee"` | |||||
PromotionId string `json:"promotion_id"` | |||||
PromotionStartTime string `json:"promotion_start_time"` | |||||
PromotionTitle string `json:"promotion_title"` | |||||
} `json:"final_promotion_path_map_data"` | |||||
} `json:"final_promotion_path_list"` | |||||
FinalPromotionPrice string `json:"final_promotion_price"` | |||||
MorePromotionList struct { | |||||
MorePromotionMapData []struct { | |||||
PromotionDesc string `json:"promotion_desc"` | |||||
PromotionEndTime string `json:"promotion_end_time"` | |||||
PromotionStartTime string `json:"promotion_start_time"` | |||||
PromotionTitle string `json:"promotion_title"` | |||||
} `json:"more_promotion_map_data"` | |||||
} `json:"more_promotion_list,omitempty"` | |||||
PredictRoundingUpPathList struct { | |||||
PredictRoundingUpPathMapData []struct { | |||||
PromotionDesc string `json:"promotion_desc"` | |||||
PromotionTitle string `json:"promotion_title"` | |||||
} `json:"predict_rounding_up_path_map_data"` | |||||
} `json:"predict_rounding_up_path_list,omitempty"` | |||||
PredictRoundingUpPrice string `json:"predict_rounding_up_price,omitempty"` | |||||
PredictRoundingUpPriceDesc string `json:"predict_rounding_up_price_desc,omitempty"` | |||||
PromotionTagList struct { | |||||
PromotionTagMapData []struct { | |||||
TagName string `json:"tag_name"` | |||||
} `json:"promotion_tag_map_data"` | |||||
} `json:"promotion_tag_list"` | |||||
ReservePrice string `json:"reserve_price"` | |||||
ZkFinalPrice string `json:"zk_final_price"` | |||||
} `json:"price_promotion_info"` | |||||
PublishInfo struct { | |||||
ClickUrl string `json:"click_url"` | |||||
CouponShareUrl string `json:"coupon_share_url"` | |||||
IncomeInfo struct { | |||||
CommissionAmount string `json:"commission_amount"` | |||||
CommissionRate string `json:"commission_rate"` | |||||
SubsidyAmount string `json:"subsidy_amount"` | |||||
SubsidyRate string `json:"subsidy_rate"` | |||||
} `json:"income_info"` | |||||
IncomeRate string `json:"income_rate"` | |||||
} `json:"publish_info"` | |||||
ScopeInfo struct { | |||||
SuperiorBrand interface{} `json:"superior_brand"` | |||||
} `json:"scope_info"` | |||||
} | |||||
type wrapperStruct struct { | type wrapperStruct struct { | ||||
TbkDgMaterialOptionalResponse struct { | TbkDgMaterialOptionalResponse struct { | ||||
@@ -8,6 +8,7 @@ import ( | |||||
"fmt" | "fmt" | ||||
"github.com/syyongx/php2go" | "github.com/syyongx/php2go" | ||||
"strings" | "strings" | ||||
"time" | |||||
"xorm.io/xorm" | "xorm.io/xorm" | ||||
) | ) | ||||
@@ -151,19 +152,50 @@ func (t *TB) ItemDetailByLink(l, bizSceneId string) (*Material, error) { | |||||
// 如果是跟随官方 结构不一样 | // 如果是跟随官方 结构不一样 | ||||
if t.AuthType == 1 { | if t.AuthType == 1 { | ||||
var tmp scMaterialOptionalStruct | |||||
var tmp scTbkScMaterialOptionalUpgradeResponse | |||||
if err = json.Unmarshal(resp, &tmp); err != nil { | if err = json.Unmarshal(resp, &tmp); err != nil { | ||||
return nil, err | return nil, err | ||||
} | } | ||||
if len(tmp.TbkScMaterialOptionalResponse.ResultList.MapData) == 0 { | |||||
return nil, errors.New("没有数据") | |||||
if len(tmp.TbkScMaterialOptionalUpgradeResponse.ResultList.MapData) == 0 { | |||||
return nil, err | |||||
} | } | ||||
data := tmp.TbkScMaterialOptionalResponse.ResultList.MapData[0] | |||||
itemID, ok := data.ItemID.(float64) | |||||
if ok { | |||||
data.ItemID = int64(itemID) | |||||
data := tmp.TbkScMaterialOptionalUpgradeResponse.ResultList.MapData[0] | |||||
tmp1 := Material{ | |||||
CategoryID: data.ItemBasicInfo.CategoryId, | |||||
CategoryName: data.ItemBasicInfo.CategoryName, | |||||
CommissionRate: zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.StrToFloat64(data.PublishInfo.IncomeRate) * 100), | |||||
ItemID: data.ItemId, | |||||
Nick: data.ItemBasicInfo.ShopTitle, | |||||
PictURL: data.ItemBasicInfo.PictUrl, | |||||
SellerID: int(data.ItemBasicInfo.SellerId), | |||||
ShopTitle: data.ItemBasicInfo.ShopTitle, | |||||
ShortTitle: data.ItemBasicInfo.ShortTitle, | |||||
Title: data.ItemBasicInfo.Title, | |||||
ZkFinalPrice: data.PricePromotionInfo.ZkFinalPrice, | |||||
ReservePrice: data.PricePromotionInfo.ReservePrice, | |||||
Volume: data.ItemBasicInfo.Volume, | |||||
UserType: data.ItemBasicInfo.UserType, | |||||
TkTotalSales: zhios_third_party_utils.IntToStr(data.ItemBasicInfo.Volume), | |||||
} | } | ||||
return &data, nil | |||||
tmp1.SmallImages = data.ItemBasicInfo.SmallImages | |||||
if len(data.ItemBasicInfo.SmallImages.String) == 0 { | |||||
tmp1.SmallImages.String = []string{tmp1.PictURL} | |||||
} | |||||
if zhios_third_party_utils.StrToFloat64(data.PricePromotionInfo.FinalPromotionPrice) > 0 { | |||||
for _, v1 := range data.PricePromotionInfo.FinalPromotionPathList.FinalPromotionPathMapData { | |||||
tmp1.CouponAmount = zhios_third_party_utils.Float64ToStrByPrec(zhios_third_party_utils.StrToFloat64(v1.PromotionFee)+zhios_third_party_utils.StrToFloat64(tmp1.CouponAmount), 2) | |||||
tmp1.CouponStartTime = zhios_third_party_utils.IntToStr(zhios_third_party_utils.StrToInt(v1.PromotionStartTime) / 1000) | |||||
tmp1.CouponEndTime = zhios_third_party_utils.IntToStr(zhios_third_party_utils.StrToInt(v1.PromotionEndTime) / 1000) | |||||
tmp1.CouponID = v1.PromotionId | |||||
if v1.PromotionTitle == "商品券" || v1.PromotionTitle == "店铺券" { | |||||
if zhios_third_party_utils.StrToInt64(v1.PromotionEndTime)/1000 > time.Now().Unix() { | |||||
tmp1.GoodsCoupon = "1" | |||||
} | |||||
} | |||||
} | |||||
} | |||||
return &tmp1, nil | |||||
} else { | } else { | ||||
var tmp wrapperStruct | var tmp wrapperStruct | ||||
if err = json.Unmarshal(resp, &tmp); err != nil { | if err = json.Unmarshal(resp, &tmp); err != nil { | ||||