aa
This commit is contained in:
@@ -3,6 +3,7 @@ package cms
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals/api/apimanager"
|
||||||
"io"
|
"io"
|
||||||
"math"
|
"math"
|
||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
@@ -1619,6 +1620,10 @@ func GetJdUpcCodeByCode(ctx *jxcontext.Context, upcCode string) (productInfos []
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetJdUpcCodeByName(ctx *jxcontext.Context, name, upcCode string) (productInfos []*jdapi.ProductInfo, err error) {
|
func GetJdUpcCodeByName(ctx *jxcontext.Context, name, upcCode string) (productInfos []*jdapi.ProductInfo, err error) {
|
||||||
|
var (
|
||||||
|
apijd = apimanager.CurAPIManager.GetAPI(model.VendorIDJD, "320406").(*jdapi.API)
|
||||||
|
productInfo []*jdapi.ProductInfo
|
||||||
|
)
|
||||||
if name != "" {
|
if name != "" {
|
||||||
var (
|
var (
|
||||||
pageNo = 5
|
pageNo = 5
|
||||||
@@ -1634,7 +1639,7 @@ func GetJdUpcCodeByName(ctx *jxcontext.Context, name, upcCode string) (productIn
|
|||||||
task := tasksch.NewParallelTask("获取京东商品", tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx,
|
task := tasksch.NewParallelTask("获取京东商品", tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx,
|
||||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
pageNum := batchItemList[0].(int)
|
pageNum := batchItemList[0].(int)
|
||||||
productInfo, err := api.JdAPI.GetJdUpcCodeByName(name, upcCode, pageNum, pageSize)
|
productInfo, err = apijd.GetJdUpcCodeByName(name, upcCode, pageNum, pageSize)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return retVal, err
|
return retVal, err
|
||||||
}
|
}
|
||||||
@@ -1655,26 +1660,37 @@ func GetJdUpcCodeByName(ctx *jxcontext.Context, name, upcCode string) (productIn
|
|||||||
productInfos = append(productInfos, v.(*jdapi.ProductInfo))
|
productInfos = append(productInfos, v.(*jdapi.ProductInfo))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
productInfos, err = GetJdUpcCodeByCode(ctx, upcCode)
|
productInfo, err = apijd.GetJdUpcCodeByName("", upcCode, 1, 30)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for _, v := range productInfo {
|
||||||
|
_, name, _, specUnit, unit, specQuality := jxutils.SplitSkuName(v.OriginalName)
|
||||||
|
v.Name = name
|
||||||
|
v.SpecQuality = specQuality
|
||||||
|
v.SpecUnit = specUnit
|
||||||
|
v.Unit = unit
|
||||||
|
}
|
||||||
|
//productInfos, err = GetJdUpcCodeByCode(ctx, upcCode)
|
||||||
if len(productInfos) == 0 {
|
if len(productInfos) == 0 {
|
||||||
if configs, err := dao.QueryConfigs(dao.GetDB(), "mtwmCookieStr", model.ConfigTypeCookie, ""); err == nil {
|
if configs, err := dao.QueryConfigs(dao.GetDB(), "mtwmCookieStr", model.ConfigTypeCookie, ""); err == nil {
|
||||||
api.MtwmAPI.SetCookieWithStr(configs[0].Value)
|
api.MtwmAPI.SetCookieWithStr(configs[0].Value)
|
||||||
}
|
}
|
||||||
if result, err := api.MtwmAPI.GetStandardProductListWithCond(upcCode); err == nil && result != nil {
|
if result, err := api.MtwmAPI.GetStandardProductListWithCond(upcCode); err == nil && result != nil {
|
||||||
productInfo := &jdapi.ProductInfo{
|
productInfon := &jdapi.ProductInfo{
|
||||||
OriginalName: result.Name,
|
OriginalName: result.Name,
|
||||||
OriginalSpec: result.Spec,
|
OriginalSpec: result.Spec,
|
||||||
}
|
}
|
||||||
// _, name, _, specUnit, unit, specQuality := jxutils.SplitSkuName(productInfo.OriginalName)
|
// _, name, _, specUnit, unit, specQuality := jxutils.SplitSkuName(productInfo.OriginalName)
|
||||||
productInfo.Name = name
|
productInfon.Name = name
|
||||||
productInfo.SpecUnit = result.SpecUnit
|
productInfon.SpecUnit = result.SpecUnit
|
||||||
productInfo.Unit = result.Unit
|
productInfon.Unit = result.Unit
|
||||||
productInfo.SpecQuality = float32(result.SpecNew)
|
productInfon.SpecQuality = float32(result.SpecNew)
|
||||||
productInfo.ImgList = strings.Split(result.Pic, ",")
|
productInfon.ImgList = strings.Split(result.Pic, ",")
|
||||||
productInfo.Weight = float32(result.Weight)
|
productInfon.Weight = float32(result.Weight)
|
||||||
productInfo.Price = result.AvgPrice
|
productInfon.Price = result.AvgPrice
|
||||||
productInfo.BrandName = result.BrandNamePath
|
productInfon.BrandName = result.BrandNamePath
|
||||||
productInfos = append(productInfos, productInfo)
|
productInfos = append(productInfos, productInfon)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ type DepotKnowledge struct {
|
|||||||
ModelIDCULD
|
ModelIDCULD
|
||||||
|
|
||||||
Title string `json:"title"` //标题
|
Title string `json:"title"` //标题
|
||||||
Content string `json:"content"` //每条知识的内容
|
Content string `orm:"type(text)" json:"content"` //每条知识的内容
|
||||||
}
|
}
|
||||||
|
|
||||||
type DepotMedia struct {
|
type DepotMedia struct {
|
||||||
|
|||||||
@@ -46,9 +46,9 @@ func (a *APIManager) GetAPI(vendorID int, appOrgCode string) (pfAPI interface{})
|
|||||||
code := codes[0]
|
code := codes[0]
|
||||||
api.JdAPI = jdapi.New(code.Token, code.AppKey, code.AppSecret)
|
api.JdAPI = jdapi.New(code.Token, code.AppKey, code.AppSecret)
|
||||||
pfAPI = api.JdAPI
|
pfAPI = api.JdAPI
|
||||||
//if configs, err := dao.QueryConfigs(dao.GetDB(), "jdStorePageCookie", model.ConfigTypeCookie, ""); err == nil {
|
if configs, err := dao.QueryConfigs(dao.GetDB(), "jdStorePageCookie", model.ConfigTypeCookie, ""); err == nil {
|
||||||
// api.JdAPI.SetJdCookie(configs[0].Value)
|
api.JdAPI.SetCookieWithStr(configs[0].Value)
|
||||||
//}
|
}
|
||||||
if configs, err := dao.QueryConfigs(dao.GetDB(), "jdStorePageEarning", model.ConfigTypeCookie, ""); err == nil {
|
if configs, err := dao.QueryConfigs(dao.GetDB(), "jdStorePageEarning", model.ConfigTypeCookie, ""); err == nil {
|
||||||
api.JdAPI.SetCookie("user", configs[0].Value)
|
api.JdAPI.SetCookie("user", configs[0].Value)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user