diff --git a/src/dao/user_virtual_amount_dao.go b/src/dao/user_virtual_amount_dao.go index 87f43f5..202f68a 100644 --- a/src/dao/user_virtual_amount_dao.go +++ b/src/dao/user_virtual_amount_dao.go @@ -6,4 +6,6 @@ import ( type UserVirtualAmountDao interface { GetUserVirtualWalletBySession(uid int64, coinId int) (*model.UserVirtualAmount, error) + UserVirtualAmountFindAndCountByCoinKind(coinID int, page, pageSize int) ([]model.UserVirtualAmount, int64, error) + UserVirtualAmountGetSumByCoinKind(coinId int) (float64, error) } diff --git a/src/dao/user_virtual_coin_flow_dao.go b/src/dao/user_virtual_coin_flow_dao.go index 655506a..ada176d 100644 --- a/src/dao/user_virtual_coin_flow_dao.go +++ b/src/dao/user_virtual_coin_flow_dao.go @@ -7,4 +7,5 @@ import ( type UserVirtualCoinFlowDao interface { UserVirtualCoinFlowInsertBySession(session *xorm.Session, UserVirtualCoinFlow *model.UserVirtualCoinFlow) (int64, error) + UserVirtualCoinFlowFindByCoinAndUser(page, pageSize int, coinID int, uid int64, startAt string, endAt string, direction int) ([]model.UserVirtualCoinFlow, int64, error) } diff --git a/src/dao/virtual_coin_dao.go b/src/dao/virtual_coin_dao.go index 9c5c4d9..1fb1366 100644 --- a/src/dao/virtual_coin_dao.go +++ b/src/dao/virtual_coin_dao.go @@ -1,5 +1,8 @@ package dao +import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + type VirtualCoinDao interface { //TODO:: You can add specific method definitions here + VirtualCoinFindAllAndCount(pageSize, page int) (kindList []model.VirtualCoin, total int64, err error) } diff --git a/src/implement/public_platoon_free_punish_with_user_implement.go b/src/implement/public_platoon_free_punish_with_user_implement.go index 092ee26..6a4672f 100644 --- a/src/implement/public_platoon_free_punish_with_user_implement.go +++ b/src/implement/public_platoon_free_punish_with_user_implement.go @@ -66,9 +66,9 @@ func (p PublicPlatoonFreePunishWithUserDb) PublicPlatoonFreePunishWithUserCountA var err1 error if params != nil { query := fmt.Sprintf("%s = ?", params["key"]) - err1 = session.Where(query, params["value"]).Limit(limit, page-1).Find(&m) + err1 = session.Where(query, params["value"]).Limit(limit, (page-1)*limit).Find(&m) } else { - err1 = session.Where("1=1").Limit(limit, page-1).Find(&m) + err1 = session.Where("1=1").Limit(limit, (page-1)*limit).Find(&m) } if err1 != nil { return nil, 0, zhios_order_relate_logx.Error(err1) diff --git a/src/implement/user_virtual_amount_implement.go b/src/implement/user_virtual_amount_implement.go index 8be29fb..d1bb31c 100644 --- a/src/implement/user_virtual_amount_implement.go +++ b/src/implement/user_virtual_amount_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,27 @@ func (u UserVirtualAmountDb) GetUserVirtualWalletBySession(uid int64, coinId int return &UserVirtualWallet, nil } } + +func (u UserVirtualAmountDb) UserVirtualAmountFindAndCountByCoinKind(coinID int, page, pageSize int) ([]model.UserVirtualAmount, int64, error) { + var userVirtualWallets []model.UserVirtualAmount + session := u.Db.Where("coin_id = ?", coinID) + total, err1 := session.Count(&userVirtualWallets) + if err1 != nil { + return nil, 0, zhios_order_relate_logx.Error(err1.Error()) + } + + err := session.Limit(pageSize, (page-1)*pageSize).Desc("amount").Find(&userVirtualWallets) + if err != nil { + return nil, 0, zhios_order_relate_logx.Error(err.Error()) + } + return userVirtualWallets, total, nil +} + +func (u UserVirtualAmountDb) UserVirtualAmountGetSumByCoinKind(coinId int) (float64, error) { + var m model.UserVirtualAmount + sum, err := u.Db.Where("coin_id = ?", coinId).Sum(m, "amount") + if err != nil { + return 0, zhios_order_relate_logx.Error(err.Error()) + } + return sum, nil +} diff --git a/src/implement/user_virtual_coin_flow_implement.go b/src/implement/user_virtual_coin_flow_implement.go index 7fbd214..5595024 100644 --- a/src/implement/user_virtual_coin_flow_implement.go +++ b/src/implement/user_virtual_coin_flow_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" ) @@ -21,3 +22,23 @@ func (u UserVirtualCoinFlowDb) UserVirtualCoinFlowInsertBySession(session *xorm. } return UserVirtualCoinFlow.Id, nil } + +func (u UserVirtualCoinFlowDb) UserVirtualCoinFlowFindByCoinAndUser(page, pageSize int, coinID int, uid int64, startAt string, endAt string, direction int) ([]model.UserVirtualCoinFlow, int64, error) { + var m []model.UserVirtualCoinFlow + session := u.Db.Where("uid = ?", uid).And("coin_id = ?", coinID).And("create_at > ?", startAt).And("create_at < ?", endAt) + if direction != 0 { + session = session.And("direction = ?", direction) + } + + total, err1 := session.Count(&m) + if err1 != nil { + return nil, 0, zhios_order_relate_logx.Error(err1.Error()) + } + + err2 := session.Limit(pageSize, (page-1)*pageSize).Desc("create_at").Find(m) + if err2 != nil { + return nil, 0, err2 + } + + return m, total, nil +} diff --git a/src/implement/virtual_coin_implement.go b/src/implement/virtual_coin_implement.go index dc254c7..46c190b 100644 --- a/src/implement/virtual_coin_implement.go +++ b/src/implement/virtual_coin_implement.go @@ -2,6 +2,8 @@ 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" ) @@ -12,3 +14,18 @@ func NewVirtualCoinDb(engine *xorm.Engine) dao.VirtualCoinDao { type VirtualCoinDb struct { Db *xorm.Engine } + +func (v VirtualCoinDb) VirtualCoinFindAllAndCount(pageSize, page int) (kindList []model.VirtualCoin, total int64, err error) { + var m []model.VirtualCoin + session := v.Db.Where("is_use = ?", 1) + total, err = session.Count(&m) + if err != nil { + return nil, 0, err + } + + err = session.Asc("id").Limit(pageSize, (page-1)*pageSize).Find(&m) + if err != nil { + return nil, 0, zhios_order_relate_logx.Error(err) + } + return m, total, nil +}