Browse Source

update

add_mode
DengBiao 1 year ago
parent
commit
ee63e4aed0
6 changed files with 167 additions and 21 deletions
  1. +43
    -20
      app/admin/hdl/hdl_data_statistics.go
  2. +13
    -0
      app/admin/md/md_central_kitchen_for_school_export_records.go
  3. +98
    -0
      app/db/db_central_kitchen_for_school_export_records.go
  4. +11
    -0
      app/db/model/central_kitchen_for_school_export_records.go
  5. +2
    -1
      app/router/admin_router.go
  6. BIN
     

+ 43
- 20
app/admin/hdl/hdl_data_statistics.go View File

@@ -3,14 +3,13 @@ package hdl
import (
"applet/app/admin/lib/validate"
"applet/app/admin/md"
"applet/app/admin/svc"
"applet/app/db"
"applet/app/e"
"applet/app/enum"
"github.com/gin-gonic/gin"
)

func CentralKitchenForSchoolDataStatisticsList(c *gin.Context) {
var req md.EnterpriseListReq
var req md.CentralKitchenForSchoolExportRecordsListReq
err := c.ShouldBindJSON(&req)
if err != nil {
err = validate.HandleValidateErr(err)
@@ -24,43 +23,67 @@ func CentralKitchenForSchoolDataStatisticsList(c *gin.Context) {
if req.Page == 0 {
req.Page = 10
}
enterprises, total, err := svc.EnterpriseList(req)
centralKitchenForSchoolExportRecordsDb := db.CentralKitchenForSchoolExportRecordsDb{}
centralKitchenForSchoolExportRecordsDb.Set()
list, total, err := centralKitchenForSchoolExportRecordsDb.CentralKitchenForSchoolExportRecordsList(req)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}

e.OutSuc(c, map[string]interface{}{
"list": enterprises,
"list": list,
"total": total,
"state": []map[string]interface{}{
"kind": []map[string]interface{}{
{
"name": enum.EnterpriseState(enum.EnterpriseStateForNormal).String(),
"value": enum.EnterpriseStateForNormal,
"name": "订单列表",
"value": 1,
},
{
"name": enum.EnterpriseState(enum.EnterpriseStateForFreeze).String(),
"value": enum.EnterpriseStateForFreeze,
"name": "退款申请表",
"value": 2,
},
{
"name": "学校预定统计表",
"value": 3,
},
},
"kind": []map[string]interface{}{
{
"name": enum.EnterprisePvd(enum.EnterprisePvdByCentralKitchenForSchool).String(),
"value": enum.EnterprisePvdByCentralKitchenForSchool,
"name": "班级明细表",
"value": 4,
},
{
"name": enum.EnterprisePvd(enum.EnterprisePvdByCentralKitchenForFactory).String(),
"value": enum.EnterprisePvdByCentralKitchenForFactory,
"name": "退款明细表",
"value": 5,
},
{
"name": enum.EnterprisePvd(enum.EnterprisePvdBySelfSupportForSchool).String(),
"value": enum.EnterprisePvdBySelfSupportForSchool,
"name": "收款统计表",
"value": 6,
},
{
"name": enum.EnterprisePvd(enum.EnterprisePvdBySelfSupportForFactory).String(),
"value": enum.EnterprisePvdBySelfSupportForFactory,
"name": "班级收款明细表",
"value": 7,
},
{
"name": "学校预定数量统计表",
"value": 8,
},
},
}, nil)
return
}

func CentralKitchenForSchoolDataStatisticsExport(c *gin.Context) {
var req md.CentralKitchenForSchoolDataStatisticsExportReq
err := c.ShouldBindJSON(&req)
if err != nil {
err = validate.HandleValidateErr(err)
err1 := err.(e.E)
e.OutErr(c, err1.Code, err1.Error())
return
}

e.OutSuc(c, map[string]interface{}{
"msg": "导出成功,请稍后刷新数据列表",
}, nil)
return
}

+ 13
- 0
app/admin/md/md_central_kitchen_for_school_export_records.go View File

@@ -0,0 +1,13 @@
package md

type CentralKitchenForSchoolExportRecordsListReq struct {
Page int `json:"page" label:"页码"`
Limit int `json:"limit" label:"每页数量"`
}

type CentralKitchenForSchoolDataStatisticsExportReq struct {
Kind int `json:"kind" binding:"required" label:"导出类型"`
StartDate string `json:"start_date" binding:"required" label:"起始时间"`
EndDate string `json:"end_date" binding:"required" label:"截止时间"`
EnterpriseId int `json:"enterprise_id" label:"校企id"`
}

+ 98
- 0
app/db/db_central_kitchen_for_school_export_records.go View File

@@ -0,0 +1,98 @@
package db

import (
"applet/app/admin/md"
"applet/app/db/model"
"applet/app/utils/logx"
"reflect"
"xorm.io/xorm"
)

type CentralKitchenForSchoolExportRecordsDb struct {
Db *xorm.Engine `json:"db"`
}

func (centralKitchenForSchoolExportRecordsDb *CentralKitchenForSchoolExportRecordsDb) Set() { // set方法
centralKitchenForSchoolExportRecordsDb.Db = Db
}

func (centralKitchenForSchoolExportRecordsDb *CentralKitchenForSchoolExportRecordsDb) GetCentralKitchenForSchoolExportRecords(id int) (m *model.CentralKitchenForSchoolExportRecords, err error) {
m = new(model.CentralKitchenForSchoolExportRecords)
has, err := centralKitchenForSchoolExportRecordsDb.Db.Where("id =?", id).Get(m)
if err != nil {
return nil, logx.Error(err)
}
if has == false {
return nil, nil
}
return m, nil
}

func (centralKitchenForSchoolExportRecordsDb *CentralKitchenForSchoolExportRecordsDb) GetCentralKitchenForSchoolExportRecordsByMonth(year, month string) (m *model.CentralKitchenForSchoolExportRecords, err error) {
m = new(model.CentralKitchenForSchoolExportRecords)
has, err := centralKitchenForSchoolExportRecordsDb.Db.Where("year =? and month =?", year, month).Get(m)
if err != nil {
return nil, logx.Error(err)
}
if has == false {
return nil, nil
}
return m, nil
}

func (centralKitchenForSchoolExportRecordsDb *CentralKitchenForSchoolExportRecordsDb) FindCentralKitchenForSchoolExportRecords() (*[]model.CentralKitchenForSchoolExportRecords, error) {
var m []model.CentralKitchenForSchoolExportRecords
if err := centralKitchenForSchoolExportRecordsDb.Db.Desc("id").Find(&m); err != nil {
return nil, logx.Error(err)
}
return &m, nil
}

func (centralKitchenForSchoolExportRecordsDb *CentralKitchenForSchoolExportRecordsDb) CentralKitchenForSchoolExportRecordsInsert(m *model.CentralKitchenForSchoolExportRecords) (int, error) {
_, err := centralKitchenForSchoolExportRecordsDb.Db.InsertOne(m)
if err != nil {
return 0, err
}
return m.Id, nil
}

func (centralKitchenForSchoolExportRecordsDb *CentralKitchenForSchoolExportRecordsDb) CentralKitchenForSchoolExportRecordsInsertBySession(session *xorm.Session, m *model.CentralKitchenForSchoolExportRecords) (int, error) {
_, err := session.InsertOne(m)
if err != nil {
return 0, err
}
return m.Id, nil
}

func (centralKitchenForSchoolExportRecordsDb *CentralKitchenForSchoolExportRecordsDb) CentralKitchenForSchoolExportRecordsDelete(id interface{}) (int64, error) {
if reflect.TypeOf(id).Kind() == reflect.Slice {
return Db.In("id", id).Delete(model.CentralKitchenForSchoolExportRecords{})
} else {
return Db.Where("id = ?", id).Delete(model.CentralKitchenForSchoolExportRecords{})
}
}

func (centralKitchenForSchoolExportRecordsDb *CentralKitchenForSchoolExportRecordsDb) CentralKitchenForSchoolExportRecordsUpdateBySession(session *xorm.Session, id interface{}, m *model.CentralKitchenForSchoolExportRecords, forceColums ...string) (int64, error) {
var (
affected int64
err error
)
if forceColums != nil {
affected, err = session.Where("id=?", id).Cols(forceColums...).Update(m)
} else {
affected, err = session.Where("id=?", id).Update(m)
}
if err != nil {
return 0, err
}
return affected, nil
}

func (centralKitchenForSchoolExportRecordsDb *CentralKitchenForSchoolExportRecordsDb) CentralKitchenForSchoolExportRecordsList(req md.CentralKitchenForSchoolExportRecordsListReq) (m []model.CentralKitchenForSchoolExportRecords, total int64, err error) {
sess := centralKitchenForSchoolExportRecordsDb.Db.Desc("id").Limit(req.Limit, (req.Page-1)*req.Limit)
total, err = sess.FindAndCount(&m)
if err != nil {
return
}
return
}

+ 11
- 0
app/db/model/central_kitchen_for_school_export_records.go View File

@@ -0,0 +1,11 @@
package model

type CentralKitchenForSchoolExportRecords struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
Name string `json:"name" xorm:"not null default '' comment('名称') VARCHAR(255)"`
DownloadPath string `json:"download_path" xorm:"not null default '' comment('下载地址') VARCHAR(255)"`
Kind int `json:"kind" xorm:"not null default 0 comment('类型(1:订单列表 2:退款申请表 3:学校预定统计表 4:班级明细表 5:退款明细表 6:收款统计表 7:班级收款明细表 8:学校预定数量统计表)') TINYINT(1)"`
ReqContent string `json:"req_content" xorm:"TEXT"`
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
}

+ 2
- 1
app/router/admin_router.go View File

@@ -88,7 +88,8 @@ func rFinanceManage(r *gin.RouterGroup) {
}

func rDataStatistics(r *gin.RouterGroup) {
r.POST("/centralKitchenForSchool/list", hdl2.CentralKitchenForSchoolDataStatisticsList) //数据统计-(央厨-学校)-列表
r.POST("/centralKitchenForSchool/export", hdl2.CentralKitchenForSchoolDataStatisticsExport) //数据统计-(央厨-学校)-导出
r.POST("/centralKitchenForSchool/list", hdl2.CentralKitchenForSchoolDataStatisticsList) //数据统计-(央厨-学校)-列表

}



BIN
View File


Loading…
Cancel
Save