From 7c08a687736ed207fcb7910627c6d669551ccb43 Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Mon, 16 Dec 2024 22:28:48 +0800 Subject: [PATCH] update --- src/dao/egg_energy_user_activity_dao.go | 1 + src/dao/platform_active_data_dao.go | 2 ++ src/dao/platform_grow_data_dao.go | 3 +++ src/dao/platform_total_data_dao.go | 2 ++ src/dao/user_certificate_dao.go | 1 + src/dao/user_dao.go | 1 + src/dao/user_wallet_flow_dao.go | 2 ++ .../egg_energy_user_activity_implement.go | 9 +++++++ .../platform_active_data_implement.go | 16 ++++++++++++ src/implement/platform_grow_data_implement.go | 26 +++++++++++++++++++ .../platform_total_data_implement.go | 16 ++++++++++++ src/implement/user_certificate_implement.go | 8 ++++++ src/implement/user_implement.go | 8 ++++++ src/implement/user_wallet_flow_implement.go | 16 ++++++++++++ 14 files changed, 111 insertions(+) diff --git a/src/dao/egg_energy_user_activity_dao.go b/src/dao/egg_energy_user_activity_dao.go index 9794f42..bf0c584 100644 --- a/src/dao/egg_energy_user_activity_dao.go +++ b/src/dao/egg_energy_user_activity_dao.go @@ -6,4 +6,5 @@ type EggEnergyUserActivityDao interface { //TODO:: You can add specific method definitions here EggEnergyUserActivityGetOneByTimeAndUserID(userID int64, date string) (*model.EggEnergyUserActivity, error) EggEnergyUserActivityInsert(m *model.EggEnergyUserActivity) (int64, error) + EggEnergyUserActivityCountByDate(startAt, endAt string) (int64, error) } diff --git a/src/dao/platform_active_data_dao.go b/src/dao/platform_active_data_dao.go index b70ad1b..1b115ff 100644 --- a/src/dao/platform_active_data_dao.go +++ b/src/dao/platform_active_data_dao.go @@ -5,4 +5,6 @@ import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" type PlatformActiveDataDao interface { //TODO:: You can add specific method definitions here PlatformActiveDataGetOneByParams(params map[string]interface{}) (*model.PlatformActiveData, error) + PlatformActiveDataInsert(m *model.PlatformActiveData) (int64, error) + PlatformActiveDataUpdate(m *model.PlatformActiveData, columns ...string) (int64, error) } diff --git a/src/dao/platform_grow_data_dao.go b/src/dao/platform_grow_data_dao.go index bccdfe2..8334197 100644 --- a/src/dao/platform_grow_data_dao.go +++ b/src/dao/platform_grow_data_dao.go @@ -5,4 +5,7 @@ import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" type PlatformGrowDataDao interface { //TODO:: You can add specific method definitions here PlatformGrowDataGetLastOne() (*model.PlatformGrowData, bool, error) + PlatformGrowDataInsert(m *model.PlatformGrowData) (int64, error) + PlatformGrowDataUpdate(m *model.PlatformGrowData, columns ...string) (int64, error) + PlatformGrowDataGetOneByParams(params map[string]interface{}) (*model.PlatformGrowData, error) } diff --git a/src/dao/platform_total_data_dao.go b/src/dao/platform_total_data_dao.go index 4431d48..1b417ec 100644 --- a/src/dao/platform_total_data_dao.go +++ b/src/dao/platform_total_data_dao.go @@ -5,4 +5,6 @@ import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" type PlatformTotalDataDao interface { //TODO:: You can add specific method definitions here PlatformTotalDataGetOneByTime(year string, month string) (*model.PlatformTotalData, error) + PlatformTotalDataInsert(m *model.PlatformTotalData) (int64, error) + PlatformTotalDataUpdate(m *model.PlatformTotalData, columns ...string) (int64, error) } diff --git a/src/dao/user_certificate_dao.go b/src/dao/user_certificate_dao.go index 0130067..e3948b2 100644 --- a/src/dao/user_certificate_dao.go +++ b/src/dao/user_certificate_dao.go @@ -6,4 +6,5 @@ type UserCertificateDao interface { FindUserCertificate(page, limit, uid string) (*[]model.UserCertificate, int64, error) GetUserCertificateByNo(no string) (*model.UserCertificate, error) GetUserCertificateById(id string) (*model.UserCertificate, error) + UserCertificateCountByDate(startAt, endAt string) (int64, error) } diff --git a/src/dao/user_dao.go b/src/dao/user_dao.go index 9d49083..41059db 100644 --- a/src/dao/user_dao.go +++ b/src/dao/user_dao.go @@ -20,4 +20,5 @@ type UserDao interface { UserCount() (int64, error) UserFindNotInByParamsByPage(page int, limit int, params map[string]interface{}) ([]model.User, int64, error) UserExistByParams(params map[string]interface{}) (bool, error) + UserCountByDate(startAt, endAt string) (int64, error) } diff --git a/src/dao/user_wallet_flow_dao.go b/src/dao/user_wallet_flow_dao.go index e1fcbdd..50e36a4 100644 --- a/src/dao/user_wallet_flow_dao.go +++ b/src/dao/user_wallet_flow_dao.go @@ -9,4 +9,6 @@ type UserWalletFlowDao interface { UserWalletFlowInsertBySession(session *xorm.Session, userWalletFlow *model.UserWalletFlow) (int64, error) UserWalletFlowFindByParams(params map[string]interface{}, page, limit int) (*[]model.UserWalletFlow, int64, error) UserWalletFlowFindByCoinAndUser(page, pageSize int, uid int64, startAt string, endAt string, direction int, isAsc bool, kind int, state int) ([]model.UserWalletFlow, int64, error) + UserWalletFlowGetSum(startAt, endAt string, kind int) (float64, error) + UserWalletFlowUserCount(startAt, endAt string, kind int) (int64, error) } diff --git a/src/implement/egg_energy_user_activity_implement.go b/src/implement/egg_energy_user_activity_implement.go index b4f34e6..5fb5f8f 100644 --- a/src/implement/egg_energy_user_activity_implement.go +++ b/src/implement/egg_energy_user_activity_implement.go @@ -3,6 +3,7 @@ import ( "code.fnuoos.com/EggPlanet/egg_models.git/src/dao" "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_models.git/utils/logx" "xorm.io/xorm" ) @@ -33,3 +34,11 @@ func (e EggEnergyUserActivityDb) EggEnergyUserActivityInsert(m *model.EggEnergyU } return m.Id, nil } + +func (e EggEnergyUserActivityDb) EggEnergyUserActivityCountByDate(startAt, endAt string) (int64, error) { + count, err := e.Db.Distinct("uid").Where("date >= ?", startAt).And("date =< ?", endAt).Count(&model.EggEnergyUserActivity{}) + if err != nil { + return 0, zhios_order_relate_logx.Error(err) + } + return count, nil +} diff --git a/src/implement/platform_active_data_implement.go b/src/implement/platform_active_data_implement.go index 24022e6..e0422c0 100644 --- a/src/implement/platform_active_data_implement.go +++ b/src/implement/platform_active_data_implement.go @@ -24,3 +24,19 @@ func (p PlatformActiveDataDb) PlatformActiveDataGetOneByParams(params map[string } return &m, nil } + +func (p PlatformActiveDataDb) PlatformActiveDataInsert(m *model.PlatformActiveData) (int64, error) { + _, err := p.Db.InsertOne(m) + if err != nil { + return 0, err + } + return m.Id, nil +} + +func (p PlatformActiveDataDb) PlatformActiveDataUpdate(m *model.PlatformActiveData, columns ...string) (int64, error) { + affected, err := p.Db.Where("id =?", m.Id).Cols(columns...).Update(m) + if err != nil { + return 0, err + } + return affected, nil +} diff --git a/src/implement/platform_grow_data_implement.go b/src/implement/platform_grow_data_implement.go index 837584e..577ff85 100644 --- a/src/implement/platform_grow_data_implement.go +++ b/src/implement/platform_grow_data_implement.go @@ -4,6 +4,7 @@ import ( "code.fnuoos.com/EggPlanet/egg_models.git/src/dao" "code.fnuoos.com/EggPlanet/egg_models.git/src/model" zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_models.git/utils/logx" + "fmt" "xorm.io/xorm" ) @@ -23,3 +24,28 @@ func (p PlatformGrowDataDb) PlatformGrowDataGetLastOne() (*model.PlatformGrowDat } return &m, exist, nil } + +func (p PlatformGrowDataDb) PlatformGrowDataInsert(m *model.PlatformGrowData) (int64, error) { + _, err := p.Db.InsertOne(m) + if err != nil { + return 0, err + } + return m.Id, nil +} + +func (p PlatformGrowDataDb) PlatformGrowDataUpdate(m *model.PlatformGrowData, columns ...string) (int64, error) { + affected, err := p.Db.Where("id =?", m.Id).Cols(columns...).Update(m) + if err != nil { + return 0, err + } + return affected, nil +} + +func (p PlatformGrowDataDb) PlatformGrowDataGetOneByParams(params map[string]interface{}) (*model.PlatformGrowData, error) { + var m model.PlatformGrowData + var query = fmt.Sprintf("%s = ?", params["key"]) + if has, err := p.Db.Where(query, params["value"]).Get(&m); err != nil || has == false { + return nil, zhios_order_relate_logx.Error(err) + } + return &m, nil +} diff --git a/src/implement/platform_total_data_implement.go b/src/implement/platform_total_data_implement.go index aa59dba..9d730b6 100644 --- a/src/implement/platform_total_data_implement.go +++ b/src/implement/platform_total_data_implement.go @@ -25,3 +25,19 @@ func (p PlatformTotalDataDb) PlatformTotalDataGetOneByTime(year string, month st } return &m, nil } + +func (p PlatformTotalDataDb) PlatformTotalDataInsert(m *model.PlatformTotalData) (int64, error) { + _, err := p.Db.InsertOne(m) + if err != nil { + return 0, err + } + return m.Id, nil +} + +func (p PlatformTotalDataDb) PlatformTotalDataUpdate(m *model.PlatformTotalData, columns ...string) (int64, error) { + affected, err := p.Db.Where("id =?", m.Id).Cols(columns...).Update(m) + if err != nil { + return 0, err + } + return affected, nil +} diff --git a/src/implement/user_certificate_implement.go b/src/implement/user_certificate_implement.go index 15e304f..14edb16 100644 --- a/src/implement/user_certificate_implement.go +++ b/src/implement/user_certificate_implement.go @@ -53,3 +53,11 @@ func (u UserCertificateDb) GetUserCertificateById(id string) (m *model.UserCerti } return m, nil } + +func (u UserCertificateDb) UserCertificateCountByDate(startAt, endAt string) (int64, error) { + count, err := u.Db.Where("start_time >= ?", startAt).And("start_time =< ?", endAt).Count(&model.UserCertificate{}) + if err != nil { + return 0, zhios_order_relate_logx.Error(err) + } + return count, nil +} diff --git a/src/implement/user_implement.go b/src/implement/user_implement.go index f396fe4..b94112f 100644 --- a/src/implement/user_implement.go +++ b/src/implement/user_implement.go @@ -186,3 +186,11 @@ func (u UserDb) UserExistByParams(params map[string]interface{}) (bool, error) { } return has, nil } + +func (u UserDb) UserCountByDate(startAt, endAt string) (int64, error) { + count, err := u.Db.Where("create_at >= ?", startAt).And("create_at =< ?", endAt).Count(&model.User{}) + if err != nil { + return 0, zhios_order_relate_logx.Error(err) + } + return count, nil +} diff --git a/src/implement/user_wallet_flow_implement.go b/src/implement/user_wallet_flow_implement.go index dc436e9..d63d845 100644 --- a/src/implement/user_wallet_flow_implement.go +++ b/src/implement/user_wallet_flow_implement.go @@ -77,3 +77,19 @@ func (u UserWalletFlowDb) UserWalletFlowFindByCoinAndUser(page, pageSize int, ui return m, total, nil } + +func (u UserWalletFlowDb) UserWalletFlowGetSum(startAt, endAt string, kind int) (float64, error) { + sum, err := u.Db.Where("create_at >= ?", startAt).And("create_at <= ?", endAt).And("kind = ?", kind).Sum(&model.UserWalletFlow{}, "amount") + if err != nil { + return 0, zhios_order_relate_logx.Error(err) + } + return sum, nil +} + +func (u UserWalletFlowDb) UserWalletFlowUserCount(startAt, endAt string, kind int) (int64, error) { + count, err := u.Db.Where("create_at >= ?", startAt).And("create_at <= ?", endAt).And("kind = ?", kind).Count(&model.UserWalletFlow{}) + if err != nil { + return 0, zhios_order_relate_logx.Error(err) + } + return count, nil +}