This commit is contained in:
苏尹岚
2021-03-26 17:31:10 +08:00
parent d56beac926
commit 8cb61ef62d
5 changed files with 69 additions and 45 deletions

View File

@@ -2052,9 +2052,9 @@ func CreateUpcSkuByExcelBin(ctx *jxcontext.Context, reader io.Reader, categoryID
case 1:
taskFunc := func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
var (
v = batchItemList[0].(*model.SkuName)
skuNames []model.SkuName
skuName = &model.SkuNameExt{
v = batchItemList[0].(*model.SkuName)
sku *model.SkuName
skuName = &model.SkuNameExt{
SkuName: model.SkuName{},
Skus: []*model.SkuWithVendor{
&model.SkuWithVendor{
@@ -2078,8 +2078,7 @@ func CreateUpcSkuByExcelBin(ctx *jxcontext.Context, reader io.Reader, categoryID
SELECT * FROM sku_name WHERE upc = ? AND deleted_at = ?
`
sqlParams := []interface{}{*v.Upc, utils.DefaultTimeValue}
err = dao.GetRows(db, &skuNames, sql, sqlParams)
if len(skuNames) > 0 {
if err = dao.GetRow(db, &sku, sql, sqlParams); err == nil && sku != nil {
// retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, "商品在京西库中已存在!")}
return retVal, err
}
@@ -2123,32 +2122,27 @@ func CreateUpcSkuByExcelBin(ctx *jxcontext.Context, reader io.Reader, categoryID
}
}
if v.Price == 0 {
result, err := api.AliUpcAPI.GetAliUpcInfo(*v.Upc)
if err != nil {
retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, err.Error())}
return retVal, err
}
if result.Price == "" {
if productInfo.Price != 0 {
skuName.Price = productInfo.Price
} else {
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)
// 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
}
// if getNetUpcInfo.Unit != "" {
// skuName.Unit = getNetUpcInfo.Unit
// } else {
retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, "未查询到商品单位,请补充商品单位!")}
return retVal, err
// }
} else {
skuName.Unit = productInfo.Unit
}
@@ -2168,18 +2162,18 @@ func CreateUpcSkuByExcelBin(ctx *jxcontext.Context, reader io.Reader, categoryID
}
} 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
}
// 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))))
@@ -2190,11 +2184,11 @@ func CreateUpcSkuByExcelBin(ctx *jxcontext.Context, reader io.Reader, categoryID
}
}
if productInfo.SpecUnit == "" {
if getNetUpcInfo.SpecUnit != "" {
skuName.Skus[0].SpecUnit = getNetUpcInfo.SpecUnit
} else {
skuName.Skus[0].SpecUnit = model.SpecUnitNames[0]
}
// if getNetUpcInfo.SpecUnit != "" {
// skuName.Skus[0].SpecUnit = getNetUpcInfo.SpecUnit
// } else {
skuName.Skus[0].SpecUnit = model.SpecUnitNames[0]
// }
} else {
skuName.Skus[0].SpecUnit = productInfo.SpecUnit
}

View File

@@ -21,7 +21,7 @@ func init() {
partner.InitStoreAcctManager(FixedStoreAcctManager)
}
func (s *StoreAcctManager) InsertStoreAcctIncome(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID string) (err error) {
func (s *StoreAcctManager) InsertStoreAcctIncome(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID string, expendID int) (err error) {
var (
userID, userName string
goodsVendorOrderID string
@@ -49,6 +49,9 @@ func (s *StoreAcctManager) InsertStoreAcctIncome(ctx *jxcontext.Context, storeID
VendorOrderID: goodsVendorOrderID,
}
dao.WrapAddIDCULEntity(storeAcctIncome, userName)
if expendID != 0 {
storeAcctIncome.ExpID = expendID
}
err = dao.CreateEntity(db, storeAcctIncome)
globals.SugarLogger.Debugf("InsertStoreAcctIncome orderID: [%v] , price :[%v] , type :[%v]", vendorOrderID, price, acctType)
return err
@@ -80,7 +83,7 @@ func (s *StoreAcctManager) InsertStoreAcctExpend(ctx *jxcontext.Context, storeID
}
dao.WrapAddIDCULEntity(storeAcctExpend, userName)
if expendID != 0 {
storeAcctExpend.ExpID = expendID
}
err = dao.CreateEntity(db, storeAcctExpend)
globals.SugarLogger.Debugf("InsertStoreAcctExpend orderID: [%v] , price :[%v] , type :[%v]", vendorOrderID, price, acctType)
@@ -140,9 +143,9 @@ func (s *StoreAcctManager) InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx *j
return err
}
func (s *StoreAcctManager) InsertStoreAcctIncomeAndUpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID string) (err error) {
func (s *StoreAcctManager) InsertStoreAcctIncomeAndUpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID string, expendID int) (err error) {
utils.CallFuncAsync(func() {
if err = s.InsertStoreAcctIncome(ctx, storeID, price, acctType, vendorOrderID); err == nil {
if err = s.InsertStoreAcctIncome(ctx, storeID, price, acctType, vendorOrderID, expendID); err == nil {
s.UpdateStoreAcctBalance(ctx, storeID, price, true)
}
})