@@ -6,6 +6,7 @@ import ( | |||||
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/db/offical" | "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/db/offical" | ||||
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/haodanku" | "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/haodanku" | ||||
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/jd" | "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/jd" | ||||
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/lib/cps_jd" | |||||
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md" | "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md" | ||||
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/pdd" | "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/pdd" | ||||
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/taobao" | "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/taobao" | ||||
@@ -132,8 +133,7 @@ func TBOrTmTurnChain(eg *xorm.Engine, officialEg *xorm.Engine, dbName string, ar | |||||
//京东转链 | //京东转链 | ||||
func JDTurnChain(eg *xorm.Engine, dbName string, args map[string]string) (*md.ConvertedUrls, error) { | func JDTurnChain(eg *xorm.Engine, dbName string, args map[string]string) (*md.ConvertedUrls, error) { | ||||
pid := args["acc_jd_share_id"] | pid := args["acc_jd_share_id"] | ||||
urls, err := zhimeng.JDConvertUrl( | |||||
db.SysCfgGetWithDb(eg, dbName, md.KEY_CFG_ZM_AK), | |||||
urls, err := cps_jd.JdUrl(eg, dbName, args["uid"], "3", db.SysCfgGetWithDb(eg, dbName, md.KEY_CFG_ZM_AK), | |||||
db.SysCfgGetWithDb(eg, dbName, md.KEY_CFG_ZM_SK), | db.SysCfgGetWithDb(eg, dbName, md.KEY_CFG_ZM_SK), | ||||
args["gid"], | args["gid"], | ||||
pid, | pid, | ||||
@@ -294,21 +294,14 @@ func ConvertUrl(eg *xorm.Engine, officialEg *xorm.Engine, args map[string]string | |||||
postData["gid"] = args["gid"] | postData["gid"] = args["gid"] | ||||
postData["appkey"] = thirdZmAppKeyData.Val | postData["appkey"] = thirdZmAppKeyData.Val | ||||
postData["secret_key"] = thirdZmAppSecretData.Val | postData["secret_key"] = thirdZmAppSecretData.Val | ||||
jdData, err := zhimeng.NewZhiMengJingDongSDK(). | |||||
SelectFunction("getgoodsinfo"). | |||||
WithArgs(postData). | |||||
Result() | |||||
mdData := &md.MoreDetailResponse{} | |||||
// to struct | |||||
couponUrl := "" | couponUrl := "" | ||||
couponPrice := "" | couponPrice := "" | ||||
err = jdData.ToStruct(mdData) | |||||
mdData, err := cps_jd.JdDetailGoods(eg, args["master_id"], postData) | |||||
if err == nil && mdData != nil && mdData.CouponURL != "" { | if err == nil && mdData != nil && mdData.CouponURL != "" { | ||||
couponUrl = mdData.CouponURL | couponUrl = mdData.CouponURL | ||||
couponPrice = mdData.CouponPrice | couponPrice = mdData.CouponPrice | ||||
} | } | ||||
urls, err = zhimeng.JDConvertUrl( | |||||
thirdZmAppKeyData.Val, | |||||
urls, err = cps_jd.JdUrl(eg, args["master_id"], args["uid"], "3", thirdZmAppKeyData.Val, | |||||
thirdZmAppSecretData.Val, | thirdZmAppSecretData.Val, | ||||
args["gid"], | args["gid"], | ||||
pid, | pid, | ||||
@@ -1260,54 +1253,86 @@ func JDByGoodsId(eg *xorm.Engine, officialEg *xorm.Engine, tmp map[string]string | |||||
var err error | var err error | ||||
ClickUrl := "" | ClickUrl := "" | ||||
isNull := "" | isNull := "" | ||||
if zhios_third_party_utils.StrToInt(goodsId) > 0 { | |||||
postData["gid"] = goodsId | |||||
jdData, err = jd.NewZhiMengJingDongSDK(). | |||||
SelectFunction("getgoodsinfo"). | |||||
WithArgs(postData). | |||||
Result() | |||||
auth, _ := db.SysUnionByJdByUseByAuth(eg, tmp["master_id"]) | |||||
if auth != nil { | |||||
postData["union_type"] = zhios_third_party_utils.IntToStr(auth.AuthType) | |||||
} | |||||
if postData["union_type"] == "2" { | |||||
if zhios_third_party_utils.StrToInt(goodsId) > 0 { | |||||
postData["gid"] = goodsId | |||||
mdData, err = cps_jd.JdDetailGoods(eg, tmp["master_id"], postData) | |||||
} else { | |||||
curls, _ := OfficialRecommendUrl(eg, tmp, "jd", 1, 0, 0, 0, "", "1", 0, url) | |||||
if curls != nil && curls.Url != "" { | |||||
fmt.Println("===zhe1", time.Since(now)) | |||||
ClickUrl = curls.Url | |||||
//parse, _ = taoke.DaTaoKeContentParse(curls.Url) | |||||
postData["keyword"] = url | |||||
postData["size"] = "2" | |||||
postData["p"] = "1" | |||||
postData["is_url"] = "1" | |||||
mdData, err = cps_jd.JdSearchGoodsUrl(eg, tmp["master_id"], postData) | |||||
fmt.Println("===zhe2", time.Since(now)) | |||||
} else { | |||||
isNull = "1" | |||||
} | |||||
} | |||||
if mdData == nil { | |||||
if ClickUrl != "" { | |||||
return &md.ProductDetailResponse{ClickUrl: ClickUrl}, md.PVD_JD, "", "" | |||||
} | |||||
return &md.ProductDetailResponse{IsNull: isNull}, md.PVD_JD, "", "" | |||||
} | |||||
} else { | } else { | ||||
curls, _ := OfficialRecommendUrl(eg, tmp, "jd", 1, 0, 0, 0, "", "1", 0, url) | |||||
if curls != nil && curls.Url != "" { | |||||
fmt.Println("===zhe1", time.Since(now)) | |||||
ClickUrl = curls.Url | |||||
//parse, _ = taoke.DaTaoKeContentParse(curls.Url) | |||||
postData["keyword"] = url | |||||
postData["size"] = "2" | |||||
postData["p"] = "1" | |||||
postData["is_url"] = "1" | |||||
if zhios_third_party_utils.StrToInt(goodsId) > 0 { | |||||
postData["gid"] = goodsId | |||||
jdData, err = jd.NewZhiMengJingDongSDK(). | jdData, err = jd.NewZhiMengJingDongSDK(). | ||||
SelectFunction("new_getgoods"). | |||||
SelectFunction("getgoodsinfo"). | |||||
WithArgs(postData). | WithArgs(postData). | ||||
Result() | Result() | ||||
fmt.Println("===zhe2", time.Since(now)) | |||||
} else { | } else { | ||||
isNull = "1" | |||||
curls, _ := OfficialRecommendUrl(eg, tmp, "jd", 1, 0, 0, 0, "", "1", 0, url) | |||||
if curls != nil && curls.Url != "" { | |||||
fmt.Println("===zhe1", time.Since(now)) | |||||
ClickUrl = curls.Url | |||||
//parse, _ = taoke.DaTaoKeContentParse(curls.Url) | |||||
postData["keyword"] = url | |||||
postData["size"] = "2" | |||||
postData["p"] = "1" | |||||
postData["is_url"] = "1" | |||||
jdData, err = jd.NewZhiMengJingDongSDK(). | |||||
SelectFunction("new_getgoods"). | |||||
WithArgs(postData). | |||||
Result() | |||||
fmt.Println("===zhe2", time.Since(now)) | |||||
} else { | |||||
isNull = "1" | |||||
} | |||||
} | } | ||||
} | |||||
if jdData == nil { | |||||
if ClickUrl != "" { | |||||
return &md.ProductDetailResponse{ClickUrl: ClickUrl}, md.PVD_JD, "", "" | |||||
if jdData == nil { | |||||
if ClickUrl != "" { | |||||
return &md.ProductDetailResponse{ClickUrl: ClickUrl}, md.PVD_JD, "", "" | |||||
} | |||||
return &md.ProductDetailResponse{IsNull: isNull}, md.PVD_JD, "", "" | |||||
} | |||||
// scrap detail image | |||||
if zhios_third_party_utils.StrToInt(goodsId) > 0 { | |||||
jdData.WithJDDetailImageList(goodsId) | |||||
} | } | ||||
return &md.ProductDetailResponse{IsNull: isNull}, md.PVD_JD, "", "" | |||||
} | |||||
// scrap detail image | |||||
if zhios_third_party_utils.StrToInt(goodsId) > 0 { | |||||
jdData.WithJDDetailImageList(goodsId) | |||||
} | |||||
if err != nil { | |||||
//e.OutErr(c, e.ERR_API_RESPONSE, e.NewErr(400, "商品已下架")) | |||||
return nil, "", "", "" | |||||
} | |||||
// to struct | |||||
err = jdData.ToStruct(mdData) | |||||
if err != nil { | |||||
//e.OutErr(c, e.ERR_INVALID_ARGS, err) | |||||
return nil, "", "", "" | |||||
} | |||||
if err != nil { | |||||
//e.OutErr(c, e.ERR_API_RESPONSE, e.NewErr(400, "商品已下架")) | |||||
return nil, "", "", "" | |||||
} | |||||
// to struct | |||||
err = jdData.ToStruct(mdData) | |||||
if err != nil { | |||||
//e.OutErr(c, e.ERR_INVALID_ARGS, err) | |||||
return nil, "", "", "" | |||||
} | |||||
} | |||||
if mdData != nil { | if mdData != nil { | ||||
if mdData.GID == "100038437991" || strings.Contains(mdData.GoodsTitle, "Apple iPhone") { | if mdData.GID == "100038437991" || strings.Contains(mdData.GoodsTitle, "Apple iPhone") { | ||||
return nil, "", "", "" | return nil, "", "", "" | ||||
@@ -6,6 +6,21 @@ import ( | |||||
"xorm.io/xorm" | "xorm.io/xorm" | ||||
) | ) | ||||
func SysUnionByJdByUseByAuth(Db *xorm.Engine, masterId string) (*model.SysUnionSet, error) { | |||||
var ( | |||||
m model.SysUnionSet | |||||
) | |||||
has, err := Db.Where("provider = 'jd' AND is_use = 1 ").Get(&m) | |||||
if err != nil { | |||||
return nil, err | |||||
} | |||||
if !has { | |||||
return nil, errors.New("找不到联盟设置") | |||||
} | |||||
return &m, nil | |||||
} | |||||
// SysUnionByTaobaoByUseByAuth is 正在使用Taobao且已授权的设置 | // SysUnionByTaobaoByUseByAuth is 正在使用Taobao且已授权的设置 | ||||
func SysUnionByTaobaoByUseByAuth(Db *xorm.Engine, masterId string) (*model.SysUnionSet, error) { | func SysUnionByTaobaoByUseByAuth(Db *xorm.Engine, masterId string) (*model.SysUnionSet, error) { | ||||
var ( | var ( | ||||
@@ -0,0 +1,128 @@ | |||||
package cps_jd | |||||
import ( | |||||
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/db" | |||||
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/jd" | |||||
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/jd_union" | |||||
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md" | |||||
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md/cps_jd" | |||||
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" | |||||
"time" | |||||
"xorm.io/xorm" | |||||
) | |||||
func JdUnionComm() map[string]string { | |||||
keyArr := map[string]string{ | |||||
"app_key": "444ab671c4d095122916453d09af27fc", | |||||
"access_token": "", | |||||
"app_secret": "aef3c2745cc44194816d0c89c65b3847", | |||||
} | |||||
return keyArr | |||||
} | |||||
func JdDetailGoods(eg *xorm.Engine, dbName string, postData map[string]interface{}) (*md.MoreDetailResponse, error) { | |||||
auth, _ := db.SysUnionByJdByUseByAuth(eg, dbName) | |||||
if auth != nil { | |||||
postData["union_type"] = zhios_third_party_utils.IntToStr(auth.AuthType) | |||||
} | |||||
var r md.MoreDetailResponse | |||||
if postData["union_type"] == "2" { | |||||
param := map[string]interface{}{} | |||||
if php2go.IsNumeric(postData["gid"]) { | |||||
param["skuIds"] = []string{zhios_third_party_utils.AnyToString(postData["gid"])} | |||||
} else { | |||||
param["itemIds"] = []string{zhios_third_party_utils.AnyToString(postData["gid"])} | |||||
} | |||||
keyArr := JdUnionComm() | |||||
goods, err := jd_union.SearchGoods(keyArr, param) | |||||
if err != nil { | |||||
return nil, err | |||||
} | |||||
resp := gjson.Get(goods, "jd_union_open_goods_query_responce.queryResult").String() | |||||
var data cps_jd.JdSearchGoods | |||||
err = json.Unmarshal([]byte(resp), &data) | |||||
if err != nil { | |||||
return nil, err | |||||
} | |||||
if len(data.Data) == 0 { | |||||
return nil, errors.New("商品下架") | |||||
} | |||||
var tmpData md.JDZhimengItem | |||||
for _, v := range data.Data { | |||||
imgList := make([]string, 0) | |||||
img := "" | |||||
for k1, v1 := range v.ImageInfo.ImageList { | |||||
imgList = append(imgList, v1.Url) | |||||
if k1 == 0 { | |||||
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, | |||||
CouponURL: "", | |||||
EndTime: 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, | |||||
ShopName: v.ShopInfo.ShopName, | |||||
StartTime: int(time.Now().Unix()), | |||||
StoreID: "0", | |||||
WlGoodsPrice: v.PriceInfo.Price, | |||||
} | |||||
if tmp.LowerPrice > 0 { | |||||
tmp.PcGoodsPrice = tmp.LowerPrice | |||||
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.CouponURL = v1.Link | |||||
max = v1.Discount | |||||
} | |||||
} | |||||
} | |||||
tmpData = tmp | |||||
} | |||||
copier.Copy(&r, &tmpData) | |||||
} else { | |||||
jdData, err := jd.NewZhiMengJingDongSDK(). | |||||
SelectFunction("getgoodsinfo"). | |||||
WithArgs(postData). | |||||
Result() | |||||
if err != nil { | |||||
return nil, errors.New("商品下架") | |||||
} | |||||
// to struct | |||||
err = jdData.ToStruct(&r) | |||||
if err != nil { | |||||
return nil, err | |||||
} | |||||
} | |||||
return &r, nil | |||||
} |
@@ -0,0 +1,120 @@ | |||||
package cps_jd | |||||
import ( | |||||
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/db" | |||||
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/jd" | |||||
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/jd_union" | |||||
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md" | |||||
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md/cps_jd" | |||||
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/tidwall/gjson" | |||||
"strings" | |||||
"time" | |||||
"xorm.io/xorm" | |||||
) | |||||
func JdSearchGoodsUrl(eg *xorm.Engine, dbName string, postData map[string]interface{}) (*md.MoreDetailResponse, error) { | |||||
auth, _ := db.SysUnionByJdByUseByAuth(eg, dbName) | |||||
if auth != nil { | |||||
postData["union_type"] = zhios_third_party_utils.IntToStr(auth.AuthType) | |||||
} | |||||
var r md.MoreDetailResponse | |||||
if postData["union_type"] == "2" { | |||||
param := map[string]interface{}{ | |||||
"pageIndex": postData["p"], | |||||
"pageSize": postData["size"], | |||||
"keyword": postData["keyword"], | |||||
} | |||||
keyArr := JdUnionComm() | |||||
goods, err := jd_union.SearchGoods(keyArr, param) | |||||
if err != nil { | |||||
return nil, err | |||||
} | |||||
resp := gjson.Get(goods, "jd_union_open_goods_query_responce.queryResult").String() | |||||
var data cps_jd.JdSearchGoods | |||||
err = json.Unmarshal([]byte(resp), &data) | |||||
if err != nil { | |||||
return nil, err | |||||
} | |||||
if len(data.Data) == 0 || len(data.Data) > 1 { | |||||
return nil, nil | |||||
} | |||||
var tmpData md.JDZhimengItem | |||||
for _, v := range data.Data { | |||||
imgList := make([]string, 0) | |||||
img := "" | |||||
for k1, v1 := range v.ImageInfo.ImageList { | |||||
imgList = append(imgList, v1.Url) | |||||
if k1 == 0 { | |||||
img = v1.Url | |||||
} | |||||
} | |||||
var tmp = md.JDZhimengItem{ | |||||
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, | |||||
CouponURL: "", | |||||
EndTime: 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, | |||||
ShopName: v.ShopInfo.ShopName, | |||||
StartTime: int(time.Now().Unix()), | |||||
StoreID: "0", | |||||
WlGoodsPrice: v.PriceInfo.Price, | |||||
} | |||||
if tmp.LowerPrice > 0 { | |||||
tmp.PcGoodsPrice = tmp.LowerPrice | |||||
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.CouponURL = v1.Link | |||||
max = v1.Discount | |||||
} | |||||
} | |||||
} | |||||
tmpData = tmp | |||||
} | |||||
copier.Copy(&r, &tmpData) | |||||
return &r, nil | |||||
} else { | |||||
jdData, err := jd.NewZhiMengJingDongSDK(). | |||||
SelectFunction("new_getgoods"). | |||||
WithArgs(postData). | |||||
Result() | |||||
if jdData == nil { | |||||
return nil, errors.New("商品已下架") | |||||
} | |||||
if err == nil { | |||||
itemInfo := &md.MoreDetailResponse{} | |||||
if err := jdData.ToStruct(itemInfo); err != nil { | |||||
return nil, err | |||||
} | |||||
return itemInfo, nil | |||||
} else { | |||||
return nil, errors.New("商品已下架") | |||||
} | |||||
} | |||||
return nil, nil | |||||
} |
@@ -0,0 +1,85 @@ | |||||
package cps_jd | |||||
import ( | |||||
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/db" | |||||
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/jd_union" | |||||
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md" | |||||
zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils" | |||||
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/zhimeng" | |||||
"errors" | |||||
"github.com/tidwall/gjson" | |||||
"xorm.io/xorm" | |||||
) | |||||
func JdUrl(eg *xorm.Engine, dbName string, uid string, buyType string, appkey, appsecret, itemId, promoId, couponUrl, couponPrice, activityUrl string) (*md.ConvertedUrls, error) { | |||||
auth, _ := db.SysUnionByJdByUseByAuth(eg, dbName) | |||||
var urls *md.ConvertedUrls | |||||
var err error | |||||
unionType := 0 | |||||
if auth != nil { | |||||
unionType = auth.AuthType | |||||
} | |||||
if unionType == 2 { | |||||
url := itemId | |||||
if activityUrl != "" { | |||||
url = activityUrl | |||||
} | |||||
req := map[string]interface{}{ | |||||
"materialId": url, | |||||
"unionId": gjson.Get(auth.KeyData, "apiAppId").String(), | |||||
"positionId": uid + "0" + dbName + "0" + buyType, | |||||
"chainType": "3", | |||||
} | |||||
if couponUrl != "" { | |||||
req["couponUrl"] = couponUrl | |||||
} | |||||
urls, err = JdUnionUrl(req) | |||||
if urls != nil { | |||||
urls.HasCoupon = false | |||||
if couponUrl != "" { | |||||
urls.HasCoupon = true | |||||
} | |||||
urls.CommissionRate = couponPrice | |||||
urls.ItemId = itemId | |||||
} | |||||
} else { | |||||
urls, err = zhimeng.JDConvertUrl( | |||||
appkey, | |||||
appsecret, | |||||
itemId, | |||||
promoId, | |||||
couponUrl, | |||||
couponPrice, | |||||
activityUrl) | |||||
} | |||||
return urls, err | |||||
} | |||||
func JdUnionUrl(goodsReq map[string]interface{}) (*md.ConvertedUrls, error) { | |||||
param := map[string]interface{}{ | |||||
"promotionCodeReq": goodsReq, | |||||
} | |||||
keyArr := JdUnionComm() | |||||
paramJson := zhios_third_party_utils.SerializeStr(param) | |||||
send, err := jd_union.SendGet(keyArr, "jd.union.open.promotion.byunionid.get", paramJson, "1.0") | |||||
var urls md.ConvertedUrls | |||||
if err != nil { | |||||
return nil, err | |||||
} | |||||
if send == "" { | |||||
return nil, errors.New("转链失败") | |||||
} | |||||
resp := gjson.Get(send, "jd_union_open_promotion_byunionid_get_responce.getResult").String() | |||||
code := gjson.Get(resp, "code").Int() | |||||
if code != 200 { | |||||
return nil, errors.New(gjson.Get(resp, "message").String()) | |||||
} | |||||
urls = md.ConvertedUrls{ | |||||
URL: gjson.Get(resp, "data.shortURL").String(), | |||||
ShortenURL: gjson.Get(resp, "data.shortURL").String(), | |||||
NoOpenAppURL: gjson.Get(resp, "data.shortURL").String(), | |||||
AppURL: gjson.Get(resp, "data.shortURL").String(), | |||||
ClickUrl: gjson.Get(resp, "data.url").String(), | |||||
} | |||||
return &urls, nil | |||||
} |
@@ -0,0 +1,108 @@ | |||||
package cps_jd | |||||
type JdSearchGoods struct { | |||||
Code int `json:"code"` | |||||
Data []struct { | |||||
BrandCode string `json:"brandCode"` | |||||
BrandName string `json:"brandName"` | |||||
CategoryInfo struct { | |||||
Cid1 int `json:"cid1"` | |||||
Cid1Name string `json:"cid1Name"` | |||||
Cid2 int `json:"cid2"` | |||||
Cid2Name string `json:"cid2Name"` | |||||
Cid3 int `json:"cid3"` | |||||
Cid3Name string `json:"cid3Name"` | |||||
} `json:"categoryInfo"` | |||||
Comments int `json:"comments"` | |||||
CommissionInfo struct { | |||||
Commission float64 `json:"commission"` | |||||
CommissionShare float64 `json:"commissionShare"` | |||||
CouponCommission float64 `json:"couponCommission"` | |||||
EndTime int64 `json:"endTime"` | |||||
IsLock int `json:"isLock"` | |||||
PlusCommissionShare float64 `json:"plusCommissionShare"` | |||||
StartTime int64 `json:"startTime"` | |||||
} `json:"commissionInfo"` | |||||
CouponInfo struct { | |||||
CouponList []struct { | |||||
BindType int `json:"bindType"` | |||||
CouponStyle int `json:"couponStyle"` | |||||
Discount float64 `json:"discount"` | |||||
GetEndTime int64 `json:"getEndTime"` | |||||
GetStartTime int64 `json:"getStartTime"` | |||||
IsBest int `json:"isBest"` | |||||
IsInputCoupon int `json:"isInputCoupon"` | |||||
Link string `json:"link"` | |||||
PlatformType int `json:"platformType"` | |||||
Quota float64 `json:"quota"` | |||||
UseEndTime int64 `json:"useEndTime"` | |||||
UseStartTime int64 `json:"useStartTime"` | |||||
HotValue int `json:"hotValue,omitempty"` | |||||
} `json:"couponList"` | |||||
} `json:"couponInfo"` | |||||
DeliveryType int `json:"deliveryType"` | |||||
EliteType []int `json:"eliteType,omitempty"` | |||||
ForbidTypes []int `json:"forbidTypes"` | |||||
GoodCommentsShare float64 `json:"goodCommentsShare"` | |||||
ImageInfo struct { | |||||
ImageList []struct { | |||||
Url string `json:"url"` | |||||
} `json:"imageList"` | |||||
WhiteImage string `json:"whiteImage,omitempty"` | |||||
} `json:"imageInfo"` | |||||
InOrderComm30Days float64 `json:"inOrderComm30Days"` | |||||
InOrderCount30Days int `json:"inOrderCount30Days"` | |||||
IsHot int `json:"isHot"` | |||||
IsJdSale int `json:"isJdSale"` | |||||
IsOversea int `json:"isOversea"` | |||||
ItemId string `json:"itemId"` | |||||
MaterialUrl string `json:"materialUrl"` | |||||
Owner string `json:"owner"` | |||||
PinGouInfo struct { | |||||
} `json:"pinGouInfo"` | |||||
PingGouInfo struct { | |||||
} `json:"pingGouInfo"` | |||||
PriceInfo struct { | |||||
HistoryPriceDay int `json:"historyPriceDay,omitempty"` | |||||
LowestCouponPrice float64 `json:"lowestCouponPrice"` | |||||
LowestPrice float64 `json:"lowestPrice"` | |||||
LowestPriceType int `json:"lowestPriceType"` | |||||
Price float64 `json:"price"` | |||||
} `json:"priceInfo"` | |||||
ShopInfo struct { | |||||
AfsFactorScoreRankGrade string `json:"afsFactorScoreRankGrade,omitempty"` | |||||
AfterServiceScore string `json:"afterServiceScore,omitempty"` | |||||
CommentFactorScoreRankGrade string `json:"commentFactorScoreRankGrade,omitempty"` | |||||
LogisticsFactorScoreRankGrade string `json:"logisticsFactorScoreRankGrade,omitempty"` | |||||
LogisticsLvyueScore string `json:"logisticsLvyueScore,omitempty"` | |||||
ScoreRankRate string `json:"scoreRankRate,omitempty"` | |||||
ShopId int `json:"shopId"` | |||||
ShopLabel string `json:"shopLabel"` | |||||
ShopLevel float64 `json:"shopLevel"` | |||||
ShopName string `json:"shopName"` | |||||
UserEvaluateScore string `json:"userEvaluateScore,omitempty"` | |||||
} `json:"shopInfo"` | |||||
SkuId int64 `json:"skuId"` | |||||
SkuName string `json:"skuName"` | |||||
Spuid int64 `json:"spuid"` | |||||
VideoInfo struct { | |||||
VideoList []struct { | |||||
Duration int `json:"duration"` | |||||
High int `json:"high"` | |||||
ImageUrl string `json:"imageUrl"` | |||||
PlayType string `json:"playType"` | |||||
PlayUrl string `json:"playUrl"` | |||||
VideoType int `json:"videoType"` | |||||
Width int `json:"width"` | |||||
} `json:"videoList,omitempty"` | |||||
} `json:"videoInfo"` | |||||
JxFlags []int `json:"jxFlags,omitempty"` | |||||
SecondPriceInfoList []struct { | |||||
SecondPrice float64 `json:"secondPrice"` | |||||
SecondPriceType int `json:"secondPriceType"` | |||||
} `json:"secondPriceInfoList,omitempty"` | |||||
} `json:"data"` | |||||
Message string `json:"message"` | |||||
RequestId string `json:"requestId"` | |||||
TotalCount int `json:"totalCount"` | |||||
} |
@@ -1,6 +1,7 @@ | |||||
package md | package md | ||||
type JDZhimengItem struct { | type JDZhimengItem struct { | ||||
SkuId interface{} `json:"sku_id"` | |||||
Cid1 int `json:"cid1"` | Cid1 int `json:"cid1"` | ||||
Cid1Name string `json:"cid1_name"` | Cid1Name string `json:"cid1_name"` | ||||
Cid2 int `json:"cid2"` | Cid2 int `json:"cid2"` | ||||
@@ -0,0 +1 @@ | |||||
package pdd_union |