|
|
@@ -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) |
|
|
|
} |
|
|
|
|
|
|
|