加入ThingMap表示商品库的同步信息

This commit is contained in:
gazebo
2019-12-05 09:04:23 +08:00
parent 527659bf55
commit e742d88efd
4 changed files with 67 additions and 23 deletions

View File

@@ -716,14 +716,58 @@ func GetTimeMixByInt(begin1, end1, begin2, end2 int16) (beginAt, endAt int16) {
return beginAt, endAt
}
func OnCreateThing(db *dao.DaoDB, thingID int64, thingType int8) (err error) {
return err
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(db *dao.DaoDB, thingID int64, thingType int8) (err error) {
return err
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(db *dao.DaoDB, thingID int64, thingType int8) (err error) {
return err
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
}