刷新京东等级
This commit is contained in:
@@ -36,8 +36,6 @@ type tJdStoreInfo struct {
|
||||
VendorStoreID string `orm:"column(vendor_store_id)"`
|
||||
RealLastOperator string
|
||||
SyncStatus int
|
||||
Level string
|
||||
PageNo int
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -93,9 +91,6 @@ func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorOrgCode, vendo
|
||||
}
|
||||
}
|
||||
}
|
||||
if level, err := GetJdStoreLevel(ctx, vendorOrgCode, vendorStoreID); err == nil {
|
||||
retVal.JdStoreLevel = level
|
||||
}
|
||||
if retVal.DistrictCode == 0 {
|
||||
retVal.DistrictCode = api.AutonaviAPI.GetCoordinateDistrictCode(lng, lat)
|
||||
if retVal.CityCode == 0 {
|
||||
@@ -120,42 +115,6 @@ 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