updateThingMapEntity
This commit is contained in:
@@ -315,6 +315,7 @@ func getGetStoresSkusBaseSQL(db *dao.DaoDB, storeIDs, skuIDs []int, isFocus bool
|
|||||||
return "", nil, err
|
return "", nil, err
|
||||||
}
|
}
|
||||||
sql += " AND ( 1 = 0"
|
sql += " AND ( 1 = 0"
|
||||||
|
// TODO
|
||||||
if params["jdSyncStatus"] != nil && realVendorMap[model.VendorIDJD] == 1 {
|
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 = ?)"
|
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)
|
sqlParams = append(sqlParams, params["jdSyncStatus"], model.SkuStatusNormal, model.SkuStatusNormal)
|
||||||
|
|||||||
@@ -167,6 +167,8 @@ func OnCreateThing(ctx *jxcontext.Context, db *dao.DaoDB, thingID int64, thingTy
|
|||||||
}
|
}
|
||||||
dao.WrapAddIDCULDEntity(thingMap, ctx.GetUserName())
|
dao.WrapAddIDCULDEntity(thingMap, ctx.GetUserName())
|
||||||
errList.AddErr(dao.CreateEntity(db, thingMap))
|
errList.AddErr(dao.CreateEntity(db, thingMap))
|
||||||
|
|
||||||
|
updateThingMapEntity(db, thingMap)
|
||||||
}
|
}
|
||||||
if globals.IsUseThingMap {
|
if globals.IsUseThingMap {
|
||||||
err = errList.GetErrListAsOne()
|
err = errList.GetErrListAsOne()
|
||||||
@@ -192,6 +194,8 @@ func OnUpdateThing(ctx *jxcontext.Context, db *dao.DaoDB, thingID int64, thingTy
|
|||||||
thingMap.LastOperator = ctx.GetUserName()
|
thingMap.LastOperator = ctx.GetUserName()
|
||||||
_, err2 = dao.UpdateEntity(db, thingMap)
|
_, err2 = dao.UpdateEntity(db, thingMap)
|
||||||
errList.AddErr(err2)
|
errList.AddErr(err2)
|
||||||
|
|
||||||
|
updateThingMapEntity(db, thingMap)
|
||||||
} else if !dao.IsNoRowsError(err2) {
|
} else if !dao.IsNoRowsError(err2) {
|
||||||
errList.AddErr(err2)
|
errList.AddErr(err2)
|
||||||
}
|
}
|
||||||
@@ -225,6 +229,8 @@ func OnDeleteThing(ctx *jxcontext.Context, db *dao.DaoDB, thingID int64, thingTy
|
|||||||
thingMap.LastOperator = ctx.GetUserName()
|
thingMap.LastOperator = ctx.GetUserName()
|
||||||
_, err2 = dao.UpdateEntity(db, thingMap)
|
_, err2 = dao.UpdateEntity(db, thingMap)
|
||||||
errList.AddErr(err2)
|
errList.AddErr(err2)
|
||||||
|
|
||||||
|
updateThingMapEntity(db, thingMap)
|
||||||
} else if !dao.IsNoRowsError(err2) {
|
} else if !dao.IsNoRowsError(err2) {
|
||||||
errList.AddErr(err2)
|
errList.AddErr(err2)
|
||||||
}
|
}
|
||||||
@@ -259,6 +265,7 @@ func SkuVendor2ThingMap(sku *dao.StoreSkuSyncInfo) (thingMap *model.ThingMap) {
|
|||||||
SyncStatus: sku.SkuSyncStatus,
|
SyncStatus: sku.SkuSyncStatus,
|
||||||
VendorThingID: sku.VendorSkuID,
|
VendorThingID: sku.VendorSkuID,
|
||||||
}
|
}
|
||||||
|
thingMap.DeletedAt = utils.DefaultTimeValue
|
||||||
thingMap.ID = sku.BindID // 一定要赋值
|
thingMap.ID = sku.BindID // 一定要赋值
|
||||||
return thingMap
|
return thingMap
|
||||||
}
|
}
|
||||||
@@ -288,6 +295,26 @@ func OnThingSync(ctx *jxcontext.Context, db *dao.DaoDB, thingMap *model.ThingMap
|
|||||||
thingMap.UpdatedAt = time.Now()
|
thingMap.UpdatedAt = time.Now()
|
||||||
thingMap.Remark = ""
|
thingMap.Remark = ""
|
||||||
_, err = dao.UpdateEntity(db, thingMap, updateFields...)
|
_, err = dao.UpdateEntity(db, thingMap, updateFields...)
|
||||||
|
|
||||||
|
updateThingMapEntity(db, thingMap)
|
||||||
}
|
}
|
||||||
return err
|
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