浏览代码

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	go.mod
master
huangjiajun 3 天前
父节点
当前提交
8e5a0a3d47
共有 8 个文件被更改,包括 727 次插入7 次删除
  1. +158
    -0
      app/hdl/hdl_home_page.go
  2. +6
    -0
      app/router/router.go
  3. +3
    -3
      app/svc/im/svc_send_message.go
  4. +19
    -3
      app/utils/time.go
  5. +204
    -0
      docs/docs.go
  6. +204
    -0
      docs/swagger.json
  7. +132
    -0
      docs/swagger.yaml
  8. +1
    -1
      go.mod

+ 158
- 0
app/hdl/hdl_home_page.go 查看文件

@@ -0,0 +1,158 @@
package hdl

import (
"applet/app/db"
"applet/app/e"
"applet/app/utils"
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
"code.fnuoos.com/EggPlanet/egg_models.git/src/model"
"fmt"
"github.com/gin-gonic/gin"
"strings"
"time"
)

// GetTotalData
// @Summary 首页-首页-数据总览
// @Tags 首页
// @Description 数据总览
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Param year query string true "年"
// @Param month query string true "月"
// @Success 200 {object} model.PlatformTotalData "具体数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/homePage/totalData [GET]
func GetTotalData(c *gin.Context) {
year := c.Query("year")
month := c.Query("month")
if year == "" || month == "" {
nowStr := time.Now().Format("2006-01-02")
year = strings.Split(nowStr, "-")[0]
month = strings.Split(nowStr, "-")[1]
}
dataDb := implement.NewPlatformTotalDataDb(db.Db)
data, err := dataDb.PlatformTotalDataGetOneByTime(year, month)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
e.OutSuc(c, data, nil)
}

type GetActiveDataResp struct {
Today *model.PlatformActiveData `json:"today"` // 今日数据
Yesterday *model.PlatformActiveData `json:"yesterday"` // 昨日数据
}

// GetActiveData
// @Summary 首页-首页-活跃数据
// @Tags 首页
// @Description 活跃数据
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Success 200 {object} GetActiveDataResp "具体数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/homePage/activeData [GET]
func GetActiveData(c *gin.Context) {
nowStr := time.Now().Format("2006-01-02")
yesterdayStr := time.Now().AddDate(0, 0, -1).Format("2006-01-02")
activityDb := implement.NewPlatformActiveDataDb(db.Db)

today, err := activityDb.PlatformActiveDataGetOneByParams(map[string]interface{}{"key": "date", "value": nowStr})
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err)
}
yesterday, err := activityDb.PlatformActiveDataGetOneByParams(map[string]interface{}{"key": "date", "value": yesterdayStr})
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err)
}
resp := GetActiveDataResp{
Today: today,
Yesterday: yesterday,
}
e.OutSuc(c, resp, nil)
}

// GetGrowData
// @Summary 首页-首页-用户增长曲线
// @Tags 首页
// @Description 用户增长曲线
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Param kind query string false "1:按天 2:按周 3:按小时"
// @Success 200 {object} md.GetPriceCurveResp "具体数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/homePage/growData [GET]
func GetGrowData(c *gin.Context) {
kind := c.DefaultQuery("kind", "1")
now := time.Now()

dataDb := implement.NewPlatformGrowDataDb(db.Db)
m, has, err := dataDb.PlatformGrowDataGetLastOne()
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
if !has {
e.OutErr(c, e.ERR_NO_DATA, "未查询到数据")
return
}
var yData []interface{}
var xData []interface{}
switch kind {
case "1":
// 日
var date = now.AddDate(0, 0, -30).Format("2006-01-02")
var sql = fmt.Sprintf("SELECT user_grow_count,date FROM `platform_grow_data` WHERE DATE >= \"%s\" AND DATE != \"%s\" ORDER BY DATE ASC ", date, now.Format("2006-01-02"))
results, _ := db.Db.QueryString(sql)
for _, v := range results {
tmpDate := utils.TimeParseStd(v["date"])
yData = append(yData, v["user_grow_count"])
xData = append(xData, tmpDate.Format("2006-01-02"))
}
yData = append(yData, m.UserGrowCount)
tmpDate := utils.TimeParseStd(m.Date)
xData = append(xData, tmpDate.Format("2006-01-02"))
break
case "2":
// 周
var nums = 29
for i := nums; i >= 1; i-- {
var date = now.AddDate(0, 0, -7*i).Format("2006-01-02")
var sql = "SELECT user_grow_count,date FROM `platform_grow_data` WHERE DATE = \"%s\" "
sql = fmt.Sprintf(sql, date)
results, _ := db.Db.QueryString(sql)
if results != nil {
year, week, _, _ := utils.GetWeekInfo(results[0]["date"])
yData = append(yData, results[0]["user_grow_count"])
xData = append(xData, fmt.Sprintf("%s年%s周", year, week))
}
}
yData = append(yData, m.UserGrowCount)
year, week, _, _ := utils.GetWeekInfo(m.Date)
xData = append(xData, fmt.Sprintf("%s年%s周", year, week))
break
case "3":
// 月
var nums = 29
for i := nums; i >= 1; i-- {
var date = now.AddDate(0, -i, 0).Format("2006-01-02")
var sql = "SELECT user_grow_count,date FROM `platform_grow_data` WHERE DATE = \"%s\" "
sql = fmt.Sprintf(sql, date)
results, _ := db.Db.QueryString(sql)
if results != nil {
tmpDate := utils.TimeParseStd(results[0]["date"])
yData = append(yData, results[0]["user_grow_count"])
xData = append(xData, tmpDate.Format("2006-01"))
}
}
yData = append(yData, m.UserGrowCount)
tmpDate := utils.TimeParseStd(m.Date)
xData = append(xData, tmpDate.Format("2006-01"))
break
}
}

+ 6
- 0
app/router/router.go 查看文件

@@ -76,6 +76,7 @@ func route(r *gin.RouterGroup) {
rInstitutionalManagement(r.Group("/institutionalManagement"))
rMarketingApplications(r.Group("/marketingApplications"))
rMemberCenter(r.Group("/memberCenter"))
rHomePage(r.Group("/homePage"))
rSettCenter(r.Group("/settCenter"))
rFinancialCenter(r.Group("/financialCenter"))
rAdvertising(r.Group("/advertising"))
@@ -95,6 +96,11 @@ func rSettCenter(r *gin.RouterGroup) { //设置中心
}
}
}
func rHomePage(r *gin.RouterGroup) {
r.GET("/totalData", hdl.GetTotalData)
r.GET("/activeData", hdl.GetActiveData)
r.GET("/growData", hdl.GetGrowData)
}
func rAdvertising(r *gin.RouterGroup) {
r.GET("/getBasic", advertising.GetBasic)
r.POST("/setBasic", advertising.SetBasic)


+ 3
- 3
app/svc/im/svc_send_message.go 查看文件

@@ -212,7 +212,7 @@ func DealUserMessage(recordID int, req *md.BatchSendUserMessageReq) {
var customerServiceWithUsers []model.CustomerServiceWithUser
err = db.DbIm.Table("user").
Join("INNER", "customer_service", "customer_service.id = user.customer_id").
In("phone", phoneIds).
In("phone_number", phoneIds).
Where("customer_service.state = 1").
Find(&customerServiceWithUsers)
if err != nil {
@@ -260,7 +260,7 @@ func DealUserMessage(recordID int, req *md.BatchSendUserMessageReq) {
var customerServiceWithUsers []model.CustomerServiceWithUser
err = db.DbIm.Table("user").
Join("INNER", "customer_service", "customer_service.id = user.customer_id").
In("phone", tempPhoneList).
In("phone_number", tempPhoneList).
Where("customer_service.state = 1").
Find(&customerServiceWithUsers)
if err != nil {
@@ -323,7 +323,7 @@ func DealUserMessage(recordID int, req *md.BatchSendUserMessageReq) {
var customerServiceWithUsers []model.CustomerServiceWithUser
err = db.DbIm.Table("user").
Join("INNER", "customer_service", "customer_service.id = user.customer_id").
In("phone", phoneIds).
In("phone_number", phoneIds).
Where("customer_service.state = 1").
Find(&customerServiceWithUsers)
for _, customerServiceWithUser := range customerServiceWithUsers {


+ 19
- 3
app/utils/time.go 查看文件

@@ -209,18 +209,34 @@ func GetDateTimeRangeStr(s string) (string, string) {
return stime.Format("2006-01-02 15:04:05"), etime.Format("2006-01-02 15:04:05")
}

//获取传入的时间所在月份的第一天,即某月第一天的0点。如传入time.Now(), 返回当前月份的第一天0点时间。
// 获取传入的时间所在月份的第一天,即某月第一天的0点。如传入time.Now(), 返回当前月份的第一天0点时间。
func GetFirstDateOfMonth(d time.Time) time.Time {
d = d.AddDate(0, 0, -d.Day()+1)
return GetZeroTime(d)
}

//获取传入的时间所在月份的最后一天,即某月最后一天的0点。如传入time.Now(), 返回当前月份的最后一天0点时间。
// 获取传入的时间所在月份的最后一天,即某月最后一天的0点。如传入time.Now(), 返回当前月份的最后一天0点时间。
func GetLastDateOfMonth(d time.Time) time.Time {
return GetFirstDateOfMonth(d).AddDate(0, 1, -1)
}

//获取某一天的0点时间
// 获取某一天的0点时间
func GetZeroTime(d time.Time) time.Time {
return time.Date(d.Year(), d.Month(), d.Day(), 0, 0, 0, 0, d.Location())
}

// GetWeekInfo 获取周数、开始时间、结束时间
func GetWeekInfo(dateStr string) (string, string, string, string) {
date := TimeParseStd(dateStr)
year, week := date.ISOWeek()
location, _ := time.LoadLocation("Asia/Shanghai")
// 计算给定年份1月1日是星期几
startOfYear := time.Date(year, time.January, 1, 0, 0, 0, 0, location)
daysOffset := int(startOfYear.Weekday()) - int(time.Monday) + 1
// 计算给定年份的第一周的开始日期
firstWeekStart := startOfYear.AddDate(0, 0, -daysOffset+1)
// 计算给定周的开始日期
weekStart := firstWeekStart.AddDate(0, 0, (week-1)*7)
weekEnd := weekStart.AddDate(0, 0, 6)
return IntToStr(year), IntToStr(week), weekStart.Format("2006-01-02"), weekEnd.Format("2006-01-02")
}

+ 204
- 0
docs/docs.go 查看文件

@@ -1506,6 +1506,140 @@ const docTemplate = `{
}
}
},
"/api/homePage/activeData": {
"get": {
"description": "活跃数据",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"首页"
],
"summary": "首页-首页-活跃数据",
"parameters": [
{
"type": "string",
"description": "验证参数Bearer和token空格拼接",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": {
"200": {
"description": "具体数据",
"schema": {
"$ref": "#/definitions/hdl.GetActiveDataResp"
}
},
"400": {
"description": "具体错误",
"schema": {
"$ref": "#/definitions/md.Response"
}
}
}
}
},
"/api/homePage/growData": {
"get": {
"description": "用户增长曲线",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"首页"
],
"summary": "首页-首页-用户增长曲线",
"parameters": [
{
"type": "string",
"description": "验证参数Bearer和token空格拼接",
"name": "Authorization",
"in": "header",
"required": true
},
{
"type": "string",
"description": "1:按天 2:按周 3:按小时",
"name": "kind",
"in": "query"
}
],
"responses": {
"200": {
"description": "具体数据",
"schema": {
"$ref": "#/definitions/md.GetPriceCurveResp"
}
},
"400": {
"description": "具体错误",
"schema": {
"$ref": "#/definitions/md.Response"
}
}
}
}
},
"/api/homePage/totalData": {
"get": {
"description": "数据总览",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"首页"
],
"summary": "首页-首页-数据总览",
"parameters": [
{
"type": "string",
"description": "验证参数Bearer和token空格拼接",
"name": "Authorization",
"in": "header",
"required": true
},
{
"type": "string",
"description": "年",
"name": "year",
"in": "query",
"required": true
},
{
"type": "string",
"description": "月",
"name": "month",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "具体数据",
"schema": {
"$ref": "#/definitions/model.PlatformTotalData"
}
},
"400": {
"description": "具体错误",
"schema": {
"$ref": "#/definitions/md.Response"
}
}
}
}
},
"/api/im/addCustomerService": {
"post": {
"description": "客服(新增)",
@@ -6499,6 +6633,27 @@ const docTemplate = `{
}
}
},
"hdl.GetActiveDataResp": {
"type": "object",
"properties": {
"today": {
"description": "今日数据",
"allOf": [
{
"$ref": "#/definitions/model.PlatformActiveData"
}
]
},
"yesterday": {
"description": "昨日数据",
"allOf": [
{
"$ref": "#/definitions/model.PlatformActiveData"
}
]
}
}
},
"md.ActivePointsWalletNode": {
"type": "object",
"properties": {
@@ -12099,6 +12254,55 @@ const docTemplate = `{
}
}
},
"model.PlatformActiveData": {
"type": "object",
"properties": {
"date": {
"type": "string"
},
"id": {
"type": "integer"
},
"new_user_count": {
"type": "integer"
},
"user_sign_in_count": {
"type": "integer"
},
"withdraw_amount_count": {
"type": "string"
},
"withdraw_user_count": {
"type": "integer"
}
}
},
"model.PlatformTotalData": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"month": {
"type": "string"
},
"no_sigin_in_user_count": {
"type": "integer"
},
"total_user_count": {
"type": "integer"
},
"total_withdraw_amount": {
"type": "string"
},
"verified_user_count": {
"type": "integer"
},
"year": {
"type": "string"
}
}
},
"model.UserLevelTask": {
"type": "object",
"properties": {


+ 204
- 0
docs/swagger.json 查看文件

@@ -1498,6 +1498,140 @@
}
}
},
"/api/homePage/activeData": {
"get": {
"description": "活跃数据",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"首页"
],
"summary": "首页-首页-活跃数据",
"parameters": [
{
"type": "string",
"description": "验证参数Bearer和token空格拼接",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": {
"200": {
"description": "具体数据",
"schema": {
"$ref": "#/definitions/hdl.GetActiveDataResp"
}
},
"400": {
"description": "具体错误",
"schema": {
"$ref": "#/definitions/md.Response"
}
}
}
}
},
"/api/homePage/growData": {
"get": {
"description": "用户增长曲线",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"首页"
],
"summary": "首页-首页-用户增长曲线",
"parameters": [
{
"type": "string",
"description": "验证参数Bearer和token空格拼接",
"name": "Authorization",
"in": "header",
"required": true
},
{
"type": "string",
"description": "1:按天 2:按周 3:按小时",
"name": "kind",
"in": "query"
}
],
"responses": {
"200": {
"description": "具体数据",
"schema": {
"$ref": "#/definitions/md.GetPriceCurveResp"
}
},
"400": {
"description": "具体错误",
"schema": {
"$ref": "#/definitions/md.Response"
}
}
}
}
},
"/api/homePage/totalData": {
"get": {
"description": "数据总览",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"首页"
],
"summary": "首页-首页-数据总览",
"parameters": [
{
"type": "string",
"description": "验证参数Bearer和token空格拼接",
"name": "Authorization",
"in": "header",
"required": true
},
{
"type": "string",
"description": "年",
"name": "year",
"in": "query",
"required": true
},
{
"type": "string",
"description": "月",
"name": "month",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "具体数据",
"schema": {
"$ref": "#/definitions/model.PlatformTotalData"
}
},
"400": {
"description": "具体错误",
"schema": {
"$ref": "#/definitions/md.Response"
}
}
}
}
},
"/api/im/addCustomerService": {
"post": {
"description": "客服(新增)",
@@ -6491,6 +6625,27 @@
}
}
},
"hdl.GetActiveDataResp": {
"type": "object",
"properties": {
"today": {
"description": "今日数据",
"allOf": [
{
"$ref": "#/definitions/model.PlatformActiveData"
}
]
},
"yesterday": {
"description": "昨日数据",
"allOf": [
{
"$ref": "#/definitions/model.PlatformActiveData"
}
]
}
}
},
"md.ActivePointsWalletNode": {
"type": "object",
"properties": {
@@ -12091,6 +12246,55 @@
}
}
},
"model.PlatformActiveData": {
"type": "object",
"properties": {
"date": {
"type": "string"
},
"id": {
"type": "integer"
},
"new_user_count": {
"type": "integer"
},
"user_sign_in_count": {
"type": "integer"
},
"withdraw_amount_count": {
"type": "string"
},
"withdraw_user_count": {
"type": "integer"
}
}
},
"model.PlatformTotalData": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"month": {
"type": "string"
},
"no_sigin_in_user_count": {
"type": "integer"
},
"total_user_count": {
"type": "integer"
},
"total_withdraw_amount": {
"type": "string"
},
"verified_user_count": {
"type": "integer"
},
"year": {
"type": "string"
}
}
},
"model.UserLevelTask": {
"type": "object",
"properties": {


+ 132
- 0
docs/swagger.yaml 查看文件

@@ -206,6 +206,17 @@ definitions:
- content_type
- file_name
type: object
hdl.GetActiveDataResp:
properties:
today:
allOf:
- $ref: '#/definitions/model.PlatformActiveData'
description: 今日数据
yesterday:
allOf:
- $ref: '#/definitions/model.PlatformActiveData'
description: 昨日数据
type: object
md.ActivePointsWalletNode:
properties:
amount:
@@ -4104,6 +4115,38 @@ definitions:
violate_nums:
type: string
type: object
model.PlatformActiveData:
properties:
date:
type: string
id:
type: integer
new_user_count:
type: integer
user_sign_in_count:
type: integer
withdraw_amount_count:
type: string
withdraw_user_count:
type: integer
type: object
model.PlatformTotalData:
properties:
id:
type: integer
month:
type: string
no_sigin_in_user_count:
type: integer
total_user_count:
type: integer
total_withdraw_amount:
type: string
verified_user_count:
type: integer
year:
type: string
type: object
model.UserLevelTask:
properties:
create_at:
@@ -5115,6 +5158,95 @@ paths:
summary: 财务中心-提现-基础设置(更新)
tags:
- 提现
/api/homePage/activeData:
get:
consumes:
- application/json
description: 活跃数据
parameters:
- description: 验证参数Bearer和token空格拼接
in: header
name: Authorization
required: true
type: string
produces:
- application/json
responses:
"200":
description: 具体数据
schema:
$ref: '#/definitions/hdl.GetActiveDataResp'
"400":
description: 具体错误
schema:
$ref: '#/definitions/md.Response'
summary: 首页-首页-活跃数据
tags:
- 首页
/api/homePage/growData:
get:
consumes:
- application/json
description: 用户增长曲线
parameters:
- description: 验证参数Bearer和token空格拼接
in: header
name: Authorization
required: true
type: string
- description: 1:按天 2:按周 3:按小时
in: query
name: kind
type: string
produces:
- application/json
responses:
"200":
description: 具体数据
schema:
$ref: '#/definitions/md.GetPriceCurveResp'
"400":
description: 具体错误
schema:
$ref: '#/definitions/md.Response'
summary: 首页-首页-用户增长曲线
tags:
- 首页
/api/homePage/totalData:
get:
consumes:
- application/json
description: 数据总览
parameters:
- description: 验证参数Bearer和token空格拼接
in: header
name: Authorization
required: true
type: string
- description: 年
in: query
name: year
required: true
type: string
- description: 月
in: query
name: month
required: true
type: string
produces:
- application/json
responses:
"200":
description: 具体数据
schema:
$ref: '#/definitions/model.PlatformTotalData'
"400":
description: 具体错误
schema:
$ref: '#/definitions/md.Response'
summary: 首页-首页-数据总览
tags:
- 首页
/api/im/addCustomerService:
post:
consumes:


+ 1
- 1
go.mod 查看文件

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

require (
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241127120416-8ffcaa9a33d7
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241127130035-a00c65a48d15
code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241127101803-8cd39f7b84b2
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


正在加载...
取消
保存