价格参考
This commit is contained in:
@@ -43,8 +43,9 @@ func StatisticsReportForStoreSkusPrice(ctx *jxcontext.Context, cityCodes, skuIDs
|
|||||||
|
|
||||||
func BeginSavePriceRefer(ctx *jxcontext.Context, cityCodes, skuIDs []int) (err error) {
|
func BeginSavePriceRefer(ctx *jxcontext.Context, cityCodes, skuIDs []int) (err error) {
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
snapshotAt := utils.Str2Time(time.Now().Format("2006-01-02"))
|
snapshotAt := utils.Time2Date(time.Now())
|
||||||
priceReferSnapshot, err := dao.GetStatisticsReportForStoreSkusPrice(db, cityCodes, skuIDs)
|
priceReferSnapshot, err := dao.GetStatisticsReportForStoreSkusPrice(db, cityCodes, skuIDs)
|
||||||
|
if len(priceReferSnapshot) > 0 {
|
||||||
dao.Begin(db)
|
dao.Begin(db)
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil || err != nil {
|
if r := recover(); r != nil || err != nil {
|
||||||
@@ -54,14 +55,15 @@ func BeginSavePriceRefer(ctx *jxcontext.Context, cityCodes, skuIDs []int) (err e
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
dao.DeleteEntity(db, priceReferSnapshot[0], "SnapshotAt")
|
||||||
for _, v := range priceReferSnapshot {
|
for _, v := range priceReferSnapshot {
|
||||||
dao.WrapAddIDCULDEntity(v, ctx.GetUserName())
|
dao.WrapAddIDCULDEntity(v, ctx.GetUserName())
|
||||||
v.SnapshotAt = snapshotAt
|
v.SnapshotAt = snapshotAt
|
||||||
dao.DeleteEntity(db, v, "CityCode", "SkuID", "SnapshotAt")
|
|
||||||
if err = dao.CreateEntity(db, v); err != nil {
|
if err = dao.CreateEntity(db, v); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dao.Commit(db)
|
dao.Commit(db)
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user