From 6654009a9fdbb4fbe46c3e47a8a49014fe2decd2 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Sat, 18 May 2024 20:18:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=AC=E4=B8=9C=E8=81=94=E7=9B=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/cps_jd/svc_detail.go | 51 +++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 30 deletions(-) diff --git a/lib/cps_jd/svc_detail.go b/lib/cps_jd/svc_detail.go index 951e607..66689d1 100644 --- a/lib/cps_jd/svc_detail.go +++ b/lib/cps_jd/svc_detail.go @@ -9,7 +9,6 @@ import ( zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils" "encoding/json" "errors" - "github.com/jinzhu/copier" "github.com/syyongx/php2go" "github.com/tidwall/gjson" "strings" @@ -51,9 +50,9 @@ func JdDetailGoods(eg *xorm.Engine, dbName string, postData map[string]interface return nil, err } if len(data.Data) == 0 { - return nil, errors.New("商品下架") + return nil, errors.New("商品已下架") } - var tmpData md.JDZhimengItem + var tmpData md.MoreDetailResponse for _, v := range data.Data { imgList := make([]string, 0) img := "" @@ -63,44 +62,36 @@ func JdDetailGoods(eg *xorm.Engine, dbName string, postData map[string]interface img = v1.Url } } - var tmp = md.JDZhimengItem{ - SkuId: zhios_third_party_utils.Int64ToStr(v.SkuId), - Cid1: v.CategoryInfo.Cid1, - Cid1Name: v.CategoryInfo.Cid1Name, - Cid2: v.CategoryInfo.Cid2, - Cid2Name: v.CategoryInfo.Cid2Name, - Cid3: v.CategoryInfo.Cid3, - Cid3Name: v.CategoryInfo.Cid3Name, - CommissionRate: v.CommissionInfo.CommissionShare, + var tmp = md.MoreDetailResponse{ + CommissionRate: zhios_third_party_utils.Float64ToStr(v.CommissionInfo.CommissionShare), CouponURL: "", - EndTime: int(time.Now().Unix()) + 86400*365, - Gid: v.ItemId, + CouponPrice: "", + EndTime: zhios_third_party_utils.IntToStr(int(time.Now().Unix()) + 86400*365), + GID: v.ItemId, GoodsImg: img, GoodsTitle: strings.ReplaceAll(v.SkuName, "\t", ""), - ImgList: imgList, - InOrderCount: v.InOrderCount30Days, - IsFreeFreightRisk: 1, - IsFreeShipping: 1, - IsJdSale: v.IsJdSale, - LowerPrice: v.PriceInfo.LowestPrice, - LowerPriceType: v.PriceInfo.LowestPriceType, - LowestCouponPrice: v.PriceInfo.LowestCouponPrice, - PcGoodsPrice: v.PriceInfo.Price, - ShopID: v.ShopInfo.ShopId, + InOrderCount: zhios_third_party_utils.IntToStr(v.InOrderCount30Days), + LowerPrice: zhios_third_party_utils.Float64ToStr(v.PriceInfo.LowestPrice), + LowerPriceType: zhios_third_party_utils.IntToStr(v.PriceInfo.LowestPriceType), + LowestCouponPrice: zhios_third_party_utils.Float64ToStr(v.PriceInfo.LowestCouponPrice), + ShopID: zhios_third_party_utils.IntToStr(v.ShopInfo.ShopId), ShopName: v.ShopInfo.ShopName, - StartTime: int(time.Now().Unix()), + StartTime: zhios_third_party_utils.Int64ToStr(time.Now().Unix()), StoreID: "0", - WlGoodsPrice: v.PriceInfo.Price, + WlGoodsPrice: zhios_third_party_utils.Float64ToStr(v.PriceInfo.Price), + + GoodsImgList: imgList, + ImageList: imgList, + DetailImgList: imgList, } - if tmp.LowerPrice > 0 { - tmp.PcGoodsPrice = tmp.LowerPrice + if zhios_third_party_utils.StrToFloat64(tmp.LowerPrice) > 0 { tmp.WlGoodsPrice = tmp.LowerPrice } if len(v.CouponInfo.CouponList) > 0 { var max float64 = 0 for _, v1 := range v.CouponInfo.CouponList { if v1.Discount > max && v1.IsBest == 1 { - tmp.CouponPrice = int(v1.Discount) + tmp.CouponPrice = zhios_third_party_utils.Float64ToStr(v1.Discount) tmp.CouponURL = v1.Link max = v1.Discount } @@ -108,7 +99,7 @@ func JdDetailGoods(eg *xorm.Engine, dbName string, postData map[string]interface } tmpData = tmp } - copier.Copy(&r, &tmpData) + r = tmpData } else { jdData, err := jd.NewZhiMengJingDongSDK(). SelectFunction("getgoodsinfo").