- sync sku to ebai, still have bugs.
This commit is contained in:
@@ -105,9 +105,9 @@ func GetEntity(db *DaoDB, item interface{}, cols ...string) (err error) {
|
||||
if db == nil {
|
||||
db = GetDB()
|
||||
}
|
||||
err = utils.CallFuncLogError(func() error {
|
||||
err = utils.CallFuncLogErrorIgnore(func() error {
|
||||
return db.db.Read(item, cols...)
|
||||
}, reflect.TypeOf(item).Name())
|
||||
}, reflect.TypeOf(item).Name(), orm.ErrNoRows)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"github.com/astaxie/beego/orm"
|
||||
)
|
||||
|
||||
// 这里面的函数要求实体是IDCUDL的,即含有ID, UpdatedAt, LastOperator, DeletedAt字段
|
||||
@@ -110,3 +111,29 @@ func DeleteEntityLogically(db *DaoDB, item interface{}, kvs map[string]interface
|
||||
model.FieldDeletedAt: time.Now(),
|
||||
}), userName, conditions)
|
||||
}
|
||||
|
||||
func AddStoreCategoryMap(db *DaoDB, storeID, categoryID int, vendorID int, vendorCategoryID string, status int8, userName string) (err error) {
|
||||
storeCat := &model.StoreSkuCategoryMap{
|
||||
StoreID: storeID,
|
||||
CategoryID: categoryID,
|
||||
}
|
||||
if err = GetEntity(db, storeCat, model.FieldStoreID, model.FieldCategoryID); err != nil && err != orm.ErrNoRows {
|
||||
return err
|
||||
}
|
||||
if vendorID == model.VendorIDEBAI {
|
||||
if vendorCategoryID != "" {
|
||||
storeCat.EbaiID = utils.Str2Int64(vendorCategoryID)
|
||||
}
|
||||
storeCat.EbaiSyncStatus = status
|
||||
} else {
|
||||
panic("unsupported vendor")
|
||||
}
|
||||
if storeCat.ID == 0 {
|
||||
WrapAddIDCULDEntity(storeCat, userName)
|
||||
err = CreateEntity(db, storeCat)
|
||||
} else {
|
||||
WrapUpdateULEntity(storeCat, userName)
|
||||
_, err = UpdateEntity(db, storeCat)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user