价格参考
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) {
|
||||
db := dao.GetDB()
|
||||
snapshotAt := utils.Str2Time(time.Now().Format("2006-01-02"))
|
||||
snapshotAt := utils.Time2Date(time.Now())
|
||||
priceReferSnapshot, err := dao.GetStatisticsReportForStoreSkusPrice(db, cityCodes, skuIDs)
|
||||
dao.Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil || err != nil {
|
||||
dao.Rollback(db)
|
||||
if r != nil {
|
||||
panic(r)
|
||||
if len(priceReferSnapshot) > 0 {
|
||||
dao.Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil || err != nil {
|
||||
dao.Rollback(db)
|
||||
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
|
||||
}
|
||||
}
|
||||
}()
|
||||
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)
|
||||
}
|
||||
dao.Commit(db)
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user