diff --git a/business/jxstore/cms/sku.go b/business/jxstore/cms/sku.go index 940328557..b9b6c4403 100644 --- a/business/jxstore/cms/sku.go +++ b/business/jxstore/cms/sku.go @@ -3,6 +3,7 @@ package cms import ( "errors" "fmt" + "git.rosy.net.cn/jx-callback/globals/api/apimanager" "io" "math" "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) { + var ( + apijd = apimanager.CurAPIManager.GetAPI(model.VendorIDJD, "320406").(*jdapi.API) + productInfo []*jdapi.ProductInfo + ) if name != "" { var ( pageNo = 5 @@ -1634,7 +1639,7 @@ func GetJdUpcCodeByName(ctx *jxcontext.Context, name, upcCode string) (productIn task := tasksch.NewParallelTask("获取京东商品", tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx, func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { pageNum := batchItemList[0].(int) - productInfo, err := api.JdAPI.GetJdUpcCodeByName(name, upcCode, pageNum, pageSize) + productInfo, err = apijd.GetJdUpcCodeByName(name, upcCode, pageNum, pageSize) if err != nil { return retVal, err } @@ -1655,26 +1660,37 @@ func GetJdUpcCodeByName(ctx *jxcontext.Context, name, upcCode string) (productIn productInfos = append(productInfos, v.(*jdapi.ProductInfo)) } } 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 configs, err := dao.QueryConfigs(dao.GetDB(), "mtwmCookieStr", model.ConfigTypeCookie, ""); err == nil { api.MtwmAPI.SetCookieWithStr(configs[0].Value) } if result, err := api.MtwmAPI.GetStandardProductListWithCond(upcCode); err == nil && result != nil { - productInfo := &jdapi.ProductInfo{ + productInfon := &jdapi.ProductInfo{ OriginalName: result.Name, OriginalSpec: result.Spec, } // _, name, _, specUnit, unit, specQuality := jxutils.SplitSkuName(productInfo.OriginalName) - productInfo.Name = name - productInfo.SpecUnit = result.SpecUnit - productInfo.Unit = result.Unit - productInfo.SpecQuality = float32(result.SpecNew) - productInfo.ImgList = strings.Split(result.Pic, ",") - productInfo.Weight = float32(result.Weight) - productInfo.Price = result.AvgPrice - productInfo.BrandName = result.BrandNamePath - productInfos = append(productInfos, productInfo) + productInfon.Name = name + productInfon.SpecUnit = result.SpecUnit + productInfon.Unit = result.Unit + productInfon.SpecQuality = float32(result.SpecNew) + productInfon.ImgList = strings.Split(result.Pic, ",") + productInfon.Weight = float32(result.Weight) + productInfon.Price = result.AvgPrice + productInfon.BrandName = result.BrandNamePath + productInfos = append(productInfos, productInfon) } } } diff --git a/business/model/message.go b/business/model/message.go index 8b5d87849..da226b818 100644 --- a/business/model/message.go +++ b/business/model/message.go @@ -86,8 +86,8 @@ func (*ImMessageRecord) TableIndex() [][]string { type DepotKnowledge struct { ModelIDCULD - Title string `json:"title"` //标题 - Content string `json:"content"` //每条知识的内容 + Title string `json:"title"` //标题 + Content string `orm:"type(text)" json:"content"` //每条知识的内容 } type DepotMedia struct { diff --git a/globals/api/apimanager/apimanager.go b/globals/api/apimanager/apimanager.go index 7693e6d44..806d13e57 100644 --- a/globals/api/apimanager/apimanager.go +++ b/globals/api/apimanager/apimanager.go @@ -46,9 +46,9 @@ func (a *APIManager) GetAPI(vendorID int, appOrgCode string) (pfAPI interface{}) code := codes[0] api.JdAPI = jdapi.New(code.Token, code.AppKey, code.AppSecret) pfAPI = api.JdAPI - //if configs, err := dao.QueryConfigs(dao.GetDB(), "jdStorePageCookie", model.ConfigTypeCookie, ""); err == nil { - // api.JdAPI.SetJdCookie(configs[0].Value) - //} + if configs, err := dao.QueryConfigs(dao.GetDB(), "jdStorePageCookie", model.ConfigTypeCookie, ""); err == nil { + api.JdAPI.SetCookieWithStr(configs[0].Value) + } if configs, err := dao.QueryConfigs(dao.GetDB(), "jdStorePageEarning", model.ConfigTypeCookie, ""); err == nil { api.JdAPI.SetCookie("user", configs[0].Value) }