shenjiachi 1 день назад
Родитель
Сommit
5ec93a0bce
3 измененных файлов: 113 добавлений и 44 удалений
  1. +99
    -30
      app/hdl/hdl_home_page.go
  2. +13
    -13
      etc/cfg.yml
  3. +1
    -1
      go.mod

+ 99
- 30
app/hdl/hdl_home_page.go Просмотреть файл

@@ -8,9 +8,9 @@ import (
"applet/app/utils"
"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"
"fmt"
"github.com/gin-gonic/gin"
"strings"
"time"
)

@@ -52,36 +52,46 @@ func GetTotalData(c *gin.Context) {

year := req.Year
month := req.Month
if year == "" || month == "" {
nowStr := time.Now().Format("2006-01-02")
year = strings.Split(nowStr, "-")[0]
month = strings.Split(nowStr, "-")[1]
startAt := fmt.Sprintf("%s-%s-01", year, month)
dateStd := utils.TimeParseDateStd(startAt)
endAt := dateStd.AddDate(0, 1, 0).Format("2006-01-02")

userDb := implement.NewUserDb(db.Db)
userCount, err := userDb.UserCountByDate(startAt, endAt)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
dataDb := implement.NewPlatformTotalDataDb(db.Db)
data, err := dataDb.PlatformTotalDataGetOneByTime(year, month)

certificateDb := implement.NewUserCertificateDb(db.Db)
certificateCount, err := certificateDb.UserCertificateCountByDate(startAt, endAt)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
if data == nil {
resp := TotalDataResp{
TotalUserCount: 0,
VerifiedUserCount: 0,
NoSignInUserCount: 0,
TotalWithdrawAmount: "",
Year: "",
Month: "",
}
e.OutSuc(c, resp, nil)

// 签到人数
activityDb := implement.NewEggEnergyUserActivityDb(db.Db)
signInCount, err := activityDb.EggEnergyUserActivityCountByDate(startAt, endAt)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}

// 已提现累计金额
flowDb := implement.NewUserWalletFlowDb(db.Db)
sum, err := flowDb.UserWalletFlowGetSum(startAt, endAt, int(enum.UserWithdrawApply))
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
resp := TotalDataResp{
TotalUserCount: data.TotalUserCount,
VerifiedUserCount: data.VerifiedUserCount,
NoSignInUserCount: data.NoSignInUserCount,
TotalWithdrawAmount: data.TotalWithdrawAmount,
Year: data.Year,
Month: data.Month,
TotalUserCount: int(userCount),
VerifiedUserCount: int(certificateCount),
NoSignInUserCount: int(userCount - signInCount),
TotalWithdrawAmount: utils.Float64ToStr(sum),
Year: req.Year,
Month: req.Month,
}
e.OutSuc(c, resp, nil)
}
@@ -103,21 +113,80 @@ type GetActiveDataResp struct {
// @Router /api/homePage/activeData [GET]
func GetActiveData(c *gin.Context) {
nowStr := time.Now().Format("2006-01-02")
todayStartAt := fmt.Sprintf("%s 00:00:00", nowStr)
todayEndAt := fmt.Sprintf("%s 23:59:59", nowStr)
yesterdayStr := time.Now().AddDate(0, 0, -1).Format("2006-01-02")
activityDb := implement.NewPlatformActiveDataDb(db.Db)
yesterdayStartAt := fmt.Sprintf("%s 23:59:59", yesterdayStr)
yesterdayEndAt := fmt.Sprintf("%s 23:59:59", yesterdayStr)

userDb := implement.NewUserDb(db.Db)
todayNewUserCount, err := userDb.UserCountByDate(todayStartAt, todayEndAt)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
yesterdayNewUserCount, err := userDb.UserCountByDate(yesterdayStartAt, yesterdayEndAt)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}

activityDb := implement.NewEggEnergyUserActivityDb(db.Db)
todayActivityCount, err := activityDb.EggEnergyUserActivityCountByDate(todayStartAt, todayEndAt)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
yesterdayActivityCount, err := activityDb.EggEnergyUserActivityCountByDate(yesterdayStartAt, yesterdayEndAt)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}

flowDb := implement.NewUserWalletFlowDb(db.Db)
todayWithdrawAmount, err := flowDb.UserWalletFlowGetSum(todayStartAt, todayEndAt, int(enum.UserWithdrawApply))
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
yesterdayWithdrawAmount, err := flowDb.UserWalletFlowGetSum(yesterdayStartAt, yesterdayEndAt, int(enum.UserWithdrawApply))
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}

today, err := activityDb.PlatformActiveDataGetOneByParams(map[string]interface{}{"key": "date", "value": nowStr})
todayWithdrawUserCount, err := flowDb.UserWalletFlowUserCount(todayStartAt, todayEndAt, int(enum.UserWithdrawApply))
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err)
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
yesterday, err := activityDb.PlatformActiveDataGetOneByParams(map[string]interface{}{"key": "date", "value": yesterdayStr})

yesterdayWithdrawUserCount, err := flowDb.UserWalletFlowUserCount(yesterdayStartAt, yesterdayEndAt, int(enum.UserWithdrawApply))
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err)
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}

today := model.PlatformActiveData{
NewUserCount: int(todayNewUserCount),
UserSignInCount: int(todayActivityCount),
WithdrawAmountCount: utils.Float64ToStr(todayWithdrawAmount),
WithdrawUserCount: int(todayWithdrawUserCount),
Date: nowStr,
}
yesterday := model.PlatformActiveData{
NewUserCount: int(yesterdayNewUserCount),
UserSignInCount: int(yesterdayActivityCount),
WithdrawAmountCount: utils.Float64ToStr(yesterdayWithdrawAmount),
WithdrawUserCount: int(yesterdayWithdrawUserCount),
Date: yesterdayStr,
}

resp := GetActiveDataResp{
Today: today,
Yesterday: yesterday,
Today: &today,
Yesterday: &yesterday,
}

e.OutSuc(c, resp, nil)
}



+ 13
- 13
etc/cfg.yml Просмотреть файл

@@ -9,26 +9,26 @@ srv_addr: ':4001'
redis_addr: '127.0.0.1:6379'
redis_password: ''

#db:
# host: '119.23.182.117:3306'
# name: 'egg'
# user: 'root'
# psw: 'Fnuo123com@'
# show_log: true
# max_lifetime: 30
# max_open_conns: 100
# max_idle_conns: 100
# path: 'tmp/%s.log'
db:
host: 'advertisement-db.rwlb.rds.aliyuncs.com:3306'
host: '119.23.182.117:3306'
name: 'egg'
user: 'canal'
psw: 'DengBiao@1997'
user: 'root'
psw: 'Fnuo123com@'
show_log: true
max_lifetime: 30
max_open_conns: 100
max_idle_conns: 100
path: 'tmp/%s.log'
#db:
# host: 'advertisement-db.rwlb.rds.aliyuncs.com:3306'
# name: 'egg'
# user: 'canal'
# psw: 'DengBiao@1997'
# show_log: true
# max_lifetime: 30
# max_open_conns: 100
# max_idle_conns: 100
# path: 'tmp/%s.log'

#db_back:
# host: '119.23.182.117:3306'


+ 1
- 1
go.mod Просмотреть файл

@@ -33,7 +33,7 @@ require (
)

require (
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241216101124-4d30878258da
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241216144119-b08da56ec5ec
code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241216085945-78fe55637e4b
code.fnuoos.com/go_rely_warehouse/zyos_go_es.git v1.0.1-0.20241118083738-0f22da9ba0be
code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5


Загрузка…
Отмена
Сохранить