|
|
@@ -2,6 +2,10 @@ package main |
|
|
|
|
|
|
|
import ( |
|
|
|
"applet/app/db" |
|
|
|
"applet/app/utils" |
|
|
|
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" |
|
|
|
"code.fnuoos.com/EggPlanet/egg_system_rules.git/rule" |
|
|
|
"code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy/md" |
|
|
|
"context" |
|
|
|
"errors" |
|
|
|
"fmt" |
|
|
@@ -47,6 +51,38 @@ func init() { |
|
|
|
// @host ddxq.izhim.com |
|
|
|
// @BasePath /api/v1 |
|
|
|
func main() { |
|
|
|
var users []model.UserRelate |
|
|
|
//db.Db.Where("level=1 and id>= 79725").Asc("id").Find(&users) |
|
|
|
db.Db.Where("level=1").Asc("id").Find(&users) |
|
|
|
for _, v := range users { |
|
|
|
fmt.Println("user>>>>>", v.Uid) |
|
|
|
if v.ParentUid != 0 { |
|
|
|
var req []*md.AddPublicPlatoonUserRelationCommissionReq |
|
|
|
req = append(req, &md.AddPublicPlatoonUserRelationCommissionReq{ |
|
|
|
Uid: utils.Int64ToStr(v.Uid), |
|
|
|
RecommendUid: utils.Int64ToStr(v.ParentUid), |
|
|
|
}) |
|
|
|
_, err := rule.AddPublicPlatoonUserRelationCommission(db.Db, req) |
|
|
|
if err != nil { |
|
|
|
var user model.User |
|
|
|
db.Db.Where("`id`=?", v.ParentUid).Get(&user) |
|
|
|
if user.Nickname != "注销用户" { |
|
|
|
fmt.Println("err >>>>>>>", err.Error()) |
|
|
|
return |
|
|
|
} else { |
|
|
|
var newreq []*md.AddPublicPlatoonUserRelationCommissionReq |
|
|
|
newreq = append(newreq, &md.AddPublicPlatoonUserRelationCommissionReq{ |
|
|
|
Uid: utils.Int64ToStr(v.Uid), |
|
|
|
RecommendUid: utils.Int64ToStr(1), |
|
|
|
}) |
|
|
|
_, err := rule.AddPublicPlatoonUserRelationCommission(db.Db, newreq) |
|
|
|
fmt.Println("err>>>>>>", err) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return |
|
|
|
r := router.Init() // 创建路由 |
|
|
|
|
|
|
|
srv := &http.Server{ // 设置http服务参数 |
|
|
@@ -74,3 +110,76 @@ func main() { |
|
|
|
log.Println("Server exiting") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//func main() { |
|
|
|
// var users []model.User |
|
|
|
// db.Db.Where("1=1 and phone != ''").Desc("id").Find(&users) |
|
|
|
// var codeWithUsers = map[string]*model.User{} |
|
|
|
// for _, v := range users { |
|
|
|
// fmt.Println("user>>>>>", v.Id) |
|
|
|
// if v.ParentUid != 0 { |
|
|
|
// var userRelate model.UserRelate |
|
|
|
// if has, _ := db.Db.Where("`parent_uid`=? and level = 1", v.ParentUid).Get(&userRelate); has == false { |
|
|
|
// utils.FilePutContents("test_test_test_1", utils.SerializeStr(map[string]interface{}{ |
|
|
|
// "uid": v.Id, |
|
|
|
// "phone": v.Phone, |
|
|
|
// })) |
|
|
|
// } |
|
|
|
// } |
|
|
|
// if codeWithUsers[v.SystemInviteCode] != nil { |
|
|
|
// if v.Phone != "" { |
|
|
|
// utils.FilePutContents("test_test_test", utils.SerializeStr(map[string]interface{}{ |
|
|
|
// "uid": v.Id, |
|
|
|
// "phone": v.Phone, |
|
|
|
// })) |
|
|
|
// //var inviteCode string |
|
|
|
// //sysCfgDb := sys_cfg.NewSysCfgDb(db.Db) |
|
|
|
// //sysCfg := sysCfgDb.SysCfgFindWithDb(enum.AppInviteType, enum.AppInviteLength) |
|
|
|
// //inviteCode = svc.ReturnCode(utils.StrToInt(sysCfg[enum.AppInviteLength]), utils.StrToInt(sysCfg[enum.AppInviteType]), 0) |
|
|
|
// //v.SystemInviteCode = inviteCode |
|
|
|
// //_, err := db.Db.Where("id=?", v.Id).Cols("system_invite_code").Update(v) |
|
|
|
// //fmt.Println("code>>>>", inviteCode) |
|
|
|
// //fmt.Println("err>>>>", err) |
|
|
|
// |
|
|
|
// //var userRelate []model.UserRelate |
|
|
|
// //db.Db.Where("parent_uid = ? and level = 1", v.Id).Find(&userRelate) |
|
|
|
// //if len(userRelate) > 0 { |
|
|
|
// // utils.FilePutContents("test_test_test_v1", utils.SerializeStr(map[string]interface{}{ |
|
|
|
// // "uid": v.Id, |
|
|
|
// // "phone": v.Phone, |
|
|
|
// // })) |
|
|
|
// //} |
|
|
|
// } |
|
|
|
// continue |
|
|
|
// } |
|
|
|
// codeWithUsers[v.SystemInviteCode] = &v |
|
|
|
// } |
|
|
|
// |
|
|
|
// return |
|
|
|
// r := router.Init() // 创建路由 |
|
|
|
// |
|
|
|
// srv := &http.Server{ // 设置http服务参数 |
|
|
|
// Addr: cfg.SrvAddr, // 指定ip和端口 |
|
|
|
// Handler: r, // 指定路由 |
|
|
|
// } |
|
|
|
// |
|
|
|
// go func() { // 协程启动监听http服务 |
|
|
|
// fmt.Println("Listening and serving HTTP on " + cfg.SrvAddr) |
|
|
|
// if err := srv.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) { |
|
|
|
// log.Fatalf("listen: %s\n", err) |
|
|
|
// } |
|
|
|
// }() |
|
|
|
// |
|
|
|
// // 退出go守护进程 |
|
|
|
// quit := make(chan os.Signal) |
|
|
|
// signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM) |
|
|
|
// <-quit |
|
|
|
// log.Println("Shutting down server...") |
|
|
|
// ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) |
|
|
|
// defer cancel() |
|
|
|
// if err := srv.Shutdown(ctx); err != nil { |
|
|
|
// log.Fatal("Server forced to shutdown:", err) |
|
|
|
// } |
|
|
|
// log.Println("Server exiting") |
|
|
|
// |
|
|
|
//} |