From 92b9f96889f9e959c463d8f3fb914a3387f94b2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Fri, 22 Nov 2019 17:59:48 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=AF=BB=E5=8F=96=E6=B0=B8=E8=BE=89Excel?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/yonghui/yonghui.go | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/business/jxstore/yonghui/yonghui.go b/business/jxstore/yonghui/yonghui.go index 512ea0244..2678934d8 100644 --- a/business/jxstore/yonghui/yonghui.go +++ b/business/jxstore/yonghui/yonghui.go @@ -165,13 +165,13 @@ func (d *DataFailedLock) AppendData2(dataFailed DataFailed) { } func LoadExcelByYongHui(ctx *jxcontext.Context, files []*multipart.FileHeader, isAsync, isContinueWhenError bool) (hint string, err error) { - if len(files) == 0 { - return "", errors.New("没有文件上传!") - } - fileHeader := files[0] - file, err := fileHeader.Open() - hint, err = LoadExcelBinByYongHui(ctx, file, true, true) - file.Close() + // if len(files) == 0 { + // return "", errors.New("没有文件上传!") + // } + // fileHeader := files[0] + // file, err := fileHeader.Open() + hint, err = LoadExcelBinByYongHui(ctx, nil, true, true) + // file.Close() return hint, err } @@ -189,7 +189,8 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, is switch step { case 0: //读取excel文件 - xlsx, err := excelize.OpenReader(reader) + // xlsx, err := excelize.OpenReader(reader) + xlsx, err := excelize.OpenFile("111.xlsx") if err != nil { return "", err } @@ -274,7 +275,7 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, is } else { costPrice = skuMap[spuCode].Price } - _, _, _ = updateWeiMobGoods(costPrice, skuMap[spuCode].Price, skuList[0].Unit, isCompare, goodsDetail) + // _, _, _ = updateWeiMobGoods(costPrice, skuMap[spuCode].Price, skuList[0].Unit, isCompare, goodsDetail) } } else { //下架微盟商品 @@ -297,7 +298,7 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, is for _, v := range batchItemList { int64Slice = append(int64Slice, v.(int64)) } - PutAwayWeiMobSku(int64Slice) + // PutAwayWeiMobSku(int64Slice) return retVal, err } taskParallel4 := tasksch.NewParallelTask("下架微盟商品", tasksch.NewParallelConfig().SetParallelCount(parallelCount).SetBatchSize(UpdateGoodsShelfStatusCount), ctx, taskFunc4, goodsIDListForPutAway) From 70bf3a70a9d2b58fe92d098a018c4c98ad954450 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Fri, 22 Nov 2019 18:03:12 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=B0=B8=E8=BE=89Excel=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/yonghui/yonghui.go | 21 ++++++++++----------- controllers/yonghui.go | 20 +++++++++++++++++++- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/business/jxstore/yonghui/yonghui.go b/business/jxstore/yonghui/yonghui.go index 2678934d8..512ea0244 100644 --- a/business/jxstore/yonghui/yonghui.go +++ b/business/jxstore/yonghui/yonghui.go @@ -165,13 +165,13 @@ func (d *DataFailedLock) AppendData2(dataFailed DataFailed) { } func LoadExcelByYongHui(ctx *jxcontext.Context, files []*multipart.FileHeader, isAsync, isContinueWhenError bool) (hint string, err error) { - // if len(files) == 0 { - // return "", errors.New("没有文件上传!") - // } - // fileHeader := files[0] - // file, err := fileHeader.Open() - hint, err = LoadExcelBinByYongHui(ctx, nil, true, true) - // file.Close() + if len(files) == 0 { + return "", errors.New("没有文件上传!") + } + fileHeader := files[0] + file, err := fileHeader.Open() + hint, err = LoadExcelBinByYongHui(ctx, file, true, true) + file.Close() return hint, err } @@ -189,8 +189,7 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, is switch step { case 0: //读取excel文件 - // xlsx, err := excelize.OpenReader(reader) - xlsx, err := excelize.OpenFile("111.xlsx") + xlsx, err := excelize.OpenReader(reader) if err != nil { return "", err } @@ -275,7 +274,7 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, is } else { costPrice = skuMap[spuCode].Price } - // _, _, _ = updateWeiMobGoods(costPrice, skuMap[spuCode].Price, skuList[0].Unit, isCompare, goodsDetail) + _, _, _ = updateWeiMobGoods(costPrice, skuMap[spuCode].Price, skuList[0].Unit, isCompare, goodsDetail) } } else { //下架微盟商品 @@ -298,7 +297,7 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, is for _, v := range batchItemList { int64Slice = append(int64Slice, v.(int64)) } - // PutAwayWeiMobSku(int64Slice) + PutAwayWeiMobSku(int64Slice) return retVal, err } taskParallel4 := tasksch.NewParallelTask("下架微盟商品", tasksch.NewParallelConfig().SetParallelCount(parallelCount).SetBatchSize(UpdateGoodsShelfStatusCount), ctx, taskFunc4, goodsIDListForPutAway) diff --git a/controllers/yonghui.go b/controllers/yonghui.go index 99a397640..e5c57c354 100644 --- a/controllers/yonghui.go +++ b/controllers/yonghui.go @@ -14,7 +14,7 @@ type YongHuiController struct { // @Title 读取永辉excel文件 // @Description 读取永辉excel文件 -// @Param token header string false "认证token" +// @Param token header string true "认证token" // @Param isAsync query bool true "是否异步,缺省是同步" // @Param isContinueWhenError query bool true "单个同步失败是否继续,缺省false" // @Success 200 {object} controllers.CallResult @@ -42,3 +42,21 @@ func (c *YongHuiController) LoadExcelByYongHui() { }) } } + +// @Title 根据微盟商品更新京西价格 +// @Description 根据微盟商品更新京西价格 +// @Param token header string true "认证token" +// @Param storeIDs formData string false "门店ID列表" +// @Param isAsync formData bool true "是否异步,缺省是同步" +// @Param isContinueWhenError formData bool true "单个同步失败是否继续,缺省false" +// @Success 200 {object} controllers.CallResult +// @Failure 200 {object} controllers.CallResult +// @router /UpdateJxPriceByWeimob [post] +func (c *YongHuiController) UpdateJxPriceByWeimob() { + // c.callLoadExcelByYongHui(func(params *tYonghuiLoadExcelByYongHuiParams) (retVal interface{}, errCode string, err error) { + // r := c.Ctx.Request + // files := r.MultipartForm.File["userfiles"] + // retVal, err = yonghui.LoadExcelByYongHui(params.Ctx, files, params.IsAsync, params.IsContinueWhenError) + // return retVal, "", err + // }) +}