读取永辉excel
This commit is contained in:
@@ -114,7 +114,7 @@ var (
|
|||||||
OrgSkuIdCol: 5,
|
OrgSkuIdCol: 5,
|
||||||
OrgSkuPriceCol: 8,
|
OrgSkuPriceCol: 8,
|
||||||
OrgSkuNameCol: 6,
|
OrgSkuNameCol: 6,
|
||||||
SkuRow: 1,
|
SkuRow: 2,
|
||||||
}, "水果": &SheetParam{
|
}, "水果": &SheetParam{
|
||||||
SkuIDCol: 0,
|
SkuIDCol: 0,
|
||||||
SkuPriceCol: 14,
|
SkuPriceCol: 14,
|
||||||
@@ -133,12 +133,12 @@ var (
|
|||||||
SkuRow: 1,
|
SkuRow: 1,
|
||||||
}, "净配": &SheetParam{
|
}, "净配": &SheetParam{
|
||||||
SkuIDCol: 0,
|
SkuIDCol: 0,
|
||||||
SkuPriceCol: 13,
|
SkuPriceCol: 12,
|
||||||
SkuNameCol: 1,
|
SkuNameCol: 1,
|
||||||
OrgSkuIdCol: 4,
|
OrgSkuIdCol: 4,
|
||||||
OrgSkuPriceCol: 7,
|
OrgSkuPriceCol: 7,
|
||||||
OrgSkuNameCol: 5,
|
OrgSkuNameCol: 5,
|
||||||
SkuRow: 2,
|
SkuRow: 1,
|
||||||
}, "水产": &SheetParam{
|
}, "水产": &SheetParam{
|
||||||
SkuIDCol: 1,
|
SkuIDCol: 1,
|
||||||
SkuPriceCol: 15,
|
SkuPriceCol: 15,
|
||||||
@@ -239,12 +239,9 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, is
|
|||||||
costPrice float64 //成本价
|
costPrice float64 //成本价
|
||||||
goodsList []*weimobapi.GoodsInfo
|
goodsList []*weimobapi.GoodsInfo
|
||||||
goodsIDListForPutAway []interface{}
|
goodsIDListForPutAway []interface{}
|
||||||
isCompare bool
|
// isCompare bool
|
||||||
)
|
)
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
taskSeqFunc := func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
|
|
||||||
switch step {
|
|
||||||
case 0:
|
|
||||||
//读取excel文件
|
//读取excel文件
|
||||||
xlsx, err := excelize.OpenReader(reader)
|
xlsx, err := excelize.OpenReader(reader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -269,14 +266,16 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, is
|
|||||||
//修改分组名
|
//修改分组名
|
||||||
// 分类名格式为:可定XX日
|
// 分类名格式为:可定XX日
|
||||||
// XX为上传永辉 提供的 价格表时间 +2天
|
// XX为上传永辉 提供的 价格表时间 +2天
|
||||||
isCompare, err = UpdateClassifyAndGetLastClassify()
|
// isCompare, err = UpdateClassifyAndGetLastClassify()
|
||||||
case 1:
|
taskSeqFunc := func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
|
||||||
|
switch step {
|
||||||
|
case 0:
|
||||||
//获取微盟所有商品
|
//获取微盟所有商品
|
||||||
param := &weimobapi.QueryGoodsListParam{
|
// param := &weimobapi.QueryGoodsListParam{
|
||||||
PageNum: 1,
|
// PageNum: 1,
|
||||||
PageSize: jdapi.MaxSkuIDsCount4QueryListBySkuIds,
|
// PageSize: jdapi.MaxSkuIDsCount4QueryListBySkuIds,
|
||||||
}
|
// }
|
||||||
goodsList, err = GetWeiMobGoodsList(param)
|
// goodsList, err = GetWeiMobGoodsList(param)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
baseapi.SugarLogger.Errorf("GetWeiMobGoodsList error:%v", err)
|
baseapi.SugarLogger.Errorf("GetWeiMobGoodsList error:%v", err)
|
||||||
}
|
}
|
||||||
@@ -306,7 +305,7 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, is
|
|||||||
// errMsg += fmt.Sprintf("在微盟上未找到该商品xxx", xxx)
|
// errMsg += fmt.Sprintf("在微盟上未找到该商品xxx", xxx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 2:
|
case 1:
|
||||||
//找出微盟上有,excel上没有的,有就更新,没有就下架
|
//找出微盟上有,excel上没有的,有就更新,没有就下架
|
||||||
taskFunc3 := func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
taskFunc3 := func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
goods := batchItemList[0].(*weimobapi.GoodsInfo)
|
goods := batchItemList[0].(*weimobapi.GoodsInfo)
|
||||||
@@ -353,7 +352,7 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, is
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
goodsIDListForPutAway = goodsIDListForPutAwayInterface
|
goodsIDListForPutAway = goodsIDListForPutAwayInterface
|
||||||
case 3:
|
case 2:
|
||||||
// 批量下架微盟商品
|
// 批量下架微盟商品
|
||||||
taskFunc4 := func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
taskFunc4 := func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
int64Slice := []int64{}
|
int64Slice := []int64{}
|
||||||
@@ -368,7 +367,7 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, is
|
|||||||
taskParallel4 := tasksch.NewParallelTask("下架微盟商品", tasksch.NewParallelConfig().SetParallelCount(parallelCount).SetBatchSize(UpdateGoodsShelfStatusCount), ctx, taskFunc4, goodsIDListForPutAway)
|
taskParallel4 := tasksch.NewParallelTask("下架微盟商品", tasksch.NewParallelConfig().SetParallelCount(parallelCount).SetBatchSize(UpdateGoodsShelfStatusCount), ctx, taskFunc4, goodsIDListForPutAway)
|
||||||
tasksch.HandleTask(taskParallel4, task, true).Run()
|
tasksch.HandleTask(taskParallel4, task, true).Run()
|
||||||
_, err = taskParallel4.GetResult(0)
|
_, err = taskParallel4.GetResult(0)
|
||||||
case 4:
|
case 3:
|
||||||
WriteToExcel(task, dataSuccess.dataSuccessList, dataFailed.dataFailedList)
|
WriteToExcel(task, dataSuccess.dataSuccessList, dataFailed.dataFailedList)
|
||||||
}
|
}
|
||||||
// if errMsg != "" {
|
// if errMsg != "" {
|
||||||
@@ -376,7 +375,7 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, is
|
|||||||
// }
|
// }
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
taskSeq := tasksch.NewSeqTask2("读取永辉Excel文件修改微盟商品价格可售状态-序列任务", ctx, isContinueWhenError, taskSeqFunc, 5)
|
taskSeq := tasksch.NewSeqTask2("读取永辉Excel文件修改微盟商品价格可售状态-序列任务", ctx, isContinueWhenError, taskSeqFunc, 4)
|
||||||
tasksch.HandleTask(taskSeq, nil, true).Run()
|
tasksch.HandleTask(taskSeq, nil, true).Run()
|
||||||
if !isAsync {
|
if !isAsync {
|
||||||
_, err = taskSeq.GetResult(0)
|
_, err = taskSeq.GetResult(0)
|
||||||
|
|||||||
Reference in New Issue
Block a user