Browse Source

update

add_mode
DengBiao 1 year ago
parent
commit
d42040fbfd
4 changed files with 192 additions and 0 deletions
  1. +176
    -0
      app/admin/hdl/hdl_home_page.go
  2. +1
    -0
      app/admin/md/md_enterprise_manage.go
  3. +8
    -0
      app/admin/svc/enterprise_manage/svc_self_support_for_school.go
  4. +7
    -0
      app/router/admin_router.go

+ 176
- 0
app/admin/hdl/hdl_home_page.go View File

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

import (
"applet/app/db"
"applet/app/e"
"applet/app/enum"
"applet/app/utils"
"fmt"
"github.com/gin-gonic/gin"
"time"
)

func HomePageIndex(c *gin.Context) {
now := time.Now()
todayStart := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, now.Location()).Format("2006-01-02 15:04:05") //今日开始时间
todayEnd := time.Date(now.Year(), now.Month(), now.Day()+1, 0, 0, 0, 0, now.Location()).Format("2006-01-02 15:04:05") //今日结束时间
sql1 := fmt.Sprintf("SELECT sum('trade_amount') as total FROM self_support_for_school_ord where order_status = 2 and face_time >= '%s' and face_time < '%s'", todayStart, todayEnd) //统计今日"自营-学校"收益
sql2 := fmt.Sprintf("SELECT sum('total_price') as total FROM central_kitchen_for_school_package_ord where state = 1 and create_at >= '%s' and create_at < '%s'", todayStart, todayEnd) //统计今日"央厨-学校"收益
mapArr1, err := db.QueryNativeString(db.Db, sql1)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
return
}
mapArr2, err := db.QueryNativeString(db.Db, sql2)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
return
}
var result1, result2, todayIncome float64
if mapArr1 != nil {
result1 = utils.StrToFloat64(mapArr1[0]["total"])
}
if mapArr2 != nil {
result2 = utils.StrToFloat64(mapArr2[0]["total"])
}
todayIncome = result1 + result2

sql3 := fmt.Sprintf("SELECT COUNT(*) as total,kind FROM `enterprise` GROUP BY kind") //统计校企类型数量
mapArr3, err := db.QueryNativeString(db.Db, sql3)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
return
}

var totalCentralKitchenForSchoolNums, totalCentralKitchenForFactoryNums, totalSelfSupportForSchoolNums, totalSelfSupportForFactoryNums int
if mapArr3 != nil {
for _, v := range mapArr3 {
if v["kind"] == utils.IntToStr(enum.EnterprisePvdByCentralKitchenForSchool) {
totalCentralKitchenForSchoolNums = utils.StrToInt(v["total"])
}
if v["kind"] == utils.IntToStr(enum.EnterprisePvdByCentralKitchenForFactory) {
totalCentralKitchenForFactoryNums = utils.StrToInt(v["total"])
}
if v["kind"] == utils.IntToStr(enum.EnterprisePvdBySelfSupportForSchool) {
totalSelfSupportForSchoolNums = utils.StrToInt(v["total"])
}
if v["kind"] == utils.IntToStr(enum.EnterprisePvdBySelfSupportForFactory) {
totalSelfSupportForFactoryNums = utils.StrToInt(v["total"])
}
}
}

var totalCentralKitchenForSchoolUserIdentityNums, totalCentralKitchenForFactoryUserIdentityNums, totalSelfSupportForSchoolUserIdentityNums, totalSelfSupportForFactoryUserIdentityNums int
sql4 := fmt.Sprintf("select count(*) as total from `user_identity` where kind in (%d, %d) ", enum.UserIdentityForCentralKitchenForStudent, enum.UserIdentityForCentralKitchenForTeacher) //统计"央厨-学校"用户数
sql5 := fmt.Sprintf("select count(*) as total from `user_identity` where kind in (%d, %d, %d) ", enum.UserIdentityForSelfSupportForStudent, enum.UserIdentityForSelfSupportForTeacher, enum.UserIdentityForSelfSupportForWorker) //统计"自营-学校"用户数
mapArr4, err := db.QueryNativeString(db.Db, sql4)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
return
}
if mapArr4 != nil {
totalCentralKitchenForSchoolUserIdentityNums = utils.StrToInt(mapArr4[0]["total"])
}

mapArr5, err := db.QueryNativeString(db.Db, sql5)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
return
}
if mapArr5 != nil {
totalCentralKitchenForFactoryUserIdentityNums = utils.StrToInt(mapArr4[0]["total"])
}

e.OutSuc(c, map[string]interface{}{
"data": map[string]interface{}{
"todayIncome": todayIncome,
"totalCentralKitchenForSchoolNums": totalCentralKitchenForSchoolNums,
"totalCentralKitchenForFactoryNums": totalCentralKitchenForFactoryNums,
"totalSelfSupportForSchoolNums": totalSelfSupportForSchoolNums,
"totalSelfSupportForFactoryNums": totalSelfSupportForFactoryNums,
"totalCentralKitchenForSchoolUserIdentityNums": totalCentralKitchenForSchoolUserIdentityNums,
"totalCentralKitchenForFactoryUserIdentityNums": totalCentralKitchenForFactoryUserIdentityNums,
"totalSelfSupportForSchoolUserIdentityNums": totalSelfSupportForSchoolUserIdentityNums,
"totalSelfSupportForFactoryUserIdentityNums": totalSelfSupportForFactoryUserIdentityNums,
},
}, nil)
return
}

func ThisWeekData(c *gin.Context) {
now := time.Now()
var list []map[string]interface{}
for i := -6; i <= 0; i++ {
day := now.AddDate(0, 0, i).Format("2006-01-02") //7日前
dayStart := now.AddDate(0, 0, i).Format("2006-01-02 15:04:05")
dayEnd := now.AddDate(0, 0, i+1).Format("2006-01-02 15:04:05")
sql1 := fmt.Sprintf("SELECT sum('trade_amount') as total FROM self_support_for_school_ord where order_status = 2 and face_time >= '%s' and face_time < '%s'", dayStart, dayEnd) //统计今日"自营-学校"收益
sql2 := fmt.Sprintf("SELECT sum('total_price') as total FROM central_kitchen_for_school_package_ord where state = 1 and create_at >= '%s' and create_at < '%s'", dayStart, dayEnd) //统计今日"央厨-学校"收益
mapArr1, err := db.QueryNativeString(db.Db, sql1)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
return
}
mapArr2, err := db.QueryNativeString(db.Db, sql2)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
return
}
var result1, result2, todayIncome float64
if mapArr1 != nil {
result1 = utils.StrToFloat64(mapArr1[0]["total"])
}
if mapArr2 != nil {
result2 = utils.StrToFloat64(mapArr2[0]["total"])
}
todayIncome = result1 + result2
list = append(list, map[string]interface{}{
"date": day,
"income": todayIncome,
})
}

e.OutSuc(c, map[string]interface{}{
"data": list,
}, nil)
return
}

func ThisMonthData(c *gin.Context) {
now := time.Now()
var list []map[string]interface{}
for i := -29; i <= 0; i++ {
day := now.AddDate(0, 0, i).Format("2006-01-02") //7日前
dayStart := now.AddDate(0, 0, i).Format("2006-01-02 15:04:05")
dayEnd := now.AddDate(0, 0, i+1).Format("2006-01-02 15:04:05")
sql1 := fmt.Sprintf("SELECT count(*) as total FROM self_support_for_school_ord where order_status = 2 and face_time >= '%s' and face_time < '%s'", dayStart, dayEnd) //统计今日"自营-学校"收益
sql2 := fmt.Sprintf("SELECT count(*) as total FROM central_kitchen_for_school_package_ord where state = 1 and create_at >= '%s' and create_at < '%s'", dayStart, dayEnd) //统计今日"央厨-学校"收益
mapArr1, err := db.QueryNativeString(db.Db, sql1)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
return
}
mapArr2, err := db.QueryNativeString(db.Db, sql2)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
return
}
var result1, result2 int
if mapArr1 != nil {
result1 = utils.StrToInt(mapArr1[0]["total"])
}
if mapArr2 != nil {
result2 = utils.StrToInt(mapArr2[0]["total"])
}
list = append(list, map[string]interface{}{
"date": day,
"self_support_for_school": result1,
"central_kitchen_for_school": result2,
})
}

e.OutSuc(c, map[string]interface{}{
"data": list,
}, nil)
return
}

+ 1
- 0
app/admin/md/md_enterprise_manage.go View File

@@ -423,6 +423,7 @@ type SelfSupportForSchoolOrdListReq struct {
ClassId int `json:"class_id" label:"班级id"` ClassId int `json:"class_id" label:"班级id"`
StartDate string `json:"start_date" label:"刷脸-开始时间"` StartDate string `json:"start_date" label:"刷脸-开始时间"`
EndDate string `json:"end_date" label:"刷脸-截止时间"` EndDate string `json:"end_date" label:"刷脸-截止时间"`
IsTeacher int `json:"is_teacher" label:"是否教师"`
} }


type SelfSupportForSchoolArrearsOrdListReq struct { type SelfSupportForSchoolArrearsOrdListReq struct {


+ 8
- 0
app/admin/svc/enterprise_manage/svc_self_support_for_school.go View File

@@ -585,6 +585,14 @@ func SelfSupportForSchoolOrdList(req md.SelfSupportForSchoolOrdListReq) (resp []
if req.OutTradeNo != "" { if req.OutTradeNo != "" {
sess.And("self_support_for_school_ord.out_order_no like ?", "%"+req.OutTradeNo+"%") sess.And("self_support_for_school_ord.out_order_no like ?", "%"+req.OutTradeNo+"%")
} }
if req.IsTeacher != 0 {
if req.IsTeacher == 1 {
sess.And("user_identity.identity =?", enum2.UserIdentityForCentralKitchenForTeacher)
}
if req.IsTeacher == 2 {
sess.And("user_identity.identity !=?", enum2.UserIdentityForCentralKitchenForTeacher)
}
}


if req.Name != "" { if req.Name != "" {
sess.And("user_identity.name like ?", "%"+req.Name+"%") sess.And("user_identity.name like ?", "%"+req.Name+"%")


+ 7
- 0
app/router/admin_router.go View File

@@ -46,6 +46,12 @@ func rCompany(r *gin.RouterGroup) {
r.DELETE("/delete/:id", hdl2.CompanyDelete) r.DELETE("/delete/:id", hdl2.CompanyDelete)
} }


func rHomePage(r *gin.RouterGroup) {
r.GET("/index", hdl2.HomePageIndex)
r.GET("/thisWeekData", hdl2.ThisWeekData)
r.GET("/thisMonthData", hdl2.ThisMonthData)
}

func rNotice(r *gin.RouterGroup) { func rNotice(r *gin.RouterGroup) {
r.GET("/list", hdl2.NoticeList) r.GET("/list", hdl2.NoticeList)
r.POST("/add", hdl2.NoticeAdd) r.POST("/add", hdl2.NoticeAdd)
@@ -211,6 +217,7 @@ func AdminRoute(r *gin.RouterGroup) {
r.Use(mw.CheckPermission) //检测权限 r.Use(mw.CheckPermission) //检测权限
rOss(r.Group("/oss")) rOss(r.Group("/oss"))
rComm(r.Group("/comm")) rComm(r.Group("/comm"))
rHomePage(r.Group("/homePage")) //首页
rCompany(r.Group("/company")) //公司管理 rCompany(r.Group("/company")) //公司管理
rNotice(r.Group("/notice")) //公告管理 rNotice(r.Group("/notice")) //公告管理
rBanner(r.Group("/banner")) //轮播图管理 rBanner(r.Group("/banner")) //轮播图管理


Loading…
Cancel
Save