Ver código fonte

拼多多联盟

master
huangjiajun 5 meses atrás
pai
commit
797cba2ce4
2 arquivos alterados com 100 adições e 0 exclusões
  1. +58
    -0
      md/cps_pdd/goods.go
  2. +42
    -0
      pdd_union/goods.go

+ 58
- 0
md/cps_pdd/goods.go Ver arquivo

@@ -1,5 +1,63 @@
package cps_pdd

type RecommendGoods struct {
GoodsBasicDetailResponse struct {
List []struct {
ActivityPromotionRate int `json:"activity_promotion_rate"`
ActivityTags []int `json:"activity_tags"`
BrandName string `json:"brand_name"`
CashGiftAmount int `json:"cash_gift_amount"`
CatId string `json:"cat_id"`
CatIds []int `json:"cat_ids"`
CouponDiscount int `json:"coupon_discount"`
CouponEndTime int `json:"coupon_end_time"`
CouponMinOrderAmount int `json:"coupon_min_order_amount"`
CouponPrice int `json:"coupon_price"`
CouponRemainQuantity int `json:"coupon_remain_quantity"`
CouponStartTime int `json:"coupon_start_time"`
CouponTotalQuantity int `json:"coupon_total_quantity"`
CreateAt int `json:"create_at"`
DescTxt string `json:"desc_txt"`
ExtraCouponAmount int `json:"extra_coupon_amount"`
GoodsDesc string `json:"goods_desc"`
GoodsImageUrl string `json:"goods_image_url"`
GoodsLabels []int `json:"goods_labels"`
GoodsName string `json:"goods_name"`
GoodsRate int `json:"goods_rate"`
GoodsSign string `json:"goods_sign"`
GoodsThumbnailUrl string `json:"goods_thumbnail_url"`
GoodsType int `json:"goods_type"`
HasCoupon bool `json:"has_coupon"`
HasMaterial bool `json:"has_material"`
LgstTxt string `json:"lgst_txt"`
MallId int `json:"mall_id"`
MallName string `json:"mall_name"`
MarketFee int `json:"market_fee"`
MerchantType string `json:"merchant_type"`
MinGroupPrice int `json:"min_group_price"`
MinNormalPrice int `json:"min_normal_price"`
OptId string `json:"opt_id"`
OptIds []int `json:"opt_ids"`
OptName string `json:"opt_name"`
PredictPromotionRate int `json:"predict_promotion_rate"`
PromotionRate int `json:"promotion_rate"`
QrCodeImageUrl string `json:"qr_code_image_url"`
RealtimeSalesTip string `json:"realtime_sales_tip"`
SalesTip string `json:"sales_tip"`
SearchId string `json:"search_id"`
ServTxt string `json:"serv_txt"`
ShareDesc string `json:"share_desc"`
ShareRate int `json:"share_rate"`
SubsidyAmount int `json:"subsidy_amount"`
SubsidyDuoAmountTenMillion int `json:"subsidy_duo_amount_ten_million"`
SubsidyGoodsType int `json:"subsidy_goods_type"`
UnifiedTags []string `json:"unified_tags"`
} `json:"list"`
ListId string `json:"list_id"`
SearchId string `json:"search_id"`
Total int `json:"total"`
} `json:"goods_basic_detail_response"`
}
type SearchGoods struct {
GoodsSearchResponse struct {
GoodsList []struct {


+ 42
- 0
pdd_union/goods.go Ver arquivo

@@ -7,6 +7,48 @@ import (
"strings"
)

func GetRecommendGoods(keyArr map[string]string, param map[string]interface{}) []map[string]string {
send, _ := Send(keyArr, "pdd.ddk.oauth.goods.recommend.get", param)
var res cps_pdd.RecommendGoods
json.Unmarshal([]byte(send), &res)
data := make([]map[string]string, 0)
for _, v := range res.GoodsBasicDetailResponse.List {
tmp := make(map[string]string)
tmp["gid"] = v.GoodsSign
tmp["goods_title"] = v.GoodsName
tmp["commission"] = zhios_third_party_utils.Float64ToStr(float64(v.PromotionRate) / 10)
tmp["coupon_start_time"] = "0"
tmp["coupon_end_time"] = "0"
if v.CouponStartTime > 0 {
tmp["coupon_start_time"] = zhios_third_party_utils.IntToStr(v.CouponStartTime)
}
if v.CouponEndTime > 0 {
tmp["coupon_end_time"] = zhios_third_party_utils.IntToStr(v.CouponEndTime)
}
tmp["coupon_price"] = zhios_third_party_utils.Float64ToStr(float64(v.CouponDiscount) / 100)
tmp["shop_name"] = v.MallName
tmp["mall_id"] = zhios_third_party_utils.IntToStr(v.MallId)
tmp["min_normal_price"] = zhios_third_party_utils.Float64ToStr(float64(v.MinNormalPrice) / 100)
tmp["min_group_price"] = zhios_third_party_utils.Float64ToStr(float64(v.MinGroupPrice) / 100)
//销量处理
tmp["goods_sales"] = v.SalesTip
if strings.Contains(tmp["goods_sales"], "万+") {
tmp["goods_sales"] = strings.ReplaceAll(tmp["goods_sales"], "万+", "")
tmp["goods_sales"] = zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.StrToFloat64(tmp["goods_sales"]) * 10000)
}
if strings.Contains(tmp["goods_sales"], "万") {
tmp["goods_sales"] = strings.ReplaceAll(tmp["goods_sales"], "万", "")
tmp["goods_sales"] = zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.StrToFloat64(tmp["goods_sales"]) * 10000)
}
tmp["goods_img"] = v.GoodsImageUrl
tmp["goods_min_img"] = v.GoodsThumbnailUrl
tmp["goods_desc"] = v.GoodsDesc
tmp["goods_sign"] = v.GoodsSign
data = append(data, tmp)
}
return data
}

func GetSearchGoods(keyArr map[string]string, param map[string]interface{}) []map[string]string {
send, _ := Send(keyArr, "pdd.ddk.oauth.goods.search", param)
var res cps_pdd.SearchGoods


Carregando…
Cancelar
Salvar