sync2.SyncCategories, SyncReorderCategories

This commit is contained in:
gazebo
2019-12-05 15:30:05 +08:00
parent 1c05e4c1da
commit 6066e49014
8 changed files with 325 additions and 113 deletions

View File

@@ -38,11 +38,6 @@ type SingleStoreHandlerWrapper struct {
partner.ISingleStoreHandler
}
type tMultiStoreVendorInfo struct {
VendorID int
OrgCode string
}
var (
CurVendorSync VendorSync
)
@@ -101,20 +96,6 @@ func (v *VendorSync) GetSingleStoreHandler(vendorID int) partner.ISingleStoreHan
return nil
}
func getMultiStoreVendorInfoList() (list []*tMultiStoreVendorInfo) {
vendorIDs := partner.GetMultiStoreVendorIDs()
for _, vendorID := range vendorIDs {
orgCodeList := partner.CurAPIManager.GetAppOrgCodeList(vendorID)
for _, v := range orgCodeList {
list = append(list, &tMultiStoreVendorInfo{
VendorID: vendorID,
OrgCode: v,
})
}
}
return list
}
func (v *VendorSync) syncCategories(ctx *jxcontext.Context, parentTask tasksch.ITask, vendorID int, db *dao.DaoDB, cats []*model.SkuCategory, userName string) (err error) {
multiStoresHandler := v.GetMultiStoreHandler(vendorID)
syncStatusFieldName := dao.GetSyncStatusStructField(model.VendorNames[vendorID])
@@ -715,59 +696,3 @@ func GetTimeMixByInt(begin1, end1, begin2, end2 int16) (beginAt, endAt int16) {
}
return beginAt, endAt
}
func OnCreateThing(ctx *jxcontext.Context, db *dao.DaoDB, thingID int64, thingType int8) (err error) {
for _, v := range getMultiStoreVendorInfoList() {
thingMap := &model.ThingMap{
ThingID: thingID,
ThingType: thingType,
VendorID: v.VendorID,
VendorOrgCode: v.OrgCode,
SyncStatus: model.SyncFlagNewMask,
}
dao.WrapAddIDCULDEntity(thingMap, ctx.GetUserName())
err = dao.CreateEntity(db, thingMap)
}
return nil
}
func OnUpdateThing(ctx *jxcontext.Context, db *dao.DaoDB, thingID int64, thingType int8) (err error) {
for _, v := range getMultiStoreVendorInfoList() {
thingMap := &model.ThingMap{
ThingID: thingID,
ThingType: thingType,
VendorID: v.VendorID,
VendorOrgCode: v.OrgCode,
}
thingMap.DeletedAt = utils.DefaultTimeValue
if err = dao.GetEntity(db, thingMap, "ThingID", "ThingType", "VendorID", "VendorOrgCode", model.FieldDeletedAt); err == nil {
thingMap.SyncStatus |= model.SyncFlagModifiedMask
thingMap.LastOperator = ctx.GetUserName()
_, err = dao.UpdateEntity(db, thingMap)
}
}
return nil
}
func OnDeleteThing(ctx *jxcontext.Context, db *dao.DaoDB, thingID int64, thingType int8) (err error) {
for _, v := range getMultiStoreVendorInfoList() {
thingMap := &model.ThingMap{
ThingID: thingID,
ThingType: thingType,
VendorID: v.VendorID,
VendorOrgCode: v.OrgCode,
}
thingMap.DeletedAt = utils.DefaultTimeValue
if err = dao.GetEntity(db, thingMap, "ThingID", "ThingType", "VendorID", "VendorOrgCode", model.FieldDeletedAt); err == nil {
if model.IsSyncStatusNew(thingMap.SyncStatus) {
thingMap.SyncStatus = 0
} else {
thingMap.SyncStatus |= model.SyncFlagDeletedMask
}
_, err = dao.DeleteEntityLogically(db, thingMap, map[string]interface{}{
model.FieldSyncStatus: thingMap.SyncStatus,
}, ctx.GetUserName(), nil)
}
}
return nil
}