|
@@ -258,6 +258,8 @@ func DealCommonWealthReward(engine *xorm.Engine, uid int, isCompleteReward bool) |
|
|
|
|
|
|
|
|
//2、完成共富奖励(插入 user_public_platoon_settlement_records 记录) && 构造返回数据 |
|
|
//2、完成共富奖励(插入 user_public_platoon_settlement_records 记录) && 构造返回数据 |
|
|
var userPublicPlatoonSettlementRecords []*model.UserPublicPlatoonSettlementRecords |
|
|
var userPublicPlatoonSettlementRecords []*model.UserPublicPlatoonSettlementRecords |
|
|
|
|
|
var userPublicPlatoonIncomeRecords []*model.UserPublicPlatoonIncomeRecords |
|
|
|
|
|
|
|
|
now := time.Now() |
|
|
now := time.Now() |
|
|
for _, param := range *params { |
|
|
for _, param := range *params { |
|
|
var userPublicPlatoonSettlementRecord = model.UserPublicPlatoonSettlementRecords{ |
|
|
var userPublicPlatoonSettlementRecord = model.UserPublicPlatoonSettlementRecords{ |
|
@@ -269,17 +271,33 @@ func DealCommonWealthReward(engine *xorm.Engine, uid int, isCompleteReward bool) |
|
|
CreateAt: now, |
|
|
CreateAt: now, |
|
|
UpdateAt: 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 { |
|
|
if isCompleteReward { |
|
|
|
|
|
userPublicPlatoonIncomeRecord.Title = "共富收益转入余额" |
|
|
|
|
|
userPublicPlatoonIncomeRecord.Kind = 1 |
|
|
userPublicPlatoonSettlementRecord.Kind = 1 |
|
|
userPublicPlatoonSettlementRecord.Kind = 1 |
|
|
resp = append(resp, map[string]string{ |
|
|
resp = append(resp, map[string]string{ |
|
|
zhios_order_relate_utils.AnyToString(param.CoinId): param.Amount, |
|
|
zhios_order_relate_utils.AnyToString(param.CoinId): param.Amount, |
|
|
}) |
|
|
}) |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
userPublicPlatoonIncomeRecord.Title = "共富收益清零" |
|
|
|
|
|
userPublicPlatoonIncomeRecord.Kind = 2 |
|
|
userPublicPlatoonSettlementRecord.Kind = 2 |
|
|
userPublicPlatoonSettlementRecord.Kind = 2 |
|
|
} |
|
|
} |
|
|
if zhios_order_relate_utils.StrToFloat64(userPublicPlatoonSettlementRecord.Amount) > 0 { |
|
|
if zhios_order_relate_utils.StrToFloat64(userPublicPlatoonSettlementRecord.Amount) > 0 { |
|
|
userPublicPlatoonSettlementRecords = append(userPublicPlatoonSettlementRecords, &userPublicPlatoonSettlementRecord) |
|
|
userPublicPlatoonSettlementRecords = append(userPublicPlatoonSettlementRecords, &userPublicPlatoonSettlementRecord) |
|
|
} |
|
|
} |
|
|
|
|
|
if zhios_order_relate_utils.StrToFloat64(userPublicPlatoonIncomeRecord.Amount) > 0 { |
|
|
|
|
|
userPublicPlatoonIncomeRecords = append(userPublicPlatoonIncomeRecords, &userPublicPlatoonIncomeRecord) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
affected, err := db.BatchAddUserPublicPlatoonSettlementRecordss(session, userPublicPlatoonSettlementRecords) |
|
|
affected, err := db.BatchAddUserPublicPlatoonSettlementRecordss(session, userPublicPlatoonSettlementRecords) |
|
|
if err != nil { |
|
|
if err != nil { |
|
@@ -291,6 +309,16 @@ func DealCommonWealthReward(engine *xorm.Engine, uid int, isCompleteReward bool) |
|
|
_ = session.Rollback() |
|
|
_ = session.Rollback() |
|
|
return |
|
|
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 |
|
|
//3、将 user_public_platoon_amount 相关记录的 amount 置 0 |
|
|
sql := "update user_public_platoon_amount set amount = ? where uid = ?" |
|
|
sql := "update user_public_platoon_amount set amount = ? where uid = ?" |
|
|