标品查询存到库里

This commit is contained in:
苏尹岚
2020-04-15 16:53:04 +08:00
parent 9f6cb18168
commit 3301ee8536
2 changed files with 42 additions and 1 deletions

View File

@@ -11,6 +11,8 @@ import (
"strings"
"time"
"git.rosy.net.cn/baseapi/platformapi/aliupcapi"
"git.rosy.net.cn/baseapi"
"git.rosy.net.cn/baseapi/platformapi/dingdingapi"
"git.rosy.net.cn/baseapi/platformapi/ebaiapi"
@@ -1882,7 +1884,14 @@ func CreateUpcSkuByExcelBin(ctx *jxcontext.Context, reader io.Reader, categoryID
return retVal, err
}
if len(productInfos) == 0 {
result, _ := api.AliUpcAPI.GetAliUpcInfo(*v.Upc)
var result *aliupcapi.GetAliUpcInfoResult
upcDepot, err := dao.GetUpcDepot(db, *v.Upc)
if upcDepot == nil {
result, _ = api.AliUpcAPI.GetAliUpcInfo(*v.Upc)
err = dao.InsertUpcDepot(db, result)
} else {
result = upcDepot
}
if result == nil {
retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, "未在标品库查到此商品,请手动创建!")}
return retVal, err

View File

@@ -1,6 +1,7 @@
package dao
import (
"git.rosy.net.cn/baseapi/platformapi/aliupcapi"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/model"
)
@@ -342,3 +343,34 @@ func GetSkuNamePlaces(db *DaoDB, nameIDs, skuIDs []int) (skuPlaceList []*SkuName
err = GetRows(db, &skuPlaceList, sql, sqlParams...)
return skuPlaceList, err
}
func GetUpcDepot(db *DaoDB, upc string) (result *aliupcapi.GetAliUpcInfoResult, err error) {
sql := `
SELECT * FROM upc_depot WHERE code = ?
`
sqlParams := []interface{}{upc}
err = GetRows(db, &result, sql, sqlParams...)
return result, err
}
func InsertUpcDepot(db *DaoDB, result *aliupcapi.GetAliUpcInfoResult) (err error) {
sql := `
INSERT INTO upc_depot (code, goods_name, manu_name, manu_address, spec, price, img, goods_type, ycg, trade_mark, remark)
VALUES ?,?,?,?,?,?,?,?,?,?,?
`
sqlParams := []interface{}{
result.Code,
result.GoodsName,
result.ManuName,
result.ManuAddress,
result.Spec,
result.Price,
result.Img,
result.GoodsType,
result.Ycg,
result.Trademark,
result.Remark,
}
_, err = ExecuteSQL(db, sql, sqlParams)
return err
}