Accept Merge Request #26: (su -> mark)
Merge Request: 读取永辉excel Created By: @苏尹岚 Accepted By: @苏尹岚 URL: https://rosydev.coding.net/p/jx-callback/d/jx-callback/git/merge/26
This commit is contained in:
@@ -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"
|
||||
@@ -153,9 +154,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 +171,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 +200,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
|
||||
}
|
||||
@@ -221,6 +226,7 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync boo
|
||||
}
|
||||
if errMsg != "" {
|
||||
baseapi.SugarLogger.Debugf(errMsg)
|
||||
return "", errors.New(errMsg)
|
||||
}
|
||||
return hint, err
|
||||
}
|
||||
@@ -287,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,
|
||||
}
|
||||
@@ -297,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,
|
||||
|
||||
Reference in New Issue
Block a user