diff --git a/src/dao/egg_energy_team_assistance_dao.go b/src/dao/egg_energy_team_assistance_dao.go index 750f04f..d48cc0f 100644 --- a/src/dao/egg_energy_team_assistance_dao.go +++ b/src/dao/egg_energy_team_assistance_dao.go @@ -6,7 +6,8 @@ import ( ) type EggEnergyTeamAssistanceDao interface { - EggStarLevelDividendsRecordsInsertBySession(session *xorm.Session, EggEnergyTeamAssistance *model.EggEnergyTeamAssistance) (int64, error) - EggStarLevelDividendsRecordsUpdateBySession(session *xorm.Session, id interface{}, EggEnergyTeamAssistance *model.EggEnergyTeamAssistance, forceColums ...string) (int64, error) - EggStarLevelDividendsRecordsGetOneByParamsBySession(session *xorm.Session, params map[string]interface{}) (*model.EggEnergyTeamAssistance, error) + EggEnergyTeamAssistanceInsertBySession(session *xorm.Session, EggEnergyTeamAssistance *model.EggEnergyTeamAssistance) (int64, error) + EggEnergyTeamAssistanceUpdateBySession(session *xorm.Session, id interface{}, EggEnergyTeamAssistance *model.EggEnergyTeamAssistance, forceColums ...string) (int64, error) + EggEnergyTeamAssistanceGetOneByParamsBySession(session *xorm.Session, params map[string]interface{}) (*model.EggEnergyTeamAssistance, error) + EggEnergyTeamAssistanceGetOneBySession(session *xorm.Session, uid int64, date string) (*model.EggEnergyTeamAssistance, error) } diff --git a/src/dao/user_relate_dao.go b/src/dao/user_relate_dao.go index 1a80116..e43a994 100644 --- a/src/dao/user_relate_dao.go +++ b/src/dao/user_relate_dao.go @@ -16,4 +16,5 @@ type UserRelateDao interface { UserRelateInsert(userRelate *model.UserRelate) (int64, error) UserRelatesByPuIDAndLv(puid, lv interface{}) (*[]model.UserRelate, error) UserRelatesByPuid(puid interface{}, limit, start int) (*[]model.UserRelate, error) + UserRelatesCountByParentUid(uid int64, level int) (int64, error) } diff --git a/src/implement/egg_energy_team_assistance_implement.go b/src/implement/egg_energy_team_assistance_implement.go index 45e3c96..9fc4966 100644 --- a/src/implement/egg_energy_team_assistance_implement.go +++ b/src/implement/egg_energy_team_assistance_implement.go @@ -16,7 +16,7 @@ type EggEnergyTeamAssistanceDb struct { Db *xorm.Engine } -func (e EggEnergyTeamAssistanceDb) EggStarLevelDividendsRecordsInsertBySession(session *xorm.Session, EggEnergyTeamAssistance *model.EggEnergyTeamAssistance) (int64, error) { +func (e EggEnergyTeamAssistanceDb) EggEnergyTeamAssistanceInsertBySession(session *xorm.Session, EggEnergyTeamAssistance *model.EggEnergyTeamAssistance) (int64, error) { _, err := session.InsertOne(EggEnergyTeamAssistance) if err != nil { return 0, err @@ -24,7 +24,7 @@ func (e EggEnergyTeamAssistanceDb) EggStarLevelDividendsRecordsInsertBySession(s return EggEnergyTeamAssistance.Id, nil } -func (e EggEnergyTeamAssistanceDb) EggStarLevelDividendsRecordsUpdateBySession(session *xorm.Session, id interface{}, EggEnergyTeamAssistance *model.EggEnergyTeamAssistance, forceColums ...string) (int64, error) { +func (e EggEnergyTeamAssistanceDb) EggEnergyTeamAssistanceUpdateBySession(session *xorm.Session, id interface{}, EggEnergyTeamAssistance *model.EggEnergyTeamAssistance, forceColums ...string) (int64, error) { var ( affected int64 err error @@ -40,7 +40,7 @@ func (e EggEnergyTeamAssistanceDb) EggStarLevelDividendsRecordsUpdateBySession(s return affected, nil } -func (e EggEnergyTeamAssistanceDb) EggStarLevelDividendsRecordsGetOneByParamsBySession(session *xorm.Session, params map[string]interface{}) (*model.EggEnergyTeamAssistance, error) { +func (e EggEnergyTeamAssistanceDb) EggEnergyTeamAssistanceGetOneByParamsBySession(session *xorm.Session, params map[string]interface{}) (*model.EggEnergyTeamAssistance, error) { var m model.EggEnergyTeamAssistance var query = fmt.Sprintf("%s =?", params["key"]) has, err := session.Where(query, params["value"]).Get(&m) @@ -52,3 +52,15 @@ func (e EggEnergyTeamAssistanceDb) EggStarLevelDividendsRecordsGetOneByParamsByS } return &m, nil } + +func (e EggEnergyTeamAssistanceDb) EggEnergyTeamAssistanceGetOneBySession(session *xorm.Session, uid int64, date string) (*model.EggEnergyTeamAssistance, error) { + var m model.EggEnergyTeamAssistance + has, err := session.Where("uid = ?", uid).And("date = ?", date).Get(&m) + if err != nil { + return nil, err + } + if has == false { + return nil, nil + } + return &m, nil +} diff --git a/src/implement/user_relate_implement.go b/src/implement/user_relate_implement.go index c49f77d..e701cff 100644 --- a/src/implement/user_relate_implement.go +++ b/src/implement/user_relate_implement.go @@ -138,3 +138,20 @@ func (u UserRelateDb) UpdateUserRelateBySession(session *xorm.Session, uid int64 } return affected, nil } + +func (u UserRelateDb) UserRelatesCountByParentUid(uid int64, level int) (int64, error) { + var userRelate []model.UserRelate + var total int64 + var err error + sess := u.Db.Where("parent_uid = ?", uid) + if level > 0 { + sess.And("level<=?", level) + } + if total, err = sess.Asc("level").Count(&userRelate); err != nil { + return 0, zhios_order_relate_logx.Error(err) + } + if len(userRelate) == 0 { + return 0, nil + } + return total, nil +}