From 4e571bddccfa68fefc8b115ec82091944f11c99c Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Sat, 23 Mar 2024 12:04:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- consume/zhios_order_total_second.go | 54 ++++++++++++++--------------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/consume/zhios_order_total_second.go b/consume/zhios_order_total_second.go index 0573fc7..a8d951f 100644 --- a/consume/zhios_order_total_second.go +++ b/consume/zhios_order_total_second.go @@ -187,42 +187,40 @@ func handleZhiosOrderTotalSecond(msg []byte) error { return errors.New("失败") } } - if v.CreateAt > 1711093286 { - var userStatistics1 model.UserWaitAmount - sess.Where("uid=? ", v.Uid).Get(&userStatistics1) - if userStatistics1.Id == 0 { - userStatistics1 = model.UserWaitAmount{ - Uid: v.Uid, - } - has, err := sess.Insert(&userStatistics1) - if err != nil { - sess.Rollback() - return err - } - if has == 0 { - sess.Rollback() - return errors.New("失败") - } - } - isupdate1 := 0 - if ordData.State == 4 && ordData.IsTotal == 1 { - isupdate1 = 1 - userStatistics1.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics1.Amount)-v.Amount-utils.StrToFloat64(v.AdditionalSubsidy), 4) + var userStatistics1 model.UserWaitAmount + sess.Where("uid=? ", v.Uid).Get(&userStatistics1) + if userStatistics1.Id == 0 { + userStatistics1 = model.UserWaitAmount{ + Uid: v.Uid, } - if ordData.State != 4 && ordData.IsTotal == 0 { - isupdate1 = 1 - userStatistics1.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics1.Amount)+v.Amount+utils.StrToFloat64(v.AdditionalSubsidy), 4) - } - update1, err1 := sess.Where("id=?", userStatistics1.Id).Cols("amount").Update(&userStatistics1) - if err1 != nil { + has, err := sess.Insert(&userStatistics1) + if err != nil { sess.Rollback() return err } - if update1 == 0 && isupdate1 == 1 { + if has == 0 { sess.Rollback() return errors.New("失败") } } + isupdate1 := 0 + if ordData.State == 4 && ordData.IsTotal == 1 { + isupdate1 = 1 + userStatistics1.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics1.Amount)-v.Amount-utils.StrToFloat64(v.AdditionalSubsidy), 4) + } + if ordData.State != 4 && ordData.IsTotal == 0 { + isupdate1 = 1 + userStatistics1.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics1.Amount)+v.Amount+utils.StrToFloat64(v.AdditionalSubsidy), 4) + } + update1, err1 := sess.Where("id=?", userStatistics1.Id).Cols("amount").Update(&userStatistics1) + if err1 != nil { + sess.Rollback() + return err + } + if update1 == 0 && isupdate1 == 1 { + sess.Rollback() + return errors.New("失败") + } } } } else {