From 6c54e3901f55a93cb02e2f4d6e9439c725d7faab Mon Sep 17 00:00:00 2001 From: suyl <770236076@qq.com> Date: Sun, 17 Nov 2019 16:44:59 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E8=AF=BB=E5=8F=96=E6=B0=B8=E8=BE=89ecxcle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/yonghui/yonghui.go | 42 ++++++++++++++++------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/business/jxstore/yonghui/yonghui.go b/business/jxstore/yonghui/yonghui.go index 1d0b545cf..361c1bca6 100644 --- a/business/jxstore/yonghui/yonghui.go +++ b/business/jxstore/yonghui/yonghui.go @@ -153,9 +153,9 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync boo errMsg += fmt.Sprintf("在微盟上未找到该商品!excel商品ID : [%v]\n", k) } } - if errMsg != "" { - return "", errors.New(errMsg) - } + // if errMsg != "" { + // return "", errors.New(errMsg) + // } case 2: //找出微盟上有,excel上没有的,有就更新,没有就下架 taskFunc3 := func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { @@ -170,14 +170,18 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync boo if len(skuList) == 0 { errMsg += fmt.Sprintf("在京西库中未找到该商品!name_id : [%v] \n", goodsDetail.SkuMap.SingleSku.OuterSkuCode) } else { - if skuList[0].Unit != "份" { - costPrice = Float64Round(0.5 / goodsDetail.SkuMap.SingleSku.B2CSku.Weight * skuMap[spuCode]) + if skuList[0].Unit == "份" { + if goodsDetail.SkuMap.SingleSku.B2CSku.Weight == 0 { + costPrice = skuMap[spuCode] + } else { + costPrice = Float64Round(0.5 / goodsDetail.SkuMap.SingleSku.B2CSku.Weight * skuMap[spuCode]) + } } else { costPrice = skuMap[spuCode] } - if errMsg == "" { - _, _, err = updateWeiMobGoods(costPrice, skuMap[spuCode], goodsDetail) - } + // if errMsg == "" { + _, _, err = updateWeiMobGoods(costPrice, skuMap[spuCode], goodsDetail) + // } } } else { //下架微盟商品 @@ -195,19 +199,19 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync boo // 批量下架微盟商品 goodsIDListForPutAway = goodsIDListForPutAwayInterface case 3: - if errMsg == "" { - taskFunc4 := func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { - int64Slice := []int64{} - for _, v := range batchItemList { - int64Slice = append(int64Slice, v.(int64)) - } - PutAwayWeiMobSku(int64Slice) - return retVal, err + // if errMsg == "" { + taskFunc4 := func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { + int64Slice := []int64{} + for _, v := range batchItemList { + int64Slice = append(int64Slice, v.(int64)) } - taskParallel4 := tasksch.NewParallelTask("下架微盟商品", tasksch.NewParallelConfig().SetParallelCount(parallelCount).SetBatchSize(UpdateGoodsShelfStatusCount), ctx, taskFunc4, goodsIDListForPutAway) - tasksch.HandleTask(taskParallel4, task, true).Run() - _, err = taskParallel4.GetResult(0) + PutAwayWeiMobSku(int64Slice) + return retVal, err } + taskParallel4 := tasksch.NewParallelTask("下架微盟商品", tasksch.NewParallelConfig().SetParallelCount(parallelCount).SetBatchSize(UpdateGoodsShelfStatusCount), ctx, taskFunc4, goodsIDListForPutAway) + tasksch.HandleTask(taskParallel4, task, true).Run() + _, err = taskParallel4.GetResult(0) + // } } return result, err } From 966fa16a4137df76e9312ed76cc22ed8169e76ff Mon Sep 17 00:00:00 2001 From: suyl <770236076@qq.com> Date: Sun, 17 Nov 2019 17:32:55 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E8=AF=BB=E5=8F=96=E6=B0=B8=E8=BE=89excel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/yonghui/yonghui.go | 1 + 1 file changed, 1 insertion(+) diff --git a/business/jxstore/yonghui/yonghui.go b/business/jxstore/yonghui/yonghui.go index 361c1bca6..a84cafb4d 100644 --- a/business/jxstore/yonghui/yonghui.go +++ b/business/jxstore/yonghui/yonghui.go @@ -225,6 +225,7 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync boo } if errMsg != "" { baseapi.SugarLogger.Debugf(errMsg) + return "", errors.New(errMsg) } return hint, err } From b2ab431238a804153cf056d5f9808c5c1e82ef6e Mon Sep 17 00:00:00 2001 From: suyl <770236076@qq.com> Date: Sun, 17 Nov 2019 17:38:07 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E8=AF=BB=E5=8F=96=E6=B0=B8=E8=BE=89excel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/yonghui/yonghui.go | 1 + 1 file changed, 1 insertion(+) diff --git a/business/jxstore/yonghui/yonghui.go b/business/jxstore/yonghui/yonghui.go index a84cafb4d..b5d3b8c2e 100644 --- a/business/jxstore/yonghui/yonghui.go +++ b/business/jxstore/yonghui/yonghui.go @@ -180,6 +180,7 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync boo costPrice = skuMap[spuCode] } // if errMsg == "" { + errMsg += fmt.Sprintf("更新商品:[%v],[%v],[%v]", costPrice, skuMap[spuCode], spuCode) _, _, err = updateWeiMobGoods(costPrice, skuMap[spuCode], goodsDetail) // } } From 48fc1dece615a42b9a19ff9162ca3bb7d27d30df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Mon, 18 Nov 2019 09:05:03 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E8=AF=BB=E5=8F=96=E6=B0=B8=E8=BE=89excel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/yonghui/yonghui.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/business/jxstore/yonghui/yonghui.go b/business/jxstore/yonghui/yonghui.go index b5d3b8c2e..536c12c77 100644 --- a/business/jxstore/yonghui/yonghui.go +++ b/business/jxstore/yonghui/yonghui.go @@ -17,6 +17,7 @@ import ( "git.rosy.net.cn/jx-callback/business/jxutils/jxcontext" "git.rosy.net.cn/jx-callback/business/jxutils/tasksch" "git.rosy.net.cn/jx-callback/business/model/dao" + "git.rosy.net.cn/jx-callback/globals" "git.rosy.net.cn/jx-callback/globals/api" @@ -180,7 +181,6 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync boo costPrice = skuMap[spuCode] } // if errMsg == "" { - errMsg += fmt.Sprintf("更新商品:[%v],[%v],[%v]", costPrice, skuMap[spuCode], spuCode) _, _, err = updateWeiMobGoods(costPrice, skuMap[spuCode], goodsDetail) // } } @@ -293,7 +293,7 @@ func updateWeiMobGoods(costPrice, salePrice float64, goodsDetail *weimobapi.Good SalePrice: salePrice, CostPrice: costPrice, SkuID: skuListInfo.SkuID, - EditStockNum: skuListInfo.EditStockNum, + EditStockNum: 9999 - skuListInfo.EditStockNum, OuterSkuCode: skuListInfo.OuterSkuCode, B2CSku: b2CSku, } @@ -303,7 +303,7 @@ func updateWeiMobGoods(costPrice, salePrice float64, goodsDetail *weimobapi.Good SkuList: skuListParam, Title: goodsDetail.Title, IsMultiSku: goodsDetail.IsMultiSku, - IsPutAway: goodsDetail.IsPutAway, + IsPutAway: weimobapi.GoodsTypeNormal, GoodsImageURL: goodsDetail.GoodsImageURL, GoodsID: goodsDetail.GoodsID, CategoryID: categoryID,