diff --git a/pdd_union/goods.go b/pdd_union/goods.go index 405bbd6..3b24e50 100644 --- a/pdd_union/goods.go +++ b/pdd_union/goods.go @@ -48,13 +48,13 @@ func GetSearchGoods(keyArr map[string]string, param map[string]interface{}) []ma } return data } -func GetGoodsDetail(keyArr map[string]string, param map[string]interface{}) map[string]string { +func GetGoodsDetail(keyArr map[string]string, param map[string]interface{}) map[string]interface{} { send, _ := Send(keyArr, "pdd.ddk.oauth.goods.detail", param) var res cps_pdd.GoodsDetail json.Unmarshal([]byte(send), &res) - data := make(map[string]string) + data := make(map[string]interface{}) for _, v := range res.GoodsDetailResponse.GoodsDetails { - tmp := make(map[string]string) + tmp := make(map[string]interface{}) tmp["gid"] = v.GoodsSign tmp["goods_title"] = v.GoodsName tmp["commission"] = zhios_third_party_utils.Float64ToStr(float64(v.PromotionRate) / 10) @@ -73,18 +73,21 @@ func GetGoodsDetail(keyArr map[string]string, param map[string]interface{}) map[ 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(zhios_third_party_utils.AnyToString(tmp["goods_sales"]), "万+") { + tmp["goods_sales"] = strings.ReplaceAll(zhios_third_party_utils.AnyToString(tmp["goods_sales"]), "万+", "") + tmp["goods_sales"] = zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.StrToFloat64(zhios_third_party_utils.AnyToString(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) + if strings.Contains(zhios_third_party_utils.AnyToString(tmp["goods_sales"]), "万") { + tmp["goods_sales"] = strings.ReplaceAll(zhios_third_party_utils.AnyToString(tmp["goods_sales"]), "万", "") + tmp["goods_sales"] = zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.StrToFloat64(zhios_third_party_utils.AnyToString(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 + if len(v.GoodsThumbnailUrl) > 0 { + tmp["goods_img_list"] = v.GoodsThumbnailUrl + } data = tmp } return data