- sync store after bind vendor store.

This commit is contained in:
gazebo
2018-09-10 18:34:50 +08:00
parent 834b74a09d
commit 9be4b9fdd9
2 changed files with 30 additions and 28 deletions

View File

@@ -3,6 +3,7 @@ package cms
import (
"errors"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/jxcallback/scheduler/basesch"
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/business/model/dao"
@@ -50,3 +51,27 @@ func (v *VendorSync) SyncCategory(categoryID int, isForce bool, userName string)
}
return err
}
func (v *VendorSync) SyncStore(db *dao.DaoDB, vendorID int, store *model.Store, isForce bool, userName string) (err error) {
var (
storeMaps []*model.StoreMap
)
if db == nil {
db = dao.GetDB()
}
err = dao.GetEntities(db, &storeMaps, utils.Params2Map(model.FieldStoreID, store.ID), true)
if err == nil {
// globals.SugarLogger.Debug(utils.Format4Output(store, false))
copiedStore := *store
for _, storeMap := range storeMaps {
if (vendorID == -1 || storeMap.VendorID == vendorID) && (isForce || storeMap.SyncStatus != 0) {
copiedStore.Status = mergeStoreStatus(store.Status, storeMap.Status)
if err = GetPurchaseHandler(storeMap.VendorID).UpdateStore(storeMap.VendorStoreID, &copiedStore, userName); err == nil {
storeMap.SyncStatus = 0
dao.UpdateEntity(db, storeMap, model.FieldSyncStatus)
}
}
}
}
return err
}