aa
This commit is contained in:
@@ -2088,75 +2088,86 @@ func CreateUpcSkuByExcelBin(ctx *jxcontext.Context, reader io.Reader, categoryID
|
|||||||
retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, err.Error())}
|
retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, err.Error())}
|
||||||
return retVal, err
|
return retVal, err
|
||||||
}
|
}
|
||||||
|
var productInfo = &jdapi.ProductInfo{}
|
||||||
if len(productInfos) == 0 {
|
if len(productInfos) == 0 {
|
||||||
var result *aliupcapi.GetAliUpcInfoResult
|
if configs, err := dao.QueryConfigs(dao.GetDB(), "mtwmCookieStr", model.ConfigTypeCookie, ""); err == nil {
|
||||||
upcDepot, err := dao.GetUpcDepot(db, *v.Upc)
|
api.MtwmAPI.SetCookieWithStr(configs[0].Value)
|
||||||
if upcDepot == nil {
|
|
||||||
result, err = api.AliUpcAPI.GetAliUpcInfo(*v.Upc)
|
|
||||||
if err == nil {
|
|
||||||
err = dao.InsertUpcDepot(db, result)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
result = upcDepot
|
|
||||||
}
|
}
|
||||||
if result == nil {
|
result, _ := api.MtwmAPI.GetStandardProductListWithCond(*skuName.Upc)
|
||||||
retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, "未在标品库查到此商品,请手动创建!")}
|
if result != nil {
|
||||||
|
productInfo.OriginalName = result.Name
|
||||||
|
productInfo.OriginalSpec = result.Spec
|
||||||
|
productInfo.Name = result.Name
|
||||||
|
productInfo.SpecUnit = result.SpecUnit
|
||||||
|
productInfo.Unit = result.Unit
|
||||||
|
productInfo.SpecQuality = float32(result.SpecNew)
|
||||||
|
productInfo.ImgList = strings.Split(result.Pic, ",")
|
||||||
|
productInfo.Weight = float32(result.Weight)
|
||||||
|
productInfo.BrandName = result.BrandNamePath
|
||||||
|
setImgs(skuName, productInfo.ImgList)
|
||||||
|
} else {
|
||||||
|
retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, "美团cookie过期了吧")}
|
||||||
return retVal, err
|
return retVal, err
|
||||||
}
|
}
|
||||||
if result.Img != "" {
|
} else {
|
||||||
downloadURL, err := uploadImgStandard(skuName.Img)
|
productInfo = productInfos[0]
|
||||||
if err != nil {
|
}
|
||||||
retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, err.Error())}
|
if productInfo.Name == "" {
|
||||||
return retVal, err
|
|
||||||
}
|
|
||||||
skuName.Img = downloadURL
|
|
||||||
} else {
|
|
||||||
skuName.Img = model.NOSkuNameImg
|
|
||||||
}
|
|
||||||
if v.Name != "" {
|
if v.Name != "" {
|
||||||
skuName.Name = v.Name
|
productInfo.Name = v.Name
|
||||||
|
} else if productInfo.OriginalName != "" {
|
||||||
|
productInfo.Name = productInfo.OriginalName
|
||||||
} else {
|
} else {
|
||||||
skuName.Name = result.GoodsName
|
retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, "需要填上一个合适的商品名!")}
|
||||||
|
return retVal, err
|
||||||
}
|
}
|
||||||
if v.Price == 0 {
|
}
|
||||||
if result.Price == "" {
|
if v.Price == 0 {
|
||||||
retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, "未查询到商品售价,请补充商品的售价!")}
|
result, err := api.AliUpcAPI.GetAliUpcInfo(*v.Upc)
|
||||||
return retVal, err
|
if err != nil {
|
||||||
} else {
|
retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, err.Error())}
|
||||||
skuName.Price = int(utils.Str2Int64(result.Price) * 100)
|
return retVal, err
|
||||||
}
|
|
||||||
} else {
|
|
||||||
skuName.Price = v.Price
|
|
||||||
}
|
}
|
||||||
getNetUpcInfo, err := api.AliUpcAPI.GetNetUpcInfo(*v.Upc)
|
if result.Price == "" {
|
||||||
if v.Unit != "" {
|
retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, "未查询到商品售价,请补充商品售价!")}
|
||||||
if v.Unit == model.UnitNames[0] {
|
return retVal, err
|
||||||
retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, "标品的单位不能为份!")}
|
|
||||||
return retVal, err
|
|
||||||
}
|
|
||||||
skuName.Unit = v.Unit
|
|
||||||
} else {
|
} else {
|
||||||
|
skuName.Price = int(utils.Str2Int64(result.Price) * 100)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
skuName.Price = v.Price
|
||||||
|
}
|
||||||
|
skuName.Name = productInfo.Name
|
||||||
|
getNetUpcInfo, err := api.AliUpcAPI.GetNetUpcInfo(*v.Upc)
|
||||||
|
if v.Unit != "" {
|
||||||
|
skuName.Unit = v.Unit
|
||||||
|
} else {
|
||||||
|
if productInfo.Unit == "" {
|
||||||
if getNetUpcInfo.Unit != "" {
|
if getNetUpcInfo.Unit != "" {
|
||||||
skuName.Unit = getNetUpcInfo.Unit
|
skuName.Unit = getNetUpcInfo.Unit
|
||||||
} else {
|
} else {
|
||||||
retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, "未查询到商品单位,请补充商品单位!")}
|
retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, "未查询到商品单位,请补充商品单位!")}
|
||||||
return retVal, err
|
return retVal, err
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if v.SpecQuality != 0 {
|
|
||||||
skuName.Skus[0].SpecQuality = v.SpecQuality
|
|
||||||
skuName.Skus[0].Weight = utils.Float32ToInt(v.SpecQuality)
|
|
||||||
skuName.Skus[0].SpecUnit = model.SpecUnitNames[0]
|
|
||||||
} else {
|
} else {
|
||||||
_, _, _, specUnit, _, specQuality := jxutils.SplitSkuName(v.Name)
|
skuName.Unit = productInfo.Unit
|
||||||
if specQuality != 0 {
|
}
|
||||||
skuName.Skus[0].SpecQuality = specQuality
|
}
|
||||||
if specUnit == model.SpecUnitNames[1] || specUnit == model.SpecUnitNames[2] {
|
if v.SpecQuality != 0 {
|
||||||
skuName.Skus[0].Weight = int(utils.Str2Int64(utils.Float64ToStr(float64(specQuality) * 1000)))
|
skuName.Skus[0].SpecQuality = v.SpecQuality
|
||||||
} else {
|
skuName.Skus[0].Weight = utils.Float32ToInt(v.SpecQuality)
|
||||||
skuName.Skus[0].Weight = utils.Float32ToInt(specQuality)
|
skuName.Skus[0].SpecUnit = model.SpecUnitNames[0]
|
||||||
}
|
} else {
|
||||||
|
_, _, _, specUnit, _, specQuality := jxutils.SplitSkuName(v.Name)
|
||||||
|
if specQuality != 0 {
|
||||||
|
skuName.Skus[0].SpecQuality = specQuality
|
||||||
|
if specUnit == model.SpecUnitNames[1] || specUnit == model.SpecUnitNames[2] {
|
||||||
|
skuName.Skus[0].Weight = int(utils.Str2Int64(utils.Float64ToStr(float64(specQuality) * 1000)))
|
||||||
} else {
|
} else {
|
||||||
|
skuName.Skus[0].Weight = utils.Float32ToInt(specQuality)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if productInfo.SpecQuality == 0 {
|
||||||
if getNetUpcInfo.SpecQuality != 0 {
|
if getNetUpcInfo.SpecQuality != 0 {
|
||||||
if getNetUpcInfo.SpecUnit == model.SpecUnitNames[1] || getNetUpcInfo.SpecUnit == model.SpecUnitNames[2] ||
|
if getNetUpcInfo.SpecUnit == model.SpecUnitNames[1] || getNetUpcInfo.SpecUnit == model.SpecUnitNames[2] ||
|
||||||
getNetUpcInfo.SpecUnit == "KG" || getNetUpcInfo.SpecUnit == "l" {
|
getNetUpcInfo.SpecUnit == "KG" || getNetUpcInfo.SpecUnit == "l" {
|
||||||
@@ -2169,120 +2180,32 @@ func CreateUpcSkuByExcelBin(ctx *jxcontext.Context, reader io.Reader, categoryID
|
|||||||
retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, "未查询到商品重量,请补充商品重量!")}
|
retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, "未查询到商品重量,请补充商品重量!")}
|
||||||
return retVal, err
|
return retVal, err
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if productInfo.Weight != 0 {
|
||||||
|
skuName.Skus[0].Weight = int(utils.Str2Int64(utils.Float64ToStr(float64(productInfo.Weight))))
|
||||||
|
} else {
|
||||||
|
skuName.Skus[0].Weight = utils.Float32ToInt(v.SpecQuality)
|
||||||
|
}
|
||||||
|
skuName.Skus[0].SpecQuality = productInfo.SpecQuality
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if productInfo.SpecUnit == "" {
|
||||||
if getNetUpcInfo.SpecUnit != "" {
|
if getNetUpcInfo.SpecUnit != "" {
|
||||||
skuName.Skus[0].SpecUnit = getNetUpcInfo.SpecUnit
|
skuName.Skus[0].SpecUnit = getNetUpcInfo.SpecUnit
|
||||||
} else {
|
} else {
|
||||||
skuName.Skus[0].SpecUnit = model.SpecUnitNames[0]
|
skuName.Skus[0].SpecUnit = model.SpecUnitNames[0]
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
|
||||||
productInfo := productInfos[0]
|
|
||||||
if productInfo.Name == "" {
|
|
||||||
if v.Name != "" {
|
|
||||||
productInfo.Name = v.Name
|
|
||||||
} else {
|
|
||||||
retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, "需要填上一个合适的商品名!")}
|
|
||||||
return retVal, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
skuNames2, _ := dao.GetSkuNames(db, nil, nil, productInfo.Name, false)
|
|
||||||
if len(skuNames2) > 1 {
|
|
||||||
retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, "此商品名在京西库中查询出了大于1个商品!")}
|
|
||||||
return retVal, err
|
|
||||||
}
|
|
||||||
//表示查到了,需要把upc更新上去,没查到就要新建
|
|
||||||
if len(skuNames2) == 1 && (productInfo.SpecQuality == skuNames2[0].SpecQuality && productInfo.SpecUnit == skuNames2[0].SpecUnit) {
|
|
||||||
skuNames2[0].Upc = v.Upc
|
|
||||||
dao.UpdateEntity(db, skuNames2[0], "Upc")
|
|
||||||
return retVal, err
|
|
||||||
} else {
|
} else {
|
||||||
if v.Price == 0 {
|
skuName.Skus[0].SpecUnit = productInfo.SpecUnit
|
||||||
result, err := api.AliUpcAPI.GetAliUpcInfo(*v.Upc)
|
|
||||||
if err != nil {
|
|
||||||
retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, err.Error())}
|
|
||||||
return retVal, err
|
|
||||||
}
|
|
||||||
if result.Price == "" {
|
|
||||||
retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, "未查询到商品售价,请补充商品售价!")}
|
|
||||||
return retVal, err
|
|
||||||
} else {
|
|
||||||
skuName.Price = int(utils.Str2Int64(result.Price) * 100)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
skuName.Price = v.Price
|
|
||||||
}
|
|
||||||
skuName.Name = productInfo.Name
|
|
||||||
getNetUpcInfo, err := api.AliUpcAPI.GetNetUpcInfo(*v.Upc)
|
|
||||||
if v.Unit != "" {
|
|
||||||
skuName.Unit = v.Unit
|
|
||||||
} else {
|
|
||||||
if productInfo.Unit == "" {
|
|
||||||
if getNetUpcInfo.Unit != "" {
|
|
||||||
skuName.Unit = getNetUpcInfo.Unit
|
|
||||||
} else {
|
|
||||||
retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, "未查询到商品单位,请补充商品单位!")}
|
|
||||||
return retVal, err
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
skuName.Unit = productInfo.Unit
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if v.SpecQuality != 0 {
|
|
||||||
skuName.Skus[0].SpecQuality = v.SpecQuality
|
|
||||||
skuName.Skus[0].Weight = utils.Float32ToInt(v.SpecQuality)
|
|
||||||
skuName.Skus[0].SpecUnit = model.SpecUnitNames[0]
|
|
||||||
} else {
|
|
||||||
_, _, _, specUnit, _, specQuality := jxutils.SplitSkuName(v.Name)
|
|
||||||
if specQuality != 0 {
|
|
||||||
skuName.Skus[0].SpecQuality = specQuality
|
|
||||||
if specUnit == model.SpecUnitNames[1] || specUnit == model.SpecUnitNames[2] {
|
|
||||||
skuName.Skus[0].Weight = int(utils.Str2Int64(utils.Float64ToStr(float64(specQuality) * 1000)))
|
|
||||||
} else {
|
|
||||||
skuName.Skus[0].Weight = utils.Float32ToInt(specQuality)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if productInfo.SpecQuality == 0 {
|
|
||||||
if getNetUpcInfo.SpecQuality != 0 {
|
|
||||||
if getNetUpcInfo.SpecUnit == model.SpecUnitNames[1] || getNetUpcInfo.SpecUnit == model.SpecUnitNames[2] ||
|
|
||||||
getNetUpcInfo.SpecUnit == "KG" || getNetUpcInfo.SpecUnit == "l" {
|
|
||||||
skuName.Skus[0].Weight = int(utils.Str2Int64(utils.Float64ToStr(float64(getNetUpcInfo.SpecQuality) * 1000)))
|
|
||||||
} else {
|
|
||||||
skuName.Skus[0].Weight = utils.Float32ToInt(getNetUpcInfo.SpecQuality)
|
|
||||||
}
|
|
||||||
skuName.Skus[0].SpecQuality = getNetUpcInfo.SpecQuality
|
|
||||||
} else {
|
|
||||||
retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, "未查询到商品重量,请补充商品重量!")}
|
|
||||||
return retVal, err
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if productInfo.Weight != 0 {
|
|
||||||
skuName.Skus[0].Weight = int(utils.Str2Int64(utils.Float64ToStr(float64(productInfo.Weight))))
|
|
||||||
} else {
|
|
||||||
skuName.Skus[0].Weight = utils.Float32ToInt(v.SpecQuality)
|
|
||||||
}
|
|
||||||
skuName.Skus[0].SpecQuality = productInfo.SpecQuality
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if productInfo.SpecUnit == "" {
|
|
||||||
if getNetUpcInfo.SpecUnit != "" {
|
|
||||||
skuName.Skus[0].SpecUnit = getNetUpcInfo.SpecUnit
|
|
||||||
} else {
|
|
||||||
skuName.Skus[0].SpecUnit = model.SpecUnitNames[0]
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
skuName.Skus[0].SpecUnit = productInfo.SpecUnit
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if len(productInfo.ImgList) > 0 {
|
|
||||||
setImgs(skuName, productInfo.ImgList)
|
|
||||||
} else {
|
|
||||||
skuName.Img = model.NOSkuNameImg
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if len(productInfo.ImgList) > 0 {
|
||||||
|
setImgs(skuName, productInfo.ImgList)
|
||||||
|
} else {
|
||||||
|
skuName.Img = model.NOSkuNameImg
|
||||||
|
}
|
||||||
if skuName.Img == "" {
|
if skuName.Img == "" {
|
||||||
retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, "未查询到商品图片,请联系开发!")}
|
retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, "未查询到商品图片请联系开发!")}
|
||||||
return retVal, err
|
return retVal, err
|
||||||
}
|
}
|
||||||
suffix := skuName.Img[strings.LastIndex(skuName.Img, "."):]
|
suffix := skuName.Img[strings.LastIndex(skuName.Img, "."):]
|
||||||
@@ -2298,19 +2221,6 @@ func CreateUpcSkuByExcelBin(ctx *jxcontext.Context, reader io.Reader, categoryID
|
|||||||
skuName.CategoryID = categoryID
|
skuName.CategoryID = categoryID
|
||||||
}
|
}
|
||||||
skuName.Skus[0].Status = model.SkuStatusNormal
|
skuName.Skus[0].Status = model.SkuStatusNormal
|
||||||
if skuName.Img == model.NOSkuNameImg {
|
|
||||||
if configs, err := dao.QueryConfigs(dao.GetDB(), "mtwmCookieStr", model.ConfigTypeCookie, ""); err == nil {
|
|
||||||
api.MtwmAPI.SetCookieWithStr(configs[0].Value)
|
|
||||||
}
|
|
||||||
result, _ := api.MtwmAPI.GetStandardProductListWithCond(*skuName.Upc)
|
|
||||||
if result != nil {
|
|
||||||
imgs := strings.Split(result.Pic, ",")
|
|
||||||
setImgs(skuName, imgs)
|
|
||||||
} else {
|
|
||||||
retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, "美团cookie过期了吧")}
|
|
||||||
return retVal, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//需要把图片传到七牛云上, 很难受
|
//需要把图片传到七牛云上, 很难受
|
||||||
if !strings.Contains(skuName.Img, "image.jxc4.com") {
|
if !strings.Contains(skuName.Img, "image.jxc4.com") {
|
||||||
downloadURL, err := uploadImgStandard(skuName.Img)
|
downloadURL, err := uploadImgStandard(skuName.Img)
|
||||||
|
|||||||
@@ -1274,7 +1274,6 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs
|
|||||||
if err != nil || storeDetail == nil {
|
if err != nil || storeDetail == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
globals.SugarLogger.Debugf("updateStoresSkusWithoutSync, step 0")
|
|
||||||
if beego.BConfig.RunMode == "prod" || beego.BConfig.RunMode == "beta" {
|
if beego.BConfig.RunMode == "prod" || beego.BConfig.RunMode == "beta" {
|
||||||
if len(storeIDs) > 1 {
|
if len(storeIDs) > 1 {
|
||||||
if storeDetail.StoreLevel == "D" || storeDetail.StoreLevel == "E" {
|
if storeDetail.StoreLevel == "D" || storeDetail.StoreLevel == "E" {
|
||||||
@@ -1282,12 +1281,10 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
globals.SugarLogger.Debugf("updateStoresSkusWithoutSync, step 1")
|
|
||||||
scaleFactor := float64(1)
|
scaleFactor := float64(1)
|
||||||
if isScale {
|
if isScale {
|
||||||
scaleFactor = 100 / float64(jxutils.ConstrainPayPercentage(storeDetail.PayPercentage))
|
scaleFactor = 100 / float64(jxutils.ConstrainPayPercentage(storeDetail.PayPercentage))
|
||||||
}
|
}
|
||||||
globals.SugarLogger.Debugf("updateStoresSkusWithoutSync, step 2")
|
|
||||||
for _, skuBindInfo := range skuBindInfos {
|
for _, skuBindInfo := range skuBindInfos {
|
||||||
// 关注且没有给价时,需要尝试从store_sku_bind中得到已有的单价
|
// 关注且没有给价时,需要尝试从store_sku_bind中得到已有的单价
|
||||||
needGetExistingUnitPrice := skuBindInfo.UnitPrice == 0 && skuBindInfo.IsFocus == 1
|
needGetExistingUnitPrice := skuBindInfo.UnitPrice == 0 && skuBindInfo.IsFocus == 1
|
||||||
|
|||||||
Reference in New Issue
Block a user