Merge branch 'mark' of e.coding.net:rosydev/jx-callback into mark

This commit is contained in:
gazebo
2019-12-12 15:02:17 +08:00
12 changed files with 86 additions and 65 deletions

View File

@@ -2543,9 +2543,14 @@ func GetStorePriceScore(ctx *jxcontext.Context, storeIDs []int, fromScore, toSco
return pagedInfo, err
}
func CreateStorePriceScore(ctx *jxcontext.Context) (err error) {
func CreateStorePriceScore(ctx *jxcontext.Context, forRefresh bool) (err error) {
db := dao.GetDB()
snapshotAt := utils.Time2Date(time.Now())
var snapshotAt time.Time
if forRefresh {
snapshotAt = utils.Time2Date(time.Now().AddDate(0, 0, -1))
} else {
snapshotAt = utils.Time2Date(time.Now())
}
storePriceScoreSnapshot, err := dao.GetStorePriceScoreSnapshot(db, snapshotAt)
if len(storePriceScoreSnapshot) > 0 {
dao.Begin(db)
@@ -2557,7 +2562,10 @@ func CreateStorePriceScore(ctx *jxcontext.Context) (err error) {
}
}
}()
dao.DeleteEntity(db, storePriceScoreSnapshot[0], "SnapshotAt")
priceReferSnapshotDeleteHis := &model.StorePriceScoreSnapshot{SnapshotAt: snapshotAt.AddDate(0, -1, 0)}
priceReferSnapshotDelete := &model.StorePriceScoreSnapshot{SnapshotAt: snapshotAt}
dao.DeleteEntity(db, priceReferSnapshotDeleteHis, "SnapshotAt")
dao.DeleteEntity(db, priceReferSnapshotDelete, "SnapshotAt")
for _, v := range storePriceScoreSnapshot {
dao.WrapAddIDCULDEntity(v, ctx.GetUserName())
v.SnapshotAt = snapshotAt

View File

@@ -2153,6 +2153,9 @@ func GetTopCategorysByStoreIDs(ctx *jxcontext.Context, storeIDs []int) (skuCateg
func RefershStoreSkusMidPrice(ctx *jxcontext.Context, storeIDs []int) (err error) {
db := dao.GetDB()
_, err = dao.RefershStoreSkusMidPrice(db, storeIDs)
if err == nil {
CreateStorePriceScore(ctx, true)
}
return err
}

View File

@@ -140,7 +140,7 @@ func Init() {
report.BeginSavePriceRefer(jxcontext.AdminCtx, nil, nil)
}, createStorePriceTimeList)
ScheduleTimerFunc("CreateStorePriceScore", func() {
cms.CreateStorePriceScore(jxcontext.AdminCtx)
cms.CreateStorePriceScore(jxcontext.AdminCtx, false)
}, openRemoteStoreTimeList)
}
ScheduleTimerFunc("AutoSaleStoreSku", func() {

View File

@@ -64,10 +64,14 @@ func BeginSavePriceRefer(ctx *jxcontext.Context, cityCodes, skuIDs []int) (err e
}
}
}()
dao.DeleteEntity(db, priceReferSnapshot[0], "SnapshotAt")
priceReferSnapshotDeleteHis := &model.PriceReferSnapshot{SnapshotAt: snapshotAt.AddDate(0, -1, 0)}
priceReferSnapshotDelete := &model.PriceReferSnapshot{SnapshotAt: snapshotAt}
dao.DeleteEntity(db, priceReferSnapshotDeleteHis, "SnapshotAt")
dao.DeleteEntity(db, priceReferSnapshotDelete, "SnapshotAt")
for _, v := range priceReferSnapshot {
dao.WrapAddIDCULDEntity(v, ctx.GetUserName())
v.SnapshotAt = snapshotAt
fmt.Println(v)
if err = dao.CreateEntity(db, v); err != nil {
return err
}