Browse Source

add reverse:for v1.4.8 共富收益结算加个流水

tags/v1.4.8
huangjiajun 2 years ago
parent
commit
41722153e5
2 changed files with 43 additions and 0 deletions
  1. +15
    -0
      db/db_user_public_platoon_income_records.go
  2. +28
    -0
      rule/public_platoon_relate_commission.go

+ 15
- 0
db/db_user_public_platoon_income_records.go View File

@@ -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
}

+ 28
- 0
rule/public_platoon_relate_commission.go View File

@@ -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 = ?"


Loading…
Cancel
Save