- 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
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@ const (
|
||||
FieldNameID = "NameID"
|
||||
FieldPlaceCode = "PlaceCode"
|
||||
|
||||
FieldCategoryID = "CategoryID"
|
||||
|
||||
FieldJdID = "JdID"
|
||||
FieldElmID = "ElmID"
|
||||
FieldEbaiID = "EbaiID"
|
||||
|
||||
@@ -9,8 +9,8 @@ const (
|
||||
type StoreSkuCategoryMap struct {
|
||||
ModelIDCULD
|
||||
|
||||
StoreID int `orm:"column(store_id)"`
|
||||
SkuCategoryID int `orm:"column(sku_category_id)"`
|
||||
StoreID int `orm:"column(store_id)"`
|
||||
CategoryID int `orm:"column(category_id)"`
|
||||
|
||||
ElmID int64 `orm:"column(elm_id);index"`
|
||||
EbaiID int64 `orm:"column(ebai_id);index"`
|
||||
@@ -21,7 +21,7 @@ type StoreSkuCategoryMap struct {
|
||||
|
||||
func (*StoreSkuCategoryMap) TableUnique() [][]string {
|
||||
return [][]string{
|
||||
[]string{"StoreID", "SkuCategoryID", "DeletedAt"},
|
||||
[]string{"StoreID", "CategoryID", "DeletedAt"},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user