From 37ec6afd35da61b11e5719fd85712b8a008ed1d1 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Sat, 23 Mar 2024 12:06:14 +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 | 56 ++++++++++++++--------------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/consume/zhios_order_total_second.go b/consume/zhios_order_total_second.go index a8d951f..060d981 100644 --- a/consume/zhios_order_total_second.go +++ b/consume/zhios_order_total_second.go @@ -269,40 +269,38 @@ func handleZhiosOrderTotalSecond(msg []byte) error { sess.Rollback() return err } - if ordData.CreateAt > 1711092953 { - 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("失败") - } - } - if ordData.State == 4 && (ordData.IsTotal == 1 || ordData.IsTotal == 3) { - isTotal = 2 - userStatistics1.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics1.Amount)-utils.StrToFloat64(v.AfterAmount), 4) - } - if ordData.State != 4 && (ordData.IsTotal == 0) { - isTotal = 3 - userStatistics1.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics1.Amount)+utils.StrToFloat64(v.AfterAmount), 4) - } - if ordData.State != 4 && (ordData.IsTotal == 1) { - isTotal = 3 - userStatistics1.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics1.Amount)-utils.StrToFloat64(v.Amount), 4) + var userStatistics1 model.UserWaitAmount + sess.Where("uid=? ", v.Uid).Get(&userStatistics1) + if userStatistics1.Id == 0 { + userStatistics1 = model.UserWaitAmount{ + Uid: v.Uid, } - _, err := sess.Where("id=?", userStatistics1.Id).Cols("amount").Update(&userStatistics) + has, err := sess.Insert(&userStatistics1) if err != nil { sess.Rollback() return err } + if has == 0 { + sess.Rollback() + return errors.New("失败") + } + } + if ordData.State == 4 && (ordData.IsTotal == 1 || ordData.IsTotal == 3) { + isTotal = 2 + userStatistics1.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics1.Amount)-utils.StrToFloat64(v.AfterAmount), 4) + } + if ordData.State != 4 && (ordData.IsTotal == 0) { + isTotal = 3 + userStatistics1.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics1.Amount)+utils.StrToFloat64(v.AfterAmount), 4) + } + if ordData.State != 4 && (ordData.IsTotal == 1) { + isTotal = 3 + userStatistics1.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics1.Amount)-utils.StrToFloat64(v.Amount), 4) + } + _, err = sess.Where("id=?", userStatistics1.Id).Cols("amount").Update(&userStatistics) + if err != nil { + sess.Rollback() + return err } }