Explorar el Código

update 一个圈圈

master
DengBiao hace 7 meses
padre
commit
f95f573a4c
Se han modificado 1 ficheros con 82 adiciones y 18 borrados
  1. +82
    -18
      rule/one_circles/one_circles_star_level_dividends.go

+ 82
- 18
rule/one_circles/one_circles_star_level_dividends.go Ver fichero

@@ -161,16 +161,48 @@ func SettlementStarLevelDividends(engine *xorm.Engine, masterId string, ch *rabb
}
}

siginDividend, _ := siginDividendValue.Float64()
if siginDividend > 0 {
//TODO::推入rabbitmq 异步处理
ch.Publish(md.OneCirclesExchange, md.OneCirclesStructForStarLevelDividends{
MasterId: masterId,
Uid: item.Uid,
SignDividend: siginDividend,
}, md.OneCirclesRoutKeyForStarLevelDividend)
if siginDividendValue.GreaterThan(decimal.NewFromInt(0)) {
//TODO::统计当前有多少直推用户昨天签到了
userRelates, err1 := db.DbsUserRelateByParentUid(engine, item.Uid, 1)
if err1 != nil {
fmt.Println("err:::::88888888", err1)
return err
}
var userRelatesUids []int
if userRelates != nil {
for _, userRelate := range *userRelates {
userRelatesUids = append(userRelatesUids, userRelate.Uid)
}
}
if len(userRelatesUids) > 0 {
var oneCirclesGreenEnergySignIns []*model.OneCirclesGreenEnergySignIn
err = engine.Where("start_time >= ?", startDate).And("start_time <=?", endDate).In("uid", userRelatesUids).And("is_completed =?", 0).Find(&oneCirclesGreenEnergySignIns)
if err != nil {
fmt.Println("err:::::999999999", err)
return
}
if len(oneCirclesGreenEnergySignIns) > 0 {
userRelatesUidsValue := decimal.NewFromInt(int64(len(userRelatesUids)))
oneCirclesGreenEnergySignInsValue := decimal.NewFromInt(int64(len(oneCirclesGreenEnergySignIns)))
siginDividendValue = siginDividendValue.Mul(oneCirclesGreenEnergySignInsValue.Div(userRelatesUidsValue))
} else {
siginDividendValue = decimal.NewFromFloat(0)
}
} else {
siginDividendValue = decimal.NewFromFloat(0)
}

totalDividendValue = totalDividendValue.Add(siginDividendValue)
siginDividend, _ := siginDividendValue.Float64()
if siginDividend > 0 {
//TODO::推入rabbitmq 异步处理
ch.Publish(md.OneCirclesExchange, md.OneCirclesStructForStarLevelDividends{
MasterId: masterId,
Uid: item.Uid,
SignDividend: siginDividend,
}, md.OneCirclesRoutKeyForStarLevelDividend)

totalDividendValue = totalDividendValue.Add(siginDividendValue)
}
}
}
userSignInArr = []int{}
@@ -198,16 +230,48 @@ func SettlementStarLevelDividends(engine *xorm.Engine, masterId string, ch *rabb
}
}

siginDividend, _ := siginDividendValue.Float64()
if siginDividend > 0 {
//TODO::推入rabbitmq 异步处理
ch.Publish(md.OneCirclesExchange, md.OneCirclesStructForStarLevelDividends{
MasterId: masterId,
Uid: item.Uid,
SignDividend: siginDividend,
}, md.OneCirclesRoutKeyForStarLevelDividend)
if siginDividendValue.GreaterThan(decimal.NewFromInt(0)) {
//TODO::统计当前有多少直推用户昨天签到了
userRelates, err1 := db.DbsUserRelateByParentUid(engine, item.Uid, 1)
if err1 != nil {
fmt.Println("err:::::88888888", err1)
return err
}
var userRelatesUids []int
if userRelates != nil {
for _, userRelate := range *userRelates {
userRelatesUids = append(userRelatesUids, userRelate.Uid)
}
}
if len(userRelatesUids) > 0 {
var oneCirclesGreenEnergySignIns []*model.OneCirclesGreenEnergySignIn
err = engine.Where("start_time >= ?", startDate).And("start_time <=?", endDate).In("uid", userRelatesUids).And("is_completed =?", 0).Find(&oneCirclesGreenEnergySignIns)
if err != nil {
fmt.Println("err:::::999999999", err)
return
}
if len(oneCirclesGreenEnergySignIns) > 0 {
userRelatesUidsValue := decimal.NewFromInt(int64(len(userRelatesUids)))
oneCirclesGreenEnergySignInsValue := decimal.NewFromInt(int64(len(oneCirclesGreenEnergySignIns)))
siginDividendValue = siginDividendValue.Mul(oneCirclesGreenEnergySignInsValue.Div(userRelatesUidsValue))
} else {
siginDividendValue = decimal.NewFromFloat(0)
}
} else {
siginDividendValue = decimal.NewFromFloat(0)
}

totalDividendValue = totalDividendValue.Add(siginDividendValue)
siginDividend, _ := siginDividendValue.Float64()
if siginDividend > 0 {
//TODO::推入rabbitmq 异步处理
ch.Publish(md.OneCirclesExchange, md.OneCirclesStructForStarLevelDividends{
MasterId: masterId,
Uid: item.Uid,
SignDividend: siginDividend,
}, md.OneCirclesRoutKeyForStarLevelDividend)

totalDividendValue = totalDividendValue.Add(siginDividendValue)
}
}
}
}


Cargando…
Cancelar
Guardar