生成门店商品备份表优化
This commit is contained in:
@@ -3848,7 +3848,7 @@ func getSkuNamePrice(db *dao.DaoDB, skuID int, orgPrice int64) (price int64, nam
|
|||||||
func BackUpStoreSkuBind(ctx *jxcontext.Context, isAsync, isContinueWhenError bool) (hint string, err error) {
|
func BackUpStoreSkuBind(ctx *jxcontext.Context, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||||
var (
|
var (
|
||||||
db = dao.GetDB()
|
db = dao.GetDB()
|
||||||
snapshotAt = time.Now()
|
snapshotAt = utils.Time2Date(time.Now())
|
||||||
)
|
)
|
||||||
storeSkuBindHis := &model.StoreSkuBindHistory{
|
storeSkuBindHis := &model.StoreSkuBindHistory{
|
||||||
SnapshotAt: snapshotAt.AddDate(0, 0, -3),
|
SnapshotAt: snapshotAt.AddDate(0, 0, -3),
|
||||||
@@ -3856,10 +3856,10 @@ func BackUpStoreSkuBind(ctx *jxcontext.Context, isAsync, isContinueWhenError boo
|
|||||||
storeSkuBindHis2 := &model.StoreSkuBindHistory{
|
storeSkuBindHis2 := &model.StoreSkuBindHistory{
|
||||||
SnapshotAt: snapshotAt,
|
SnapshotAt: snapshotAt,
|
||||||
}
|
}
|
||||||
dao.DeleteEntity(db, storeSkuBindHis, "SnapShotAt")
|
dao.DeleteEntity(db, storeSkuBindHis, "SnapshotAt")
|
||||||
dao.DeleteEntity(db, storeSkuBindHis2, "SnapShotAt")
|
dao.DeleteEntity(db, storeSkuBindHis2, "SnapshotAt")
|
||||||
storeList, err := dao.GetStoreList(db, nil, nil, nil, nil, "")
|
storeList, err := dao.GetStoreList(db, nil, nil, nil, nil, "")
|
||||||
task := tasksch.NewParallelTask("RefreshOrdersPriceInfo", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError), ctx,
|
task := tasksch.NewParallelTask("BackUpStoreSkuBind", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError), ctx,
|
||||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
store := batchItemList[0].(*model.Store)
|
store := batchItemList[0].(*model.Store)
|
||||||
storeSku, err := dao.GetStoresSkusInfo(db, []int{store.ID}, nil)
|
storeSku, err := dao.GetStoresSkusInfo(db, []int{store.ID}, nil)
|
||||||
@@ -3867,7 +3867,8 @@ func BackUpStoreSkuBind(ctx *jxcontext.Context, isAsync, isContinueWhenError boo
|
|||||||
storeSkuBindHis := &model.StoreSkuBindHistory{}
|
storeSkuBindHis := &model.StoreSkuBindHistory{}
|
||||||
storeSkuBindHis.StoreSkuBind = *v
|
storeSkuBindHis.StoreSkuBind = *v
|
||||||
storeSkuBindHis.StoreSkuBindID = v.ID
|
storeSkuBindHis.StoreSkuBindID = v.ID
|
||||||
storeSkuBindHis.SnapshotAt = snapshotAt
|
storeSkuBindHis.StoreSkuBind.ID = 0
|
||||||
|
storeSkuBindHis.SnapshotAt = utils.Time2Date(snapshotAt)
|
||||||
dao.CreateEntity(db, storeSkuBindHis)
|
dao.CreateEntity(db, storeSkuBindHis)
|
||||||
}
|
}
|
||||||
return retVal, err
|
return retVal, err
|
||||||
|
|||||||
@@ -283,17 +283,17 @@ func syncStoreSku() {
|
|||||||
// _, err = cms.CurVendorSync.FullSyncStoresSkus(jxcontext.AdminCtx, db, partner.GetMultiStoreVendorIDs(), nil, false, []int{27379}, true, true)
|
// _, err = cms.CurVendorSync.FullSyncStoresSkus(jxcontext.AdminCtx, db, partner.GetMultiStoreVendorIDs(), nil, false, []int{27379}, true, true)
|
||||||
errList.AddErr(err)
|
errList.AddErr(err)
|
||||||
case 1:
|
case 1:
|
||||||
errList.AddErr(cms.SetSingleStoreSkuSyncModifyStatus(db, []int{3}))
|
// errList.AddErr(cms.SetSingleStoreSkuSyncModifyStatus(db, []int{3}))
|
||||||
|
|
||||||
// errList.AddErr(cms.SetSingleStoreSkuSyncModifyStatus(db, partner.GetSingleStoreVendorIDs()))
|
errList.AddErr(cms.SetSingleStoreSkuSyncModifyStatus(db, partner.GetSingleStoreVendorIDs()))
|
||||||
_, err = cms.CurVendorSync.AmendAndPruneStoreStuff(jxcontext.AdminCtx, []int{3}, nil, false, true, cms.AmendPruneAll, false)
|
// _, err = cms.CurVendorSync.AmendAndPruneStoreStuff(jxcontext.AdminCtx, []int{3}, nil, false, true, cms.AmendPruneAll, false)
|
||||||
|
|
||||||
// _, err = cms.CurVendorSync.AmendAndPruneStoreStuff(jxcontext.AdminCtx, partner.GetSingleStoreVendorIDs(), nil, false, true, cms.AmendPruneAll, false)
|
_, err = cms.CurVendorSync.AmendAndPruneStoreStuff(jxcontext.AdminCtx, partner.GetSingleStoreVendorIDs(), nil, false, true, cms.AmendPruneAll, false)
|
||||||
errList.AddErr(err)
|
errList.AddErr(err)
|
||||||
|
|
||||||
SaveImportantTaskID(TaskNameSyncStoreSku, SpecialTaskID)
|
SaveImportantTaskID(TaskNameSyncStoreSku, SpecialTaskID)
|
||||||
taskID, err2 := cms.CurVendorSync.SyncStoresSkus2(jxcontext.AdminCtx, nil, 0, db, []int{3}, nil, false, nil, nil, syncFlag, true, true)
|
// taskID, err2 := cms.CurVendorSync.SyncStoresSkus2(jxcontext.AdminCtx, nil, 0, db, []int{3}, nil, false, nil, nil, syncFlag, true, true)
|
||||||
// taskID, err2 := cms.CurVendorSync.SyncStoresSkus2(jxcontext.AdminCtx, nil, 0, db, partner.GetSingleStoreVendorIDs(), nil, false, nil, nil, syncFlag, true, true)
|
taskID, err2 := cms.CurVendorSync.SyncStoresSkus2(jxcontext.AdminCtx, nil, 0, db, partner.GetSingleStoreVendorIDs(), nil, false, nil, nil, syncFlag, true, true)
|
||||||
|
|
||||||
errList.AddErr(err2)
|
errList.AddErr(err2)
|
||||||
SaveImportantTaskID(TaskNameSyncStoreSku, taskID)
|
SaveImportantTaskID(TaskNameSyncStoreSku, taskID)
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ type StoreSkuBindHistory struct {
|
|||||||
|
|
||||||
func (*StoreSkuBindHistory) TableUnique() [][]string {
|
func (*StoreSkuBindHistory) TableUnique() [][]string {
|
||||||
return [][]string{
|
return [][]string{
|
||||||
[]string{"StoreID", "SkuID", "DeletedAt"},
|
[]string{"StoreID", "SkuID", "DeletedAt", "SnapshotAt"},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user