updateThingMapEntity

This commit is contained in:
gazebo
2019-12-11 10:13:35 +08:00
parent 6c98fecca6
commit a3e1521bb4
2 changed files with 28 additions and 0 deletions

View File

@@ -315,6 +315,7 @@ func getGetStoresSkusBaseSQL(db *dao.DaoDB, storeIDs, skuIDs []int, isFocus bool
return "", nil, err
}
sql += " AND ( 1 = 0"
// TODO
if params["jdSyncStatus"] != nil && realVendorMap[model.VendorIDJD] == 1 {
sql += " OR (t4.jd_sync_status & ? <> 0 AND t2.jd_id <> 0 AND t1.status = ? AND t2.status = ?)"
sqlParams = append(sqlParams, params["jdSyncStatus"], model.SkuStatusNormal, model.SkuStatusNormal)

View File

@@ -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")
}
}