根据名字查询upc码,获取京东等级修改
This commit is contained in:
@@ -1302,6 +1302,9 @@ func GetJdUpcCodeByName(ctx *jxcontext.Context, name, upcCode string) (productIn
|
||||
pageSize = 30
|
||||
pageNoList []int
|
||||
)
|
||||
if name == "" && upcCode == "" {
|
||||
return nil, fmt.Errorf("至少输入一个条件查询,商品名或者upc码!")
|
||||
}
|
||||
for i := 1; i < pageNo+1; i++ {
|
||||
pageNoList = append(pageNoList, i)
|
||||
}
|
||||
@@ -1312,6 +1315,16 @@ func GetJdUpcCodeByName(ctx *jxcontext.Context, name, upcCode string) (productIn
|
||||
if err != nil {
|
||||
return retVal, err
|
||||
}
|
||||
if len(productInfo) > 0 {
|
||||
for _, v := range productInfo {
|
||||
productInfo2, _ := api.ShowAPI.GetProductInfoByBarCode(v.UpcCode)
|
||||
if productInfo2 != nil {
|
||||
v.Name = productInfo2.Name
|
||||
v.SpecQuality = productInfo2.SpecQuality
|
||||
v.SpecUnit = productInfo2.SpecUnit
|
||||
}
|
||||
}
|
||||
}
|
||||
retVal = productInfo
|
||||
return retVal, err
|
||||
}, pageNoList)
|
||||
|
||||
@@ -36,6 +36,8 @@ type tJdStoreInfo struct {
|
||||
VendorStoreID string `orm:"column(vendor_store_id)"`
|
||||
RealLastOperator string
|
||||
SyncStatus int
|
||||
Level string
|
||||
PageNo int
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -91,7 +93,7 @@ func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorOrgCode, vendo
|
||||
}
|
||||
}
|
||||
}
|
||||
if level, err := a.GetJdStoreLevel(vendorOrgCode, vendorStoreID); err == nil {
|
||||
if level, err := GetJdStoreLevel(ctx, vendorOrgCode, vendorStoreID); err == nil {
|
||||
retVal.JdStoreLevel = level
|
||||
}
|
||||
if retVal.DistrictCode == 0 {
|
||||
@@ -118,6 +120,42 @@ func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorOrgCode, vendo
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func GetJdStoreLevel(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID string) (level string, err error) {
|
||||
var (
|
||||
pageNoList []int
|
||||
storeMap = make(map[int]string)
|
||||
pageNo int
|
||||
)
|
||||
a := getAPI(vendorOrgCode)
|
||||
for i := 1; i < 6; i++ {
|
||||
pageNoList = append(pageNoList, i)
|
||||
}
|
||||
task := tasksch.NewParallelTask("获取京东商品", tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
currentPage := batchItemList[0].(int)
|
||||
level, err = a.GetJdStoreLevel(vendorOrgCode, vendorStoreID, currentPage)
|
||||
if err != nil {
|
||||
return retVal, err
|
||||
}
|
||||
tJdStoreInfo1 := &tJdStoreInfo{
|
||||
Level: level,
|
||||
PageNo: currentPage,
|
||||
}
|
||||
retVal = []*tJdStoreInfo{tJdStoreInfo1}
|
||||
return retVal, err
|
||||
}, pageNoList)
|
||||
tasksch.HandleTask(task, nil, true).Run()
|
||||
tJdStoreInfoInterface, err := task.GetResult(0)
|
||||
for _, v := range tJdStoreInfoInterface {
|
||||
store := v.(*tJdStoreInfo)
|
||||
if store.PageNo > pageNo {
|
||||
pageNo = store.PageNo
|
||||
}
|
||||
storeMap[store.PageNo] = store.Level
|
||||
}
|
||||
return storeMap[pageNo], err
|
||||
}
|
||||
|
||||
// stoerIDs为nil表示所有
|
||||
func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName string) (err error) {
|
||||
var stores []*tJdStoreInfo
|
||||
|
||||
Reference in New Issue
Block a user