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/jxcontext"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
||||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
|
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
|
|
||||||
"git.rosy.net.cn/jx-callback/globals/api"
|
"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)
|
errMsg += fmt.Sprintf("在微盟上未找到该商品!excel商品ID : [%v]\n", k)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if errMsg != "" {
|
// if errMsg != "" {
|
||||||
return "", errors.New(errMsg)
|
// return "", errors.New(errMsg)
|
||||||
}
|
// }
|
||||||
case 2:
|
case 2:
|
||||||
//找出微盟上有,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) {
|
||||||
@@ -170,14 +171,18 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync boo
|
|||||||
if len(skuList) == 0 {
|
if len(skuList) == 0 {
|
||||||
errMsg += fmt.Sprintf("在京西库中未找到该商品!name_id : [%v] \n", goodsDetail.SkuMap.SingleSku.OuterSkuCode)
|
errMsg += fmt.Sprintf("在京西库中未找到该商品!name_id : [%v] \n", goodsDetail.SkuMap.SingleSku.OuterSkuCode)
|
||||||
} else {
|
} else {
|
||||||
if skuList[0].Unit != "份" {
|
if skuList[0].Unit == "份" {
|
||||||
costPrice = Float64Round(0.5 / goodsDetail.SkuMap.SingleSku.B2CSku.Weight * skuMap[spuCode])
|
if goodsDetail.SkuMap.SingleSku.B2CSku.Weight == 0 {
|
||||||
|
costPrice = skuMap[spuCode]
|
||||||
|
} else {
|
||||||
|
costPrice = Float64Round(0.5 / goodsDetail.SkuMap.SingleSku.B2CSku.Weight * skuMap[spuCode])
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
costPrice = skuMap[spuCode]
|
costPrice = skuMap[spuCode]
|
||||||
}
|
}
|
||||||
if errMsg == "" {
|
// if errMsg == "" {
|
||||||
_, _, err = updateWeiMobGoods(costPrice, skuMap[spuCode], goodsDetail)
|
_, _, err = updateWeiMobGoods(costPrice, skuMap[spuCode], goodsDetail)
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//下架微盟商品
|
//下架微盟商品
|
||||||
@@ -195,19 +200,19 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync boo
|
|||||||
// 批量下架微盟商品
|
// 批量下架微盟商品
|
||||||
goodsIDListForPutAway = goodsIDListForPutAwayInterface
|
goodsIDListForPutAway = goodsIDListForPutAwayInterface
|
||||||
case 3:
|
case 3:
|
||||||
if errMsg == "" {
|
// if errMsg == "" {
|
||||||
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{}
|
||||||
for _, v := range batchItemList {
|
for _, v := range batchItemList {
|
||||||
int64Slice = append(int64Slice, v.(int64))
|
int64Slice = append(int64Slice, v.(int64))
|
||||||
}
|
|
||||||
PutAwayWeiMobSku(int64Slice)
|
|
||||||
return retVal, err
|
|
||||||
}
|
}
|
||||||
taskParallel4 := tasksch.NewParallelTask("下架微盟商品", tasksch.NewParallelConfig().SetParallelCount(parallelCount).SetBatchSize(UpdateGoodsShelfStatusCount), ctx, taskFunc4, goodsIDListForPutAway)
|
PutAwayWeiMobSku(int64Slice)
|
||||||
tasksch.HandleTask(taskParallel4, task, true).Run()
|
return retVal, err
|
||||||
_, err = taskParallel4.GetResult(0)
|
|
||||||
}
|
}
|
||||||
|
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
|
return result, err
|
||||||
}
|
}
|
||||||
@@ -221,6 +226,7 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync boo
|
|||||||
}
|
}
|
||||||
if errMsg != "" {
|
if errMsg != "" {
|
||||||
baseapi.SugarLogger.Debugf(errMsg)
|
baseapi.SugarLogger.Debugf(errMsg)
|
||||||
|
return "", errors.New(errMsg)
|
||||||
}
|
}
|
||||||
return hint, err
|
return hint, err
|
||||||
}
|
}
|
||||||
@@ -287,7 +293,7 @@ func updateWeiMobGoods(costPrice, salePrice float64, goodsDetail *weimobapi.Good
|
|||||||
SalePrice: salePrice,
|
SalePrice: salePrice,
|
||||||
CostPrice: costPrice,
|
CostPrice: costPrice,
|
||||||
SkuID: skuListInfo.SkuID,
|
SkuID: skuListInfo.SkuID,
|
||||||
EditStockNum: skuListInfo.EditStockNum,
|
EditStockNum: 9999 - skuListInfo.EditStockNum,
|
||||||
OuterSkuCode: skuListInfo.OuterSkuCode,
|
OuterSkuCode: skuListInfo.OuterSkuCode,
|
||||||
B2CSku: b2CSku,
|
B2CSku: b2CSku,
|
||||||
}
|
}
|
||||||
@@ -297,7 +303,7 @@ func updateWeiMobGoods(costPrice, salePrice float64, goodsDetail *weimobapi.Good
|
|||||||
SkuList: skuListParam,
|
SkuList: skuListParam,
|
||||||
Title: goodsDetail.Title,
|
Title: goodsDetail.Title,
|
||||||
IsMultiSku: goodsDetail.IsMultiSku,
|
IsMultiSku: goodsDetail.IsMultiSku,
|
||||||
IsPutAway: goodsDetail.IsPutAway,
|
IsPutAway: weimobapi.GoodsTypeNormal,
|
||||||
GoodsImageURL: goodsDetail.GoodsImageURL,
|
GoodsImageURL: goodsDetail.GoodsImageURL,
|
||||||
GoodsID: goodsDetail.GoodsID,
|
GoodsID: goodsDetail.GoodsID,
|
||||||
CategoryID: categoryID,
|
CategoryID: categoryID,
|
||||||
|
|||||||
Reference in New Issue
Block a user