diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index 9506e94c0..6e9702138 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -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) diff --git a/business/jxstore/cms/sync2.go b/business/jxstore/cms/sync2.go index 06508a7fc..2cdb89960 100644 --- a/business/jxstore/cms/sync2.go +++ b/business/jxstore/cms/sync2.go @@ -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") + } +}