读取永辉excel

This commit is contained in:
苏尹岚
2019-11-29 11:56:47 +08:00
parent 2d653c2e19
commit 2e4c408170

View File

@@ -235,14 +235,15 @@ func LoadExcelByYongHui(ctx *jxcontext.Context, files []*multipart.FileHeader, i
func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, isContinueWhenError bool) (hint string, err error) {
var (
skuMap = make(map[string]*ExcelParam)
errMsg string
costPrice float64 //成本价
goodsList []*weimobapi.GoodsInfo
goodsIDListForPutAway []interface{}
isCompare bool
isExecute = false
)
db := dao.GetDB()
taskSeqFunc := func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
var errMsg string
switch step {
case 0:
//读取excel文件
@@ -261,6 +262,11 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, is
// 分类名格式为可定XX日
// XX为上传永辉 提供的 价格表时间 +2天
if errMsg == "" {
isExecute = true
} else {
err = fmt.Errorf(errMsg)
}
if isExecute {
isCompare, err = UpdateClassifyAndGetLastClassify()
}
case 1:
@@ -326,7 +332,7 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, is
} else {
costPrice = skuMap[spuCode].Price
}
if errMsg == "" {
if isExecute {
_, _, _ = updateWeiMobGoods(costPrice, skuMap[spuCode].Price, skuList[0].Unit, isCompare, goodsDetail)
}
}
@@ -351,7 +357,7 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, is
for _, v := range batchItemList {
int64Slice = append(int64Slice, v.(int64))
}
if errMsg == "" {
if isExecute {
PutAwayWeiMobSku(int64Slice)
}
return retVal, err
@@ -362,9 +368,7 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, is
case 4:
WriteToExcel(task, dataSuccess.dataSuccessList, dataFailed.dataFailedList)
}
if errMsg != "" {
return result, errors.New(errMsg)
}
return result, err
}
taskSeq := tasksch.NewSeqTask2("读取永辉Excel文件修改微盟商品价格可售状态-序列任务", ctx, isContinueWhenError, taskSeqFunc, 5)