- sku category.

This commit is contained in:
gazebo
2018-09-10 07:47:18 +08:00
parent d8907cf010
commit ce56d774a2
5 changed files with 82 additions and 21 deletions

View File

@@ -237,10 +237,13 @@ func CreateStore(store *model.Store, userName string) (id int, err error) {
}
func SyncStore2Vendor(db *dao.DaoDB, vendorID int, store *model.Store, isForce bool, userName string) (err error) {
var (
storeMaps []*model.StoreMap
)
if db == nil {
db = dao.GetDB()
}
storeMaps, err := GetStoreVendorMaps(db, store.ID, -1)
err = dao.GetEntities(db, &storeMaps, utils.Params2Map("StoreID", store.ID), true)
if err == nil {
// globals.SugarLogger.Debug(utils.Format4Output(store, false))
copiedStore := *store
@@ -258,12 +261,13 @@ func SyncStore2Vendor(db *dao.DaoDB, vendorID int, store *model.Store, isForce b
}
func GetStoreVendorMaps(db *dao.DaoDB, storeID int, vendorID int) (storeMaps []*model.StoreMap, err error) {
if vendorID == -1 {
err = dao.GetRows(db, &storeMaps, "SELECT * FROM store_map WHERE store_id = ?", storeID)
} else {
err = dao.GetRows(db, &storeMaps, "SELECT * FROM store_map WHERE store_id = ? AND vendor_id = ?", storeID, vendorID)
cond := map[string]interface{}{
"StoreID": storeID,
}
return storeMaps, err
if vendorID != -1 {
cond["VendorID"] = vendorID
}
return storeMaps, dao.GetEntities(db, &storeMaps, cond, false)
}
func AddStoreVendorMap(db *dao.DaoDB, storeMap *model.StoreMap, userName string) (outStoreMap *model.StoreMap, err error) {
@@ -281,7 +285,7 @@ func AddStoreVendorMap(db *dao.DaoDB, storeMap *model.StoreMap, userName string)
func DeleteStoreVendorMap(db *dao.DaoDB, storeID, vendorID int, userName string) (num int64, err error) {
storeMap := &model.StoreMap{}
return dao.DeleteEntity(db, storeMap, utils.Params2Map("StoreID", storeID, "VendorID", vendorID))
return dao.DeleteEntity(db, storeMap, utils.Params2Map("StoreID", storeID, "VendorID", vendorID), "")
}
func UpdateStoreVendorMap(db *dao.DaoDB, storeID, vendorID int, payload map[string]interface{}, userName string) (num int64, err error) {