|
|
@@ -28,9 +28,6 @@ func SettlementStarLevelDividends(engine *xorm.Engine, masterId string) (err err |
|
|
|
} |
|
|
|
//TODO::增加“悲观锁”防止串行 |
|
|
|
getString, _ := cache.GetString(SettlementStarLevelDividendsLockKey) |
|
|
|
//if err != nil { |
|
|
|
// return err |
|
|
|
//} |
|
|
|
if getString != "" { |
|
|
|
fmt.Println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", "上一次结算未执行完") |
|
|
|
return errors.New("上一次结算未执行完") |
|
|
@@ -130,6 +127,7 @@ func SettlementStarLevelDividends(engine *xorm.Engine, masterId string) (err err |
|
|
|
fmt.Println("err:::::66666", err1) |
|
|
|
return err1 |
|
|
|
} |
|
|
|
vipLevelUserTotalMap[v.VipLevelId] = map[string]int64{} |
|
|
|
vipLevelUserTotalMap[v.VipLevelId]["count"] = count |
|
|
|
vipLevelUserTotalMap[v.VipLevelId]["weight"] = int64(userLevel.LevelWeight) |
|
|
|
} |
|
|
@@ -145,12 +143,12 @@ func SettlementStarLevelDividends(engine *xorm.Engine, masterId string) (err err |
|
|
|
var totalDividendValue = decimal.Decimal{} |
|
|
|
for _, item := range users { |
|
|
|
var siginDividendValue = decimal.Decimal{} |
|
|
|
for _, v := range vipLevelUserTotalMap { |
|
|
|
if int(v["weight"]) < allUserLevelMap[item.Level].LevelWeight { |
|
|
|
for k, v := range vipLevelUserTotalMap { |
|
|
|
if int(v["weight"]) > allUserLevelMap[item.Level].LevelWeight { |
|
|
|
continue |
|
|
|
} |
|
|
|
if vipEquitySettingMap[zhios_order_relate_utils.IntToStr(item.Level)] != "" && vipLevelUserTotalMap[zhios_order_relate_utils.IntToStr(item.Level)]["count"] > 0 { |
|
|
|
dividendValue, _ := decimal.NewFromString(vipEquitySettingMap[zhios_order_relate_utils.IntToStr(item.Level)]) |
|
|
|
dividendValue, _ := decimal.NewFromString(vipEquitySettingMap[k]) |
|
|
|
userTotal := decimal.NewFromInt(vipLevelUserTotalMap[zhios_order_relate_utils.IntToStr(item.Level)]["count"]) |
|
|
|
siginDividendValue = siginDividendValue.Add(dividendValue.Div(userTotal)) |
|
|
|
} |
|
|
|