Explorar el Código

京东联盟

master
huangjiajun hace 5 meses
padre
commit
6654009a9f
Se han modificado 1 ficheros con 21 adiciones y 30 borrados
  1. +21
    -30
      lib/cps_jd/svc_detail.go

+ 21
- 30
lib/cps_jd/svc_detail.go Ver fichero

@@ -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").


Cargando…
Cancelar
Guardar