价格参考
This commit is contained in:
@@ -43,25 +43,27 @@ 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)
|
||||||
dao.Begin(db)
|
if len(priceReferSnapshot) > 0 {
|
||||||
defer func() {
|
dao.Begin(db)
|
||||||
if r := recover(); r != nil || err != nil {
|
defer func() {
|
||||||
dao.Rollback(db)
|
if r := recover(); r != nil || err != nil {
|
||||||
if r != nil {
|
dao.Rollback(db)
|
||||||
panic(r)
|
if r != nil {
|
||||||
|
panic(r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
dao.DeleteEntity(db, priceReferSnapshot[0], "SnapshotAt")
|
||||||
|
for _, v := range priceReferSnapshot {
|
||||||
|
dao.WrapAddIDCULDEntity(v, ctx.GetUserName())
|
||||||
|
v.SnapshotAt = snapshotAt
|
||||||
|
if err = dao.CreateEntity(db, v); err != nil {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
dao.Commit(db)
|
||||||
for _, v := range priceReferSnapshot {
|
|
||||||
dao.WrapAddIDCULDEntity(v, ctx.GetUserName())
|
|
||||||
v.SnapshotAt = snapshotAt
|
|
||||||
dao.DeleteEntity(db, v, "CityCode", "SkuID", "SnapshotAt")
|
|
||||||
if err = dao.CreateEntity(db, v); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
dao.Commit(db)
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user