Bläddra i källkod

update

add_mode
DengBiao 1 år sedan
förälder
incheckning
5e1cc75f57
18 ändrade filer med 854 tillägg och 11 borttagningar
  1. +173
    -0
      app/admin/hdl/hdl_data_statistics.go
  2. +6
    -6
      app/admin/hdl/hdl_home_page.go
  3. +30
    -0
      app/admin/md/md_central_kitchen_for_school_export_records.go
  4. +1
    -0
      app/admin/md/md_central_kitchen_for_school_order.go
  5. +1
    -0
      app/admin/md/md_nursing_home_order.go
  6. +0
    -3
      app/admin/svc/enterprise_manage/svc_self_support_for_school.go
  7. +1
    -0
      app/admin/svc/order/svc_central_kitchen_for_school_order.go
  8. +1
    -0
      app/admin/svc/order/svc_nursing_home_package_ord.go
  9. +387
    -0
      app/admin/svc/svc_data_statisstics.go
  10. +107
    -0
      app/db/db_nursing_home_export_records.go
  11. +107
    -0
      app/db/db_self_support_for_school_export_records.go
  12. +1
    -0
      app/db/db_user_identity.go
  13. +11
    -0
      app/db/model/nursing_home_export_records.go
  14. +11
    -0
      app/db/model/self_support_for_school_export_records.go
  15. +15
    -1
      app/router/admin_router.go
  16. +1
    -1
      cmd/task/main.go
  17. +1
    -0
      go.mod
  18. Binär
     

+ 173
- 0
app/admin/hdl/hdl_data_statistics.go Visa fil

@@ -3,10 +3,12 @@ package hdl
import (
"applet/app/admin/lib/validate"
"applet/app/admin/md"
"applet/app/admin/svc"
"applet/app/db"
"applet/app/e"
"applet/app/utils"
"github.com/gin-gonic/gin"
"os"
)

func CentralKitchenForSchoolDataStatisticsList(c *gin.Context) {
@@ -104,6 +106,177 @@ func CentralKitchenForSchoolDataStatisticsExport(c *gin.Context) {
e.OutErr(c, err1.Code, err1.Error())
return
}
e.OutSuc(c, map[string]interface{}{
"msg": "导出成功,请稍后刷新数据列表",
}, nil)
return
}

func NursingHomeDataStatisticsList(c *gin.Context) {
var req md.NursingHomeExportRecordsListReq
err := c.ShouldBindJSON(&req)
if err != nil {
err = validate.HandleValidateErr(err)
err1 := err.(e.E)
e.OutErr(c, err1.Code, err1.Error())
return
}
if req.Limit == 0 {
req.Limit = 10
}
if req.Page == 0 {
req.Page = 10
}

nursingHomeExportRecordsDb := db.NursingHomeExportRecordsDb{}
nursingHomeExportRecordsDb.Set()
list, total, err := nursingHomeExportRecordsDb.NursingHomeExportRecordsList(req)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}

e.OutSuc(c, map[string]interface{}{
"list": list,
"total": total,
"kind": []map[string]interface{}{
{
"name": "订单列表",
"value": 1,
},
{
"name": "退款申请表",
"value": 2,
},
{
"name": "预定统计表",
"value": 3,
},
},
}, nil)
return
}

func NursingHomeDataStatisticsDelete(c *gin.Context) {
id := c.Param("id")
nursingHomeExportRecordsDb := db.NursingHomeExportRecordsDb{}
nursingHomeExportRecordsDb.Set()
centralKitchenForSchoolExportRecords, err := nursingHomeExportRecordsDb.GetNursingHomeExportRecords(utils.StrToInt(id))
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
if centralKitchenForSchoolExportRecords == nil {
e.OutErr(c, e.ERR_NO_DATA, "未查询到相关记录")
return
}
os.RemoveAll("./static" + centralKitchenForSchoolExportRecords.DownloadPath) //移除文件
_, err = nursingHomeExportRecordsDb.NursingHomeExportRecordsDelete(id)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
e.OutSuc(c, "success", nil)
return
}

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

go svc.NursingHomeDataStatisticsExport(req)

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

func SelfSupportForSchoolDataStatisticsList(c *gin.Context) {
var req md.SelfSupportForSchoolExportRecordsListReq
err := c.ShouldBindJSON(&req)
if err != nil {
err = validate.HandleValidateErr(err)
err1 := err.(e.E)
e.OutErr(c, err1.Code, err1.Error())
return
}
if req.Limit == 0 {
req.Limit = 10
}
if req.Page == 0 {
req.Page = 10
}

selfSupportForSchoolExportRecordsDb := db.SelfSupportForSchoolExportRecordsDb{}
selfSupportForSchoolExportRecordsDb.Set()
list, total, err := selfSupportForSchoolExportRecordsDb.SelfSupportForSchoolExportRecordsList(req)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}

e.OutSuc(c, map[string]interface{}{
"list": list,
"total": total,
"kind": []map[string]interface{}{
{
"name": "学生列表",
"value": 1,
},
{
"name": "老师列表",
"value": 2,
},
{
"name": "消费明细表",
"value": 3,
},
},
}, nil)
return
}

func SelfSupportForSchoolDataStatisticsDelete(c *gin.Context) {
id := c.Param("id")
selfSupportForSchoolExportRecordsDb := db.SelfSupportForSchoolExportRecordsDb{}
selfSupportForSchoolExportRecordsDb.Set()
selfSupportForSchoolExportRecords, err := selfSupportForSchoolExportRecordsDb.GetSelfSupportForSchoolExportRecords(utils.StrToInt(id))
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
if selfSupportForSchoolExportRecords == nil {
e.OutErr(c, e.ERR_NO_DATA, "未查询到相关记录")
return
}
os.RemoveAll("./static" + selfSupportForSchoolExportRecords.DownloadPath) //移除文件
_, err = selfSupportForSchoolExportRecordsDb.SelfSupportForSchoolExportRecordsDelete(id)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
e.OutSuc(c, "success", nil)
return
}

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

go svc.SelfSupportForSchoolDataStatisticsExport(req)

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


+ 6
- 6
app/admin/hdl/hdl_home_page.go Visa fil

@@ -16,10 +16,10 @@ import (

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) //统计今日"央厨-学校"收益
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())
@@ -108,8 +108,8 @@ func ThisWeekData(c *gin.Context) {
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) //统计今日"央厨-学校"收益
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())


+ 30
- 0
app/admin/md/md_central_kitchen_for_school_export_records.go Visa fil

@@ -14,3 +14,33 @@ type CentralKitchenForSchoolDataStatisticsExportReq struct {
EndDate string `json:"end_date" binding:"required" label:"截止时间"`
EnterpriseId int `json:"enterprise_id" label:"校企id"`
}

type NursingHomeExportRecordsListReq struct {
Page int `json:"page" label:"页码"`
Kind int `json:"kind" label:"导出类型"`
Limit int `json:"limit" label:"每页数量"`
StartDate string `json:"start_date" label:"起始时间"`
EndDate string `json:"end_date" label:"截止时间"`
}

type NursingHomeDataStatisticsExportReq 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" binding:"required" label:"校企id"`
}

type SelfSupportForSchoolExportRecordsListReq struct {
Page int `json:"page" label:"页码"`
Kind int `json:"kind" label:"导出类型"`
Limit int `json:"limit" label:"每页数量"`
StartDate string `json:"start_date" label:"起始时间"`
EndDate string `json:"end_date" label:"截止时间"`
}

type SelfSupportForSchoolDataStatisticsExportReq 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"`
}

+ 1
- 0
app/admin/md/md_central_kitchen_for_school_order.go Visa fil

@@ -14,6 +14,7 @@ type CentralKitchenForSchoolOrderRefundListResp struct {
Amount string `json:"amount" label:"退款金额"`
State int `json:"state" label:"退款订单状态"`
CreateAt string `json:"create_at" label:"申请时间"`
RefundDate string `json:"refund_date" label:"退款时间"`
Memo string `json:"memo" label:"备注"`
}



+ 1
- 0
app/admin/md/md_nursing_home_order.go Visa fil

@@ -12,6 +12,7 @@ type NursingHomeOrderRefundListResp struct {
Amount string `json:"amount" label:"退款金额"`
State int `json:"state" label:"退款订单状态"`
CreateAt string `json:"create_at" label:"申请时间"`
RefundDate string `json:"refund_date" label:"退款时间"`
Memo string `json:"memo" label:"备注"`
}



+ 0
- 3
app/admin/svc/enterprise_manage/svc_self_support_for_school.go Visa fil

@@ -335,9 +335,6 @@ func SelfSupportForSchoolTeacherList(req md.SelfSupportForSchoolTeacherListReq)
var m []*db.UserIdentityWithUser
count, err = sess.
Join("LEFT", "user", "user_identity.uid = user.id").
Join("LEFT", "class_with_user", "class_with_user.user_identity_id = user_identity.id").
Join("LEFT", "class", "class_with_user.class_id = class.id").
Join("LEFT", "grade", "class.grade_id = grade.id").
Join("LEFT", "self_support_for_user_face_info", "user_identity.id = self_support_for_user_face_info.user_identity_id").
Limit(req.Limit, (req.Page-1)*req.Limit).FindAndCount(&m)
if err != nil {


+ 1
- 0
app/admin/svc/order/svc_central_kitchen_for_school_order.go Visa fil

@@ -139,6 +139,7 @@ func CentralKitchenForSchoolOrderRefundList(req md.CentralKitchenForSchoolOrderR
Amount: v.CentralKitchenForSchoolUserRefundDay.Amount,
State: v.CentralKitchenForSchoolUserRefundDay.State,
CreateAt: v.CentralKitchenForSchoolUserRefundDay.CreateAt,
RefundDate: v.CentralKitchenForSchoolUserRefundDay.RefundDate,
Memo: v.CentralKitchenForSchoolUserRefundDay.Memo,
})
}


+ 1
- 0
app/admin/svc/order/svc_nursing_home_package_ord.go Visa fil

@@ -80,6 +80,7 @@ func NursingHomeOrderRefundList(req md.NursingHomeOrderRefundListReq) (resp []md
Amount: v.NursingHomeUserRefundDay.Amount,
State: v.NursingHomeUserRefundDay.State,
CreateAt: v.NursingHomeUserRefundDay.CreateAt,
RefundDate: v.NursingHomeUserRefundDay.RefundDate,
Memo: v.NursingHomeUserRefundDay.Memo,
})
}


+ 387
- 0
app/admin/svc/svc_data_statisstics.go Visa fil

@@ -0,0 +1,387 @@
package svc

import (
"applet/app/admin/md"
"applet/app/db"
"applet/app/db/model"
"applet/app/enum"
"applet/app/utils"
"applet/app/utils/logx"
"encoding/json"
"github.com/360EntSecGroup-Skylar/excelize"
"strconv"
"time"
)

func NursingHomeDataStatisticsExport(req md.NursingHomeDataStatisticsExportReq) {
var titleList []string
var fileName string
var now = time.Now()
xlsx := excelize.NewFile()
xlsx.SetSheetRow("Sheet1", "A1", &titleList)
switch req.Kind {
case 1:
//订单列表
fileName = "/export/nursing_home/订单列表_" + req.StartDate + "-" + req.EndDate + utils.Int64ToStr(now.UnixMilli()) + ".xlsx"

//查找订单数据
sess := db.Db.Desc("nursing_home_package_ord.id")
if req.EnterpriseId != 0 {
sess.And("nursing_home_package_ord.enterprise_id =?", req.EnterpriseId)
}
if req.StartDate != "" {
sess.And("nursing_home_package_ord.create_at >= ?", req.StartDate)
}
if req.EndDate != "" {
sess.And("nursing_home_package_ord.create_at <= ?", req.EndDate)
}
var m []*db.NursingHomePackageOrdWithUserIdentity
_, err := sess.
Join("LEFT", "user_identity", "nursing_home_package_ord.user_identity_id = user_identity.id").
Join("LEFT", "enterprise", "enterprise.id = nursing_home_package_ord.enterprise_id").
Join("LEFT", "user", "user.id = nursing_home_package_ord.uid").
FindAndCount(&m)
if err != nil {
logx.Error(err)
println("<<<<NursingHomeDataStatisticsExport1>>>>>Error:::", err.Error())
return
}
titleList = []string{"单位名称", "用户身份名称", "用户手机号", "购买类型", "总价", "商户订单号", "支付状态", "购买时间"}
j := 2 //表头被第一行用了,只能从第二行开始
for _, v := range m {
var kind string //1:按年购买 2:按月购买 3:按天购买 4:补餐
switch v.NursingHomePackageOrd.Kind {
case 1:
kind = "按年购买"
break
case 2:
kind = "按月购买"
break
case 3:
kind = "按天购买"
break
case 4:
kind = "补餐"
break
}

var state string //0:待支付 1:支付成功 2:支付失败
switch v.NursingHomePackageOrd.State {
case enum.NursingHomePackageOrdStateForWait:
state = enum.NursingHomePackageOrdState.String(enum.NursingHomePackageOrdStateForWait)
break
case enum.NursingHomePackageOrdStateForSuccess:
state = enum.NursingHomePackageOrdState.String(enum.NursingHomePackageOrdStateForWait)
break
case enum.NursingHomePackageOrdStateForFail:
state = enum.NursingHomePackageOrdState.String(enum.NursingHomePackageOrdStateForFail)
break
}
xlsx.SetSheetRow("Sheet1", "A"+strconv.Itoa(j), &[]interface{}{v.Enterprise.Name, v.NursingHomePackageOrd.UserIdentityName, v.User.Phone, kind, v.NursingHomePackageOrd.TotalPrice,
v.NursingHomePackageOrd.OutTradeNo, state, v.NursingHomePackageOrd.CreateAt})
j++
}
xlsx.SaveAs("./static" + fileName)
break
case 2:
//退款申请表
fileName = "/export/nursing_home/退款申请表_" + req.StartDate + "-" + req.EndDate + utils.Int64ToStr(now.UnixMilli()) + ".xlsx"
var m []*db.NursingHomeUserRefundDayWithData
sess := db.Db.Desc("nursing_home_user_refund_day.id")
if req.EnterpriseId != 0 {
sess.And("enterprise.enterprise_id =?", req.EnterpriseId)
}
if req.StartDate != "" {
sess.And("nursing_home_user_refund_day.create_at >= ?", req.StartDate)
}
if req.EndDate != "" {
sess.And("nursing_home_user_refund_day.create_at <= ?", req.EndDate)
}
_, err := sess.
Join("LEFT", "nursing_home_user_with_day", "nursing_home_user_refund_day.records_id = nursing_home_user_with_day.id").
Join("LEFT", "nursing_home_package_ord", "nursing_home_user_refund_day.out_trade_no = nursing_home_package_ord.out_trade_no").
Join("LEFT", "user_identity", "nursing_home_user_with_day.identity_id = user_identity.id").
Join("LEFT", "user", "user_identity.uid = user.id").
Join("LEFT", "enterprise", "user_identity.enterprise_id = enterprise.id").
Desc("nursing_home_user_refund_day.id").
FindAndCount(&m)
if err != nil {
logx.Error(err)
println("<<<<NursingHomeDataStatisticsExport2>>>>>Error:::", err.Error())
return
}

titleList = []string{"退款单号", "所属订单号", "单位名称", "用户身份名称", "用户手机号", "就餐类型", "就餐时间", "金额", "状态", "退款时间"}
j := 2 //表头被第一行用了,只能从第二行开始
for _, v := range m {
var kind string //就餐类型(1:早餐 2:午餐 3:晚餐)
switch v.NursingHomeUserWithDay.Kind {
case enum.NursingHomeUserWithDayKindForBreakfast:
kind = enum.NursingHomeUserWithDayKind.String(enum.NursingHomeUserWithDayKindForBreakfast)
break
case enum.NursingHomeUserWithDayKindForLunch:
kind = enum.NursingHomeUserWithDayKind.String(enum.NursingHomeUserWithDayKindForLunch)
break
case enum.NursingHomeUserWithDayKindForDinner:
kind = enum.NursingHomeUserWithDayKind.String(enum.NursingHomeUserWithDayKindForDinner)
break
}

var state string //状态(1:审核中 2:审核通过 3:审核拒绝 4:退款已完成)
switch v.NursingHomeUserRefundDay.State {
case enum.NursingHomeUserRefundDayStateForAuditing:
state = enum.NursingHomeUserRefundDayState.String(enum.NursingHomeUserRefundDayStateForAuditing)
break
case enum.NursingHomeUserRefundDayStateForAuditPass:
state = enum.NursingHomeUserRefundDayState.String(enum.NursingHomeUserRefundDayStateForAuditPass)
break
case enum.NursingHomeUserRefundDayStateForAuditReject:
state = enum.NursingHomeUserRefundDayState.String(enum.NursingHomeUserRefundDayStateForAuditReject)
break
case enum.NursingHomeUserRefundDayStateForAuditComplete:
state = enum.NursingHomeUserRefundDayState.String(enum.NursingHomeUserRefundDayStateForAuditComplete)
break
}
xlsx.SetSheetRow("Sheet1", "A"+strconv.Itoa(j), &[]interface{}{v.NursingHomeUserRefundDay.OutRequestNo, v.NursingHomeUserRefundDay.OutTradeNo, v.Enterprise.Name,
v.NursingHomePackageOrd.UserIdentityName, v.User.Phone, kind, v.NursingHomeUserWithDay.Date, v.NursingHomeUserRefundDay.Amount, state, v.NursingHomeUserRefundDay.RefundDate})
j++
}
xlsx.SaveAs("./static" + fileName + ".xlsx")
break
case 3:
//预定统计表
fileName = "/export/nursing_home/预定统计表_" + req.StartDate + "-" + req.EndDate + utils.Int64ToStr(now.UnixMilli()) + ".xlsx"
var m []*db.NursingHomePackageOrdForReserveWithUserIdentity
sess := db.Db.Desc("nursing_home_package_ord_for_reserve.id")
if req.EnterpriseId != 0 {
sess.And("enterprise.enterprise_id =?", req.EnterpriseId)
}
if req.StartDate != "" {
sess.And("nursing_home_package_ord_for_reserve.meal_time_start >= ?", req.StartDate)
}
if req.EndDate != "" {
sess.And("nursing_home_package_ord_for_reserve.meal_time_start <= ?", req.EndDate)
}
_, err := sess.
Join("LEFT", "nursing_home_package_ord", "nursing_home_package_ord_for_reserve.out_trade_no = nursing_home_package_ord.out_trade_no").
Join("LEFT", "user_identity", "nursing_home_package_ord.user_identity_id = user_identity.id").
Join("LEFT", "enterprise", "enterprise.id = user_identity.enterprise_id").
Join("LEFT", "user", "user.id = user_identity.uid").FindAndCount(&m)
if err != nil {
logx.Error(err)
println("<<<<NursingHomeDataStatisticsExport2>>>>>Error:::", err.Error())
return
}

titleList = []string{"所属订单号", "单位名称", "用户身份名称", "用户手机号", "预定类型", "预定月份", "就餐时间-开始", "就餐时间-截止"}
j := 2 //表头被第一行用了,只能从第二行开始
for _, v := range m {
var kind string //预定类型(1:早餐 2:午餐 3:晚餐)
switch v.NursingHomePackageOrdForReserve.Kind {
case enum.NursingHomeUserWithDayKindForBreakfast:
kind = enum.NursingHomeUserWithDayKind.String(enum.NursingHomeUserWithDayKindForBreakfast)
break
case enum.NursingHomeUserWithDayKindForLunch:
kind = enum.NursingHomeUserWithDayKind.String(enum.NursingHomeUserWithDayKindForLunch)
break
case enum.NursingHomeUserWithDayKindForDinner:
kind = enum.NursingHomeUserWithDayKind.String(enum.NursingHomeUserWithDayKindForDinner)
break
}

xlsx.SetSheetRow("Sheet1", "A"+strconv.Itoa(j), &[]interface{}{v.NursingHomePackageOrdForReserve.OutTradeNo, v.Enterprise.Name, v.NursingHomePackageOrd.UserIdentityName,
v.User.Phone, kind, v.NursingHomePackageOrdForReserve.ReserveMonth, v.NursingHomePackageOrdForReserve.MealTimeStart, v.NursingHomePackageOrdForReserve.MealTimeEnd})
j++
}
xlsx.SaveAs("./static" + fileName + ".xlsx")
break
}
//新增数据
nursingHomeExportRecordsDb := db.NursingHomeExportRecordsDb{}
nursingHomeExportRecordsDb.Set()
marshal, _ := json.Marshal(req)
nursingHomeExportRecordsDb.NursingHomeExportRecordsInsert(&model.NursingHomeExportRecords{
Name: fileName,
DownloadPath: fileName,
Kind: req.Kind,
ReqContent: string(marshal),
CreateAt: now.Format("2006-01-02 15:04:05"),
UpdateAt: now.Format("2006-01-02 15:04:05"),
})
}

func SelfSupportForSchoolDataStatisticsExport(req md.SelfSupportForSchoolDataStatisticsExportReq) {
var titleList []string
var fileName string
var now = time.Now()
xlsx := excelize.NewFile()
xlsx.SetSheetRow("Sheet1", "A1", &titleList)
switch req.Kind {
case 1:
//学生列表
fileName = "/export/self_support_for_school/学生列表_" + req.StartDate + "-" + req.EndDate + utils.Int64ToStr(now.UnixMilli()) + ".xlsx"

//查找订单数据
sess := db.Db.Desc("user_identity.id")
sess.And("identity =?", enum.UserIdentityForSelfSupportForStudent)
if req.EnterpriseId != 0 {
sess.And("user_identity.enterprise_id =?", req.EnterpriseId)
}
if req.StartDate != "" {
sess.And("user_identity.create_at >= ?", req.StartDate)
}
if req.EndDate != "" {
sess.And("user_identity.create_at <= ?", req.EndDate)
}
var m []*db.UserIdentityWithUser
_, err := sess.
Join("LEFT", "user", "user_identity.uid = user.id").
Join("LEFT", "enterprise", "user_identity.enterprise_id = enterprise.id").
Join("LEFT", "class_with_user", "class_with_user.user_identity_id = user_identity.id").
Join("LEFT", "class", "class_with_user.class_id = class.id").
Join("LEFT", "grade", "class.grade_id = grade.id").
Join("LEFT", "self_support_for_user_face_info", "user_identity.id = self_support_for_user_face_info.user_identity_id").
FindAndCount(&m)
if err != nil {
logx.Error(err)
println("<<<<SelfSupportForSchoolDataStatisticsExport1>>>>>Error:::", err.Error())
return
}
titleList = []string{"单位名称", "姓名", "身份证号", "家长电话", "采脸方式", "支付状态", "刷脸状态", "年级", "班级", "注册时间"}
j := 2 //表头被第一行用了,只能从第二行开始
for _, v := range m {
var kind string //采集人脸方式(1:个采 2:集采)
switch v.SelfSupportForUserFaceInfo.CollectFaceType {
case 1:
kind = "个采"
break
case 2:
kind = "集采"
break
}

xlsx.SetSheetRow("Sheet1", "A"+strconv.Itoa(j), &[]interface{}{v.Enterprise.Name, v.UserIdentity.Name, v.UserIdentity.IdNo, v.User.Phone, kind,
v.SelfSupportForUserFaceInfo.SchoolFacePaymentStatus, v.SelfSupportForUserFaceInfo.SchoolFacePassStatus, v.Grade.Name, v.Class.Name, v.UserIdentity.CreateAt})
j++
}
xlsx.SaveAs("./static" + fileName)
break
case 2:
//教师列表
fileName = "/export/self_support_for_school/教师列表_" + req.StartDate + "-" + req.EndDate + utils.Int64ToStr(now.UnixMilli()) + ".xlsx"

//查找订单数据
sess := db.Db.Desc("user_identity.id")
sess.And("identity =?", enum.UserIdentityForSelfSupportForTeacher)
if req.EnterpriseId != 0 {
sess.And("user_identity.enterprise_id =?", req.EnterpriseId)
}
if req.StartDate != "" {
sess.And("user_identity.create_at >= ?", req.StartDate)
}
if req.EndDate != "" {
sess.And("user_identity.create_at <= ?", req.EndDate)
}
var m []*db.UserIdentityWithUser
_, err := sess.
Join("LEFT", "user", "user_identity.uid = user.id").
Join("LEFT", "enterprise", "user_identity.enterprise_id = enterprise.id").
Join("LEFT", "self_support_for_user_face_info", "user_identity.id = self_support_for_user_face_info.user_identity_id").
FindAndCount(&m)
if err != nil {
logx.Error(err)
println("<<<<SelfSupportForSchoolDataStatisticsExport2>>>>>Error:::", err.Error())
return
}
titleList = []string{"单位名称", "姓名", "身份证号", "电话", "采脸方式", "支付状态", "刷脸状态", "注册时间"}
j := 2 //表头被第一行用了,只能从第二行开始
for _, v := range m {
var kind string //采集人脸方式(1:个采 2:集采)
switch v.SelfSupportForUserFaceInfo.CollectFaceType {
case 1:
kind = "个采"
break
case 2:
kind = "集采"
break
}

xlsx.SetSheetRow("Sheet1", "A"+strconv.Itoa(j), &[]interface{}{v.Enterprise.Name, v.UserIdentity.Name, v.UserIdentity.IdNo, v.User.Phone, kind,
v.SelfSupportForUserFaceInfo.SchoolFacePaymentStatus, v.SelfSupportForUserFaceInfo.SchoolFacePassStatus, v.UserIdentity.CreateAt})
j++
}
xlsx.SaveAs("./static" + fileName)
break
case 3:
//消费明细表
fileName = "/export/self_support_for_school/消费明细表_" + req.StartDate + "-" + req.EndDate + utils.Int64ToStr(now.UnixMilli()) + ".xlsx"
var m []*db.SelfSupportForSchoolOrdWithUserIdentity
sess := db.Db.Desc("self_support_for_school_ord.id")
if req.EnterpriseId != 0 {
sess.And("self_support_for_school_ord.enterprise_id =?", req.EnterpriseId)
}
if req.StartDate != "" {
sess.And("self_support_for_school_ord.face_time >= ?", req.StartDate)
}
if req.EndDate != "" {
sess.And("self_support_for_school_ord.face_time <= ?", req.EndDate)
}
_, err := sess.
Join("LEFT", "user_identity", "self_support_for_school_ord.user_identity_id = user_identity.id").
Join("LEFT", "enterprise", "enterprise.id = user_identity.enterprise_id").
Join("LEFT", "user", "user.id = user_identity.uid").
Join("LEFT", "class_with_user", "class_with_user.user_identity_id = user_identity.id").
Join("LEFT", "class", "class_with_user.class_id = class.id").
Join("LEFT", "grade", "class.grade_id = grade.id").
FindAndCount(&m)
if err != nil {
logx.Error(err)
println("<<<<SelfSupportForSchoolDataStatisticsExport3>>>>>Error:::", err.Error())
return
}

titleList = []string{"订单编号", "支付交易号", "用户手机号", "就餐人姓名", "学校名称", "年级", "班级", "金额", "支付状态", "就餐时间", "设备编号", "身份"}
j := 2 //表头被第一行用了,只能从第二行开始
for _, v := range m {
var state string //支付状态(0:待支付 1:支付成功)
switch v.SelfSupportForSchoolOrd.OrderStatus {
case 0:
state = "待支付"
break
case 1:
state = "支付成功"
break
}

var identity string
switch enum.UserIdentityForSelfSupportForTeacher {
case enum.UserIdentityForSelfSupportForTeacher:
identity = enum.UserIdentity.String(enum.UserIdentityForSelfSupportForTeacher)
break
case enum.UserIdentityForSelfSupportForStudent:
identity = enum.UserIdentity.String(enum.UserIdentityForSelfSupportForStudent)
break
default:
identity = "未知"
}

xlsx.SetSheetRow("Sheet1", "A"+strconv.Itoa(j), &[]interface{}{v.SelfSupportForSchoolOrd.OutOrderNo, v.SelfSupportForSchoolOrd.TradeNo, v.UserIdentity.Name, v.Enterprise.Name,
v.Grade.Name, v.Class.Name, v.SelfSupportForSchoolOrd.TradeAmount, state, v.SelfSupportForSchoolOrd.FaceTime, v.SelfSupportForSchoolOrd.DeviceSn, identity})
j++
}
xlsx.SaveAs("./static" + fileName + ".xlsx")
break
}
//新增数据
selfSupportForSchoolExportRecordsDb := db.SelfSupportForSchoolExportRecordsDb{}
selfSupportForSchoolExportRecordsDb.Set()
marshal, _ := json.Marshal(req)
selfSupportForSchoolExportRecordsDb.SelfSupportForSchoolExportRecordsInsert(&model.SelfSupportForSchoolExportRecords{
Name: fileName,
DownloadPath: fileName,
Kind: req.Kind,
ReqContent: string(marshal),
CreateAt: now.Format("2006-01-02 15:04:05"),
UpdateAt: now.Format("2006-01-02 15:04:05"),
})
}

+ 107
- 0
app/db/db_nursing_home_export_records.go Visa fil

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

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

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

func (nursingHomeExportRecordsDb *NursingHomeExportRecordsDb) Set() { // set方法
nursingHomeExportRecordsDb.Db = Db
}

func (nursingHomeExportRecordsDb *NursingHomeExportRecordsDb) GetNursingHomeExportRecords(id int) (m *model.NursingHomeExportRecords, err error) {
m = new(model.NursingHomeExportRecords)
has, err := nursingHomeExportRecordsDb.Db.Where("id =?", id).Get(m)
if err != nil {
return nil, logx.Error(err)
}
if has == false {
return nil, nil
}
return m, nil
}

func (nursingHomeExportRecordsDb *NursingHomeExportRecordsDb) GetNursingHomeExportRecordsByMonth(year, month string) (m *model.NursingHomeExportRecords, err error) {
m = new(model.NursingHomeExportRecords)
has, err := nursingHomeExportRecordsDb.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 (nursingHomeExportRecordsDb *NursingHomeExportRecordsDb) FindNursingHomeExportRecords() (*[]model.NursingHomeExportRecords, error) {
var m []model.NursingHomeExportRecords
if err := nursingHomeExportRecordsDb.Db.Desc("id").Find(&m); err != nil {
return nil, logx.Error(err)
}
return &m, nil
}

func (nursingHomeExportRecordsDb *NursingHomeExportRecordsDb) NursingHomeExportRecordsInsert(m *model.NursingHomeExportRecords) (int, error) {
_, err := nursingHomeExportRecordsDb.Db.InsertOne(m)
if err != nil {
return 0, err
}
return m.Id, nil
}

func (nursingHomeExportRecordsDb *NursingHomeExportRecordsDb) NursingHomeExportRecordsInsertBySession(session *xorm.Session, m *model.NursingHomeExportRecords) (int, error) {
_, err := session.InsertOne(m)
if err != nil {
return 0, err
}
return m.Id, nil
}

func (nursingHomeExportRecordsDb *NursingHomeExportRecordsDb) NursingHomeExportRecordsDelete(id interface{}) (int64, error) {
if reflect.TypeOf(id).Kind() == reflect.Slice {
return Db.In("id", id).Delete(model.NursingHomeExportRecords{})
} else {
return Db.Where("id = ?", id).Delete(model.NursingHomeExportRecords{})
}
}

func (nursingHomeExportRecordsDb *NursingHomeExportRecordsDb) NursingHomeExportRecordsUpdateBySession(session *xorm.Session, id interface{}, m *model.NursingHomeExportRecords, 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 (nursingHomeExportRecordsDb *NursingHomeExportRecordsDb) NursingHomeExportRecordsList(req md.NursingHomeExportRecordsListReq) (m []model.NursingHomeExportRecords, total int64, err error) {
sess := nursingHomeExportRecordsDb.Db.Desc("id")
if req.Kind != 0 {
sess.And("kind =?", req.Kind)
}
if req.StartDate != "" {
sess.And("create_at >=?", req.StartDate)
}
if req.EndDate != "" {
sess.And("create_at <=?", req.EndDate)
}
total, err = sess.Limit(req.Limit, (req.Page-1)*req.Limit).FindAndCount(&m)
if err != nil {
return
}
return
}

+ 107
- 0
app/db/db_self_support_for_school_export_records.go Visa fil

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

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

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

func (selfSupportForSchoolExportRecordsDb *SelfSupportForSchoolExportRecordsDb) Set() { // set方法
selfSupportForSchoolExportRecordsDb.Db = Db
}

func (selfSupportForSchoolExportRecordsDb *SelfSupportForSchoolExportRecordsDb) GetSelfSupportForSchoolExportRecords(id int) (m *model.SelfSupportForSchoolExportRecords, err error) {
m = new(model.SelfSupportForSchoolExportRecords)
has, err := selfSupportForSchoolExportRecordsDb.Db.Where("id =?", id).Get(m)
if err != nil {
return nil, logx.Error(err)
}
if has == false {
return nil, nil
}
return m, nil
}

func (selfSupportForSchoolExportRecordsDb *SelfSupportForSchoolExportRecordsDb) GetSelfSupportForSchoolExportRecordsByMonth(year, month string) (m *model.SelfSupportForSchoolExportRecords, err error) {
m = new(model.SelfSupportForSchoolExportRecords)
has, err := selfSupportForSchoolExportRecordsDb.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 (selfSupportForSchoolExportRecordsDb *SelfSupportForSchoolExportRecordsDb) FindSelfSupportForSchoolExportRecords() (*[]model.SelfSupportForSchoolExportRecords, error) {
var m []model.SelfSupportForSchoolExportRecords
if err := selfSupportForSchoolExportRecordsDb.Db.Desc("id").Find(&m); err != nil {
return nil, logx.Error(err)
}
return &m, nil
}

func (selfSupportForSchoolExportRecordsDb *SelfSupportForSchoolExportRecordsDb) SelfSupportForSchoolExportRecordsInsert(m *model.SelfSupportForSchoolExportRecords) (int, error) {
_, err := selfSupportForSchoolExportRecordsDb.Db.InsertOne(m)
if err != nil {
return 0, err
}
return m.Id, nil
}

func (selfSupportForSchoolExportRecordsDb *SelfSupportForSchoolExportRecordsDb) SelfSupportForSchoolExportRecordsInsertBySession(session *xorm.Session, m *model.SelfSupportForSchoolExportRecords) (int, error) {
_, err := session.InsertOne(m)
if err != nil {
return 0, err
}
return m.Id, nil
}

func (selfSupportForSchoolExportRecordsDb *SelfSupportForSchoolExportRecordsDb) SelfSupportForSchoolExportRecordsDelete(id interface{}) (int64, error) {
if reflect.TypeOf(id).Kind() == reflect.Slice {
return Db.In("id", id).Delete(model.SelfSupportForSchoolExportRecords{})
} else {
return Db.Where("id = ?", id).Delete(model.SelfSupportForSchoolExportRecords{})
}
}

func (selfSupportForSchoolExportRecordsDb *SelfSupportForSchoolExportRecordsDb) SelfSupportForSchoolExportRecordsUpdateBySession(session *xorm.Session, id interface{}, m *model.SelfSupportForSchoolExportRecords, 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 (selfSupportForSchoolExportRecordsDb *SelfSupportForSchoolExportRecordsDb) SelfSupportForSchoolExportRecordsList(req md.SelfSupportForSchoolExportRecordsListReq) (m []model.SelfSupportForSchoolExportRecords, total int64, err error) {
sess := selfSupportForSchoolExportRecordsDb.Db.Desc("id")
if req.Kind != 0 {
sess.And("kind =?", req.Kind)
}
if req.StartDate != "" {
sess.And("create_at >=?", req.StartDate)
}
if req.EndDate != "" {
sess.And("create_at <=?", req.EndDate)
}
total, err = sess.Limit(req.Limit, (req.Page-1)*req.Limit).FindAndCount(&m)
if err != nil {
return
}
return
}

+ 1
- 0
app/db/db_user_identity.go Visa fil

@@ -190,6 +190,7 @@ type UserIdentityWithUser struct {
model.Class `xorm:"extends"`
model.Grade `xorm:"extends"`
model.SelfSupportForUserFaceInfo `xorm:"extends"`
model.Enterprise `xorm:"extends"`
}

func (UserIdentityWithUser) TableName() string {


+ 11
- 0
app/db/model/nursing_home_export_records.go Visa fil

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

type NursingHomeExportRecords 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"`
}

+ 11
- 0
app/db/model/self_support_for_school_export_records.go Visa fil

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

type SelfSupportForSchoolExportRecords 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:预定统计表)') 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"`
}

+ 15
- 1
app/router/admin_router.go Visa fil

@@ -101,7 +101,15 @@ func rFinanceManage(r *gin.RouterGroup) {
func rDataStatistics(r *gin.RouterGroup) {
r.POST("/centralKitchenForSchool/export", hdl2.CentralKitchenForSchoolDataStatisticsExport) //数据统计-(央厨-学校)-导出
r.POST("/centralKitchenForSchool/list", hdl2.CentralKitchenForSchoolDataStatisticsList) //数据统计-(央厨-学校)-列表
r.DELETE("/centralKitchenForSchool/delete/:id", hdl2.CentralKitchenForSchoolDataStatisticsDelete) //数据统计-(央厨-学校)-列表
r.DELETE("/centralKitchenForSchool/delete/:id", hdl2.CentralKitchenForSchoolDataStatisticsDelete) //数据统计-(央厨-学校)-删除

r.POST("/nursingHome/export", hdl2.NursingHomeDataStatisticsExport) //数据统计-(养老院)-导出
r.POST("/nursingHome/list", hdl2.NursingHomeDataStatisticsList) //数据统计-(养老院)-列表
r.DELETE("/nursingHome/delete/:id", hdl2.NursingHomeDataStatisticsDelete) //数据统计-(养老院)-删除

r.POST("/selfSupportForSchool/export", hdl2.SelfSupportForSchoolDataStatisticsExport) //数据统计-(自营-学校)-导出
r.POST("/selfSupportForSchool/list", hdl2.SelfSupportForSchoolDataStatisticsList) //数据统计-(自营-学校)-列表
r.DELETE("/selfSupportForSchool/delete/:id", hdl2.SelfSupportForSchoolDataStatisticsDelete) //数据统计-(自营-学校)-删除

}

@@ -189,6 +197,9 @@ func rEnterpriseManage(r *gin.RouterGroup) {
r.POST("/selfSupportForSchool/arrearsOrdDebtCancel", hdl.SelfSupportForSchoolArrearsOrdDebtCancel) //"自营-学校"撤销欠款
r.GET("/selfSupportForSchool/educateSceneKidsClose", hdl.SelfSupportForSchoolEducateSceneKidsClose) //"自营-学校"人脸识别关闭
r.GET("/selfSupportForSchool/educateFacepayClose", hdl.SelfSupportForSchoolEducateFacepayClose) //"自营-学校"刷脸支付关闭
//r.POST("/selfSupportForSchool/statisticsExport", hdl2.SelfSupportForSchoolDataStatisticsExport) //"自营-学校-数据统计"-导出
//r.POST("/selfSupportForSchool/statisticsList", hdl2.SelfSupportForSchoolDataStatisticsList) //"自营-学校-数据统计"-列表
//r.DELETE("/selfSupportForSchool/statisticsDelete/:id", hdl2.SelfSupportForSchoolDataStatisticsDelete) //"自营-学校-数据统计"-删除

r.POST("/nursingHome/userUpdate", hdl.NursingHomeUserUpdate) //"养老院"用户编辑
r.POST("/nursingHome/userDelete", hdl.NursingHomeUserDelete) //"养老院"用户删除
@@ -206,6 +217,9 @@ func rEnterpriseManage(r *gin.RouterGroup) {
r.GET("/detailNursingHomePackage", hdl.DetailNursingHomePackage) //"养老院-套餐" 详情
r.POST("/saveNursingHomePackage", hdl.SaveNursingHomePackage) //新增/编辑 "养老院-套餐"
r.DELETE("/deleteNursingHomePackage/:id", hdl.DeleteNursingHomePackage) //删除 "养老院-套餐"
//r.POST("/nursingHome/statisticsExport", hdl2.NursingHomeDataStatisticsExport) //"养老院-数据统计"-导出
//r.POST("/nursingHome/statisticsList", hdl2.NursingHomeDataStatisticsList) //"养老院-数据统计"-列表
//r.DELETE("/nursingHome/statisticsDelete/:id", hdl2.NursingHomeDataStatisticsDelete) //"养老院-数据统计"-删除
}

func rRole(r *gin.RouterGroup) {


+ 1
- 1
cmd/task/main.go Visa fil

@@ -1,7 +1,7 @@
package main

import (
"applet/app/admin/db"
"applet/app/db"
"fmt"
"os"
"os/signal"


+ 1
- 0
go.mod Visa fil

@@ -3,6 +3,7 @@ module applet
go 1.15

require (
github.com/360EntSecGroup-Skylar/excelize v1.4.1
github.com/boombuler/barcode v1.0.1
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/forgoer/openssl v0.0.0-20201023062029-c3112b0c8700


Binär
Visa fil


Laddar…
Avbryt
Spara