- sync sku to ebai, still have bugs.

This commit is contained in:
gazebo
2018-09-26 22:30:19 +08:00
parent 49f2d0c969
commit 73a5f7241e
6 changed files with 349 additions and 108 deletions

View File

@@ -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
}

View File

@@ -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
}