From 05c4ed77efdbe2891a6b89a3c0dafcf28d90ca81 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Fri, 22 Mar 2024 16:19: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_settle_total.go | 31 +++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/consume/zhios_order_settle_total.go b/consume/zhios_order_settle_total.go index aed9292..8fe6eaf 100644 --- a/consume/zhios_order_settle_total.go +++ b/consume/zhios_order_settle_total.go @@ -134,6 +134,37 @@ func handleZhiosOrderSettleTotal(msg []byte) error { return errors.New("失败") } + var userStatistics2 model.UserMonthAmount + if ordData.SettleAt == 0 { + ordData.SettleAt = int(time.Now().Unix()) + } + now := time.Unix(int64(ordData.SettleAt), 0).Format("200601") + sess.Where("uid=? and date=?", v.Uid, now).Get(&userStatistics2) + if userStatistics2.Id == 0 { + userStatistics2 = model.UserMonthAmount{ + Date: utils.StrToInt(now), + Uid: v.Uid, + } + has, err := sess.Insert(&userStatistics2) + if err != nil { + sess.Rollback() + return err + } + if has == 0 { + sess.Rollback() + return errors.New("失败") + } + } + userStatistics2.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics2.SettleAmount)+v.Amount+utils.StrToFloat64(v.AdditionalSubsidy), 4) + update2, err2 := eg.Where("id=?", userStatistics2.Id).Cols("settle_amount").Update(&userStatistics2) + if err2 != nil { + sess.Rollback() + return err2 + } + if update2 == 0 { + sess.Rollback() + return errors.New("失败") + } } } sess.Commit()