From 41722153e5ae7e0d2bfc549f70776d311adcb37d Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Sat, 16 Jul 2022 10:40:03 +0800 Subject: [PATCH] =?UTF-8?q?add=20reverse:for=20v1.4.8=20=E5=85=B1=E5=AF=8C?= =?UTF-8?q?=E6=94=B6=E7=9B=8A=E7=BB=93=E7=AE=97=E5=8A=A0=E4=B8=AA=E6=B5=81?= =?UTF-8?q?=E6=B0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/db_user_public_platoon_income_records.go | 15 +++++++++++ rule/public_platoon_relate_commission.go | 28 +++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 db/db_user_public_platoon_income_records.go diff --git a/db/db_user_public_platoon_income_records.go b/db/db_user_public_platoon_income_records.go new file mode 100644 index 0000000..75d500f --- /dev/null +++ b/db/db_user_public_platoon_income_records.go @@ -0,0 +1,15 @@ +package db + +import ( + "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db/model" + "xorm.io/xorm" +) + +// BatchAddUserPublicPlatoonIncomeRecordss 批量新增数据 +func BatchAddUserPublicPlatoonIncomeRecordss(session *xorm.Session, UserPublicPlatoonIncomeRecordsData []*model.UserPublicPlatoonIncomeRecords) (int64, error) { + affected, err := session.Insert(UserPublicPlatoonIncomeRecordsData) + if err != nil { + return 0, err + } + return affected, nil +} diff --git a/rule/public_platoon_relate_commission.go b/rule/public_platoon_relate_commission.go index 83bd463..57e1e1a 100644 --- a/rule/public_platoon_relate_commission.go +++ b/rule/public_platoon_relate_commission.go @@ -258,6 +258,8 @@ func DealCommonWealthReward(engine *xorm.Engine, uid int, isCompleteReward bool) //2、完成共富奖励(插入 user_public_platoon_settlement_records 记录) && 构造返回数据 var userPublicPlatoonSettlementRecords []*model.UserPublicPlatoonSettlementRecords + var userPublicPlatoonIncomeRecords []*model.UserPublicPlatoonIncomeRecords + now := time.Now() for _, param := range *params { var userPublicPlatoonSettlementRecord = model.UserPublicPlatoonSettlementRecords{ @@ -269,17 +271,33 @@ func DealCommonWealthReward(engine *xorm.Engine, uid int, isCompleteReward bool) CreateAt: now, UpdateAt: now, } + //流水表 + var userPublicPlatoonIncomeRecord = model.UserPublicPlatoonIncomeRecords{ + Uid: param.Uid, + CoinId: param.CoinId, + Amount: param.Amount, + Date: now.AddDate(0, 0, 30).Format("2006-01-02"), + CreateAt: now, + UpdateAt: now, + } if isCompleteReward { + userPublicPlatoonIncomeRecord.Title = "共富收益转入余额" + userPublicPlatoonIncomeRecord.Kind = 1 userPublicPlatoonSettlementRecord.Kind = 1 resp = append(resp, map[string]string{ zhios_order_relate_utils.AnyToString(param.CoinId): param.Amount, }) } else { + userPublicPlatoonIncomeRecord.Title = "共富收益清零" + userPublicPlatoonIncomeRecord.Kind = 2 userPublicPlatoonSettlementRecord.Kind = 2 } if zhios_order_relate_utils.StrToFloat64(userPublicPlatoonSettlementRecord.Amount) > 0 { userPublicPlatoonSettlementRecords = append(userPublicPlatoonSettlementRecords, &userPublicPlatoonSettlementRecord) } + if zhios_order_relate_utils.StrToFloat64(userPublicPlatoonIncomeRecord.Amount) > 0 { + userPublicPlatoonIncomeRecords = append(userPublicPlatoonIncomeRecords, &userPublicPlatoonIncomeRecord) + } } affected, err := db.BatchAddUserPublicPlatoonSettlementRecordss(session, userPublicPlatoonSettlementRecords) if err != nil { @@ -291,6 +309,16 @@ func DealCommonWealthReward(engine *xorm.Engine, uid int, isCompleteReward bool) _ = session.Rollback() return } + affectedIncome, errIncome := db.BatchAddUserPublicPlatoonIncomeRecordss(session, userPublicPlatoonIncomeRecords) + if errIncome != nil { + _ = session.Rollback() + return + } + if affectedIncome == 0 { + err = errors.New("插入 user_public_platoon_settlement_records 记录失败") + _ = session.Rollback() + return + } //3、将 user_public_platoon_amount 相关记录的 amount 置 0 sql := "update user_public_platoon_amount set amount = ? where uid = ?"