价格统计
This commit is contained in:
@@ -66,9 +66,8 @@ func BeginSavePriceRefer(ctx *jxcontext.Context, cityCodes, skuIDs []int) (err e
|
||||
}
|
||||
}
|
||||
}()
|
||||
priceReferSnapshotDeleteHis := &model.PriceReferSnapshot{SnapshotAt: snapshotAt.AddDate(0, -1, 0)}
|
||||
dao.DeletePriceReferHistory(db, utils.Time2Date(snapshotAt.AddDate(0, 0, -7)))
|
||||
priceReferSnapshotDelete := &model.PriceReferSnapshot{SnapshotAt: snapshotAt}
|
||||
dao.DeleteEntity(db, priceReferSnapshotDeleteHis, "SnapshotAt")
|
||||
dao.DeleteEntity(db, priceReferSnapshotDelete, "SnapshotAt")
|
||||
task := tasksch.NewParallelTask("生成价格统计", tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
@@ -82,26 +81,5 @@ func BeginSavePriceRefer(ctx *jxcontext.Context, cityCodes, skuIDs []int) (err e
|
||||
_, err = task.GetResult(0)
|
||||
dao.Commit(db)
|
||||
}
|
||||
priceReferList, _ := dao.GetPriceReferSnapshotNoPage(db, nil, nil, nil, utils.Time2Date(time.Now().AddDate(0, 0, -1)))
|
||||
if len(priceReferList) > 0 {
|
||||
dao.Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil || err != nil {
|
||||
dao.Rollback(db)
|
||||
if r != nil {
|
||||
panic(r)
|
||||
}
|
||||
}
|
||||
}()
|
||||
for _, v := range priceReferList {
|
||||
priceRefer, _ := dao.GetPriceReferUnitPrice(db, v.CityCode, v.NameID, v.SnapshotAt)
|
||||
v.MidUnitPrice = priceRefer.MidUnitPrice
|
||||
v.MaxUnitPrice = priceRefer.MaxUnitPrice
|
||||
v.MinUnitPrice = priceRefer.MinUnitPrice
|
||||
v.AvgUnitPrice = priceRefer.AvgUnitPrice
|
||||
_, err = dao.UpdateEntity(db, v, "MidUnitPrice", "MaxUnitPrice", "AvgUnitPrice", "MinUnitPrice")
|
||||
}
|
||||
dao.Commit(db)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user