updateThingMapEntity
This commit is contained in:
@@ -167,6 +167,8 @@ func OnCreateThing(ctx *jxcontext.Context, db *dao.DaoDB, thingID int64, thingTy
|
||||
}
|
||||
dao.WrapAddIDCULDEntity(thingMap, ctx.GetUserName())
|
||||
errList.AddErr(dao.CreateEntity(db, thingMap))
|
||||
|
||||
updateThingMapEntity(db, thingMap)
|
||||
}
|
||||
if globals.IsUseThingMap {
|
||||
err = errList.GetErrListAsOne()
|
||||
@@ -192,6 +194,8 @@ func OnUpdateThing(ctx *jxcontext.Context, db *dao.DaoDB, thingID int64, thingTy
|
||||
thingMap.LastOperator = ctx.GetUserName()
|
||||
_, err2 = dao.UpdateEntity(db, thingMap)
|
||||
errList.AddErr(err2)
|
||||
|
||||
updateThingMapEntity(db, thingMap)
|
||||
} else if !dao.IsNoRowsError(err2) {
|
||||
errList.AddErr(err2)
|
||||
}
|
||||
@@ -225,6 +229,8 @@ func OnDeleteThing(ctx *jxcontext.Context, db *dao.DaoDB, thingID int64, thingTy
|
||||
thingMap.LastOperator = ctx.GetUserName()
|
||||
_, err2 = dao.UpdateEntity(db, thingMap)
|
||||
errList.AddErr(err2)
|
||||
|
||||
updateThingMapEntity(db, thingMap)
|
||||
} else if !dao.IsNoRowsError(err2) {
|
||||
errList.AddErr(err2)
|
||||
}
|
||||
@@ -259,6 +265,7 @@ func SkuVendor2ThingMap(sku *dao.StoreSkuSyncInfo) (thingMap *model.ThingMap) {
|
||||
SyncStatus: sku.SkuSyncStatus,
|
||||
VendorThingID: sku.VendorSkuID,
|
||||
}
|
||||
thingMap.DeletedAt = utils.DefaultTimeValue
|
||||
thingMap.ID = sku.BindID // 一定要赋值
|
||||
return thingMap
|
||||
}
|
||||
@@ -288,6 +295,26 @@ func OnThingSync(ctx *jxcontext.Context, db *dao.DaoDB, thingMap *model.ThingMap
|
||||
thingMap.UpdatedAt = time.Now()
|
||||
thingMap.Remark = ""
|
||||
_, err = dao.UpdateEntity(db, thingMap, updateFields...)
|
||||
|
||||
updateThingMapEntity(db, thingMap)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func updateThingMapEntity(db *dao.DaoDB, thingMap *model.ThingMap) {
|
||||
if thingMap.ThingType == model.ThingTypeCategory {
|
||||
cat := &model.SkuCategory{
|
||||
JdID: utils.Str2Int64WithDefault(thingMap.VendorThingID, 0),
|
||||
JdSyncStatus: thingMap.SyncStatus,
|
||||
}
|
||||
cat.ID = int(thingMap.ThingID)
|
||||
dao.UpdateEntity(db, cat, "JdID", "JdSyncStatus")
|
||||
} else if thingMap.ThingType == model.ThingTypeSku {
|
||||
sku := &model.Sku{
|
||||
JdID: utils.Str2Int64WithDefault(thingMap.VendorThingID, 0),
|
||||
JdSyncStatus: thingMap.SyncStatus,
|
||||
}
|
||||
sku.ID = int(thingMap.ThingID)
|
||||
dao.UpdateEntity(db, sku, "JdID", "JdSyncStatus")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user