@@ -23,6 +23,7 @@ require ( | |||
) | |||
require ( | |||
filippo.io/edwards25519 v1.1.0 // indirect | |||
github.com/alibabacloud-go/alibabacloud-gateway-spi v0.0.5 // indirect | |||
github.com/alibabacloud-go/debug v1.0.1 // indirect | |||
github.com/alibabacloud-go/endpoint-util v1.1.0 // indirect | |||
@@ -31,6 +32,7 @@ require ( | |||
github.com/alibabacloud-go/tea-xml v1.1.3 // indirect | |||
github.com/aliyun/credentials-go v1.3.10 // indirect | |||
github.com/clbanning/mxj/v2 v2.5.5 // indirect | |||
github.com/go-sql-driver/mysql v1.8.1 // indirect | |||
github.com/josharian/intern v1.0.0 // indirect | |||
github.com/mailru/easyjson v0.7.7 // indirect | |||
github.com/nxadm/tail v1.4.8 // indirect | |||
@@ -42,7 +44,7 @@ require ( | |||
) | |||
require ( | |||
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241210121211-81406596ad48 | |||
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241211055111-7c47b67b46d2 | |||
github.com/goccy/go-json v0.10.2 // indirect | |||
github.com/golang/snappy v0.0.4 // indirect | |||
github.com/json-iterator/go v1.1.12 // indirect | |||
@@ -1,14 +1,13 @@ | |||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= | |||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= | |||
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241206115326-8cbc93c7c64d h1:9XUmoFAlU46M4psHog/SbZepbSQe+I9VCiRquaqw97A= | |||
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241206115326-8cbc93c7c64d/go.mod h1:+bDK4gfBq4LEkhh6K/A46+0urH/sgxDxnjIjlxb9HI8= | |||
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241210121211-81406596ad48 h1:cEcOp21RER1MGwWXUhzObJUek8QDrypKqRR+y3chE1A= | |||
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241210121211-81406596ad48/go.mod h1:+bDK4gfBq4LEkhh6K/A46+0urH/sgxDxnjIjlxb9HI8= | |||
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241211055111-7c47b67b46d2 h1:g4zWPWExuZAG8nTmkcSJnTbxKhz5B+VANCWEsJOMGXg= | |||
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241211055111-7c47b67b46d2/go.mod h1:+bDK4gfBq4LEkhh6K/A46+0urH/sgxDxnjIjlxb9HI8= | |||
code.fnuoos.com/go_rely_warehouse/zyos_go_es.git v1.0.1-0.20241118083738-0f22da9ba0be h1:zuleX5JnIGQpt6wDAmCFs++lLgOmE6kWo3xkJnjrSck= | |||
code.fnuoos.com/go_rely_warehouse/zyos_go_es.git v1.0.1-0.20241118083738-0f22da9ba0be/go.mod h1:Yuc7XnUQ15eaC0ZobcJG7XwkVTttVqp52OTanXhI1Qk= | |||
code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5 h1:dqvWJqlJi0WXCwTxbWPLvSOsKPjP+iEDBVgLcAl9nOE= | |||
code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5/go.mod h1:TTcCnFn/LhBGapnutpezlW+GXkLRNPMWkziOoCsXQqY= | |||
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= | |||
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= | |||
gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a h1:lSA0F4e9A2NcQSqGqTOXqu2aRi/XEQxDCBwM8yJtE6s= | |||
gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:EXuID2Zs0pAQhH8yz+DNjUbjppKQzKFAn28TMYPB6IU= | |||
gitee.com/travelliu/dm v1.8.11192/go.mod h1:DHTzyhCrM843x9VdKVbZ+GKXGRbKM2sJ4LxihRxShkE= | |||
@@ -139,6 +138,7 @@ github.com/go-redis/redis v6.15.9+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8w | |||
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= | |||
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= | |||
github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y= | |||
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg= | |||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= | |||
github.com/goccy/go-json v0.8.1/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= | |||
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= | |||
@@ -1,6 +1,7 @@ | |||
package egg_energy | |||
import ( | |||
"code.fnuoos.com/EggPlanet/egg_models.git/src/dao" | |||
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement" | |||
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" | |||
"code.fnuoos.com/EggPlanet/egg_system_rules.git/enum" | |||
@@ -67,6 +68,12 @@ func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ecpm strin | |||
//TODO::奖励多少个活跃积分(根据ecpm, 新用户机制, 蛋蛋分机制) | |||
redisConn := cache.GetPool().Get() | |||
sysCfgDb := implement.NewSysCfgDb(engine, redisConn) | |||
defer func(sysCfgDb dao.SysCfgDao) { | |||
err := sysCfgDb.Close() | |||
if err != nil { | |||
fmt.Println("redis close err:" + err.Error()) // 记录错误信息 | |||
} | |||
}(sysCfgDb) | |||
videoRewardUnitPrice := sysCfgDb.SysCfgGetWithDb(enum.VideoRewardUnitPrice) | |||
if videoRewardUnitPrice != "" { //处理ecpm | |||
var coin model.VirtualCoin | |||
@@ -0,0 +1,120 @@ | |||
package rule | |||
import ( | |||
db "code.fnuoos.com/EggPlanet/egg_models.git/src" | |||
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement" | |||
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" | |||
utils "code.fnuoos.com/EggPlanet/egg_system_rules.git/utils" | |||
"errors" | |||
"fmt" | |||
"xorm.io/xorm" | |||
) | |||
/* | |||
会员升级 | |||
uid 用户id | |||
lv 要升级的等级 | |||
*/ | |||
func UserUpgradeTask(eg *xorm.Engine, uid, lv int) ([]map[string]string, error) { | |||
taskList := make([]map[string]string, 0) | |||
//获取任务 | |||
NewUserLevelTaskDb := implement.NewUserLevelTaskDb(eg) | |||
levelTask, _ := NewUserLevelTaskDb.UserLevelTaskFindByParams(map[string]interface{}{ | |||
"key": "level_id", | |||
"value": lv, | |||
}) | |||
if len(levelTask) == 0 { | |||
return taskList, errors.New("任务条件未设置") | |||
} | |||
NewUserLevelDb := implement.NewUserLevelDb(eg) | |||
level, _ := NewUserLevelDb.UserLevelByID(lv) | |||
if level == nil { | |||
return taskList, errors.New("等级不存在") | |||
} | |||
chooseNum := 0 | |||
mustTaskErr := 0 | |||
for _, v := range levelTask { | |||
isSuccess := 0 | |||
var count int64 = 0 | |||
switch v.TaskType { | |||
case 1: //直推会员人数 | |||
count = ExtendUserCount(eg, uid) | |||
if count >= int64(v.FinishCount) { | |||
isSuccess = 1 | |||
} | |||
break | |||
case 2: //直推会员活跃天数 | |||
count = ExtendUserCountWithDay(eg, uid, v.WithinDays, v.ActiveDays) | |||
if count >= int64(v.FinishCount) { | |||
isSuccess = 1 | |||
} | |||
break | |||
case 3: //直推会员等级 | |||
count = ExtendUserCountWithLv(eg, uid, v.TaskTypeLevelId) | |||
if count >= int64(v.FinishCount) { | |||
isSuccess = 1 | |||
} | |||
break | |||
} | |||
tmp := map[string]string{ | |||
"id": utils.IntToStr(v.Id), | |||
"count": utils.Int64ToStr(count), | |||
"is_success": utils.IntToStr(isSuccess), | |||
} | |||
taskList = append(taskList, tmp) | |||
if isSuccess == 1 || v.IsMustTask == 0 { //记录选做任务数量 | |||
chooseNum++ | |||
} | |||
if isSuccess == 0 && v.IsMustTask == 1 { //必做任务未完成 | |||
mustTaskErr = 1 | |||
} | |||
} | |||
if mustTaskErr == 1 { | |||
return taskList, errors.New("必做任务未完成") | |||
} | |||
if level.ChoosableNum > chooseNum { //选做任务未完成 | |||
return taskList, errors.New("选择任务未完成") | |||
} | |||
return taskList, nil | |||
} | |||
// 直推人数 | |||
func ExtendUserCount(eg *xorm.Engine, uid int) int64 { | |||
count, _ := eg.Where("parent_uid=?", uid).Count(&model.User{}) | |||
return count | |||
} | |||
// 直推人数达到对应等级 | |||
func ExtendUserCountWithLv(eg *xorm.Engine, uid, lv int) int64 { | |||
count, _ := eg.Where("parent_uid=? and level=?", uid, lv).Count(&model.User{}) | |||
return count | |||
} | |||
// X天直推X个用户活跃X天 | |||
func ExtendUserCountWithDay(eg *xorm.Engine, uid, day, activityDay int) int64 { | |||
var user []model.User | |||
today := utils.GetTimeRange("today") | |||
times := today["start"] - int64(day*86400) | |||
eg.Where("parent_uid=? and create_at>=?", uid, times).Find(&user) | |||
var num int64 = 0 | |||
if len(user) > 0 { | |||
uids := "" | |||
for _, v := range user { | |||
if uids == "" { | |||
uids += utils.Int64ToStr(v.Id) | |||
} else { | |||
uids += "," + utils.Int64ToStr(v.Id) | |||
} | |||
} | |||
sql := `select count(*) as count from egg_energy_user_activity where uid in(%s) ` | |||
sql = fmt.Sprintf(sql, uids) | |||
nativeString, _ := db.QueryNativeString(eg, sql) | |||
for _, v := range nativeString { | |||
if utils.StrToInt(v["count"]) >= activityDay { | |||
num++ | |||
} | |||
} | |||
} | |||
return num | |||
} |