Accept Merge Request #32: (yonghui -> mark)

Merge Request: 读取永辉Excel修改
Created By: @苏尹岚
Accepted By: @苏尹岚
URL: https://rosydev.coding.net/p/jx-callback/d/jx-callback/git/merge/32
This commit is contained in:
苏尹岚
2019-11-22 17:00:06 +08:00

View File

@@ -274,27 +274,7 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, is
} else {
costPrice = skuMap[spuCode].Price
}
_, _, err = updateWeiMobGoods(costPrice, skuMap[spuCode].Price, isCompare, goodsDetail)
if err != nil {
if errExt, ok := err.(*utils.ErrorWithCode); ok {
outPutData := DataFailed{
GoodsID: spuCode,
GoodsName: skuMap[spuCode].Name,
Comment: errExt.ErrMsg(),
}
dataFailed.AppendData2(outPutData)
}
} else {
outPutData := DataSuccess{
NameID: goodsDetail.SkuMap.SingleSku.OuterSkuCode,
Name: goodsDetail.Title,
Unit: skuList[0].Unit,
OrgPrice: goodsDetail.SkuMap.SingleSku.SalePrice,
NowPrice: skuMap[spuCode].Price,
MixPrice: Float64Round(skuMap[spuCode].Price - goodsDetail.SkuMap.SingleSku.SalePrice),
}
dataSuccess.AppendData(outPutData)
}
_, _, _ = updateWeiMobGoods(costPrice, skuMap[spuCode].Price, skuList[0].Unit, isCompare, goodsDetail)
}
} else {
//下架微盟商品
@@ -371,7 +351,7 @@ func GetGoodsInfoAndDetailMap(goodsList []*weimobapi.GoodsInfo) (goodsMap map[st
// return list
// }
func updateWeiMobGoods(costPrice, salePrice float64, isCompare bool, goodsDetail *weimobapi.GoodsDetailInfo) (goodsID int64, skuMap map[string]int64, err error) {
func updateWeiMobGoods(costPrice, salePrice float64, unit string, isCompare bool, goodsDetail *weimobapi.GoodsDetailInfo) (goodsID int64, skuMap map[string]int64, err error) {
var (
categoryList []*weimobapi.CategoryList
skuListInfo = goodsDetail.SkuList[0]
@@ -486,6 +466,26 @@ func updateWeiMobGoods(costPrice, salePrice float64, isCompare bool, goodsDetail
}
if globals.EnableStoreWrite {
goodsID, skuMap, err = api.WeimobAPI.UpdateGoods3(updateGoodsParam)
if err != nil {
if errExt, ok := err.(*utils.ErrorWithCode); ok {
outPutData := DataFailed{
GoodsID: goodsDetail.OuterGoodsCode,
GoodsName: goodsDetail.Title,
Comment: errExt.ErrMsg(),
}
dataFailed.AppendData2(outPutData)
}
} else {
outPutData := DataSuccess{
NameID: goodsDetail.SkuMap.SingleSku.OuterSkuCode,
Name: goodsDetail.Title,
Unit: unit,
OrgPrice: goodsDetail.SkuMap.SingleSku.SalePrice,
NowPrice: salePrice,
MixPrice: Float64Round(salePrice - goodsDetail.SkuMap.SingleSku.SalePrice),
}
dataSuccess.AppendData(outPutData)
}
}
return goodsID, skuMap, err
}