diff --git a/app/admin/hdl/hdl_data_statistics.go b/app/admin/hdl/hdl_data_statistics.go index b39aa38..6357a4a 100644 --- a/app/admin/hdl/hdl_data_statistics.go +++ b/app/admin/hdl/hdl_data_statistics.go @@ -5,6 +5,7 @@ import ( "applet/app/admin/md" "applet/app/db" "applet/app/e" + "applet/app/utils" "github.com/gin-gonic/gin" ) @@ -72,6 +73,28 @@ func CentralKitchenForSchoolDataStatisticsList(c *gin.Context) { return } +func CentralKitchenForSchoolDataStatisticsDelete(c *gin.Context) { + id := c.Param("id") + centralKitchenForSchoolExportRecordsDb := db.CentralKitchenForSchoolExportRecordsDb{} + centralKitchenForSchoolExportRecordsDb.Set() + centralKitchenForSchoolExportRecords, err := centralKitchenForSchoolExportRecordsDb.GetCentralKitchenForSchoolExportRecords(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 + } + _, err = centralKitchenForSchoolExportRecordsDb.CentralKitchenForSchoolExportRecordsDelete(id) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + e.OutSuc(c, "success", nil) + return +} + func CentralKitchenForSchoolDataStatisticsExport(c *gin.Context) { var req md.CentralKitchenForSchoolDataStatisticsExportReq err := c.ShouldBindJSON(&req) diff --git a/app/admin/md/md_central_kitchen_for_school_export_records.go b/app/admin/md/md_central_kitchen_for_school_export_records.go index ad28418..75e6099 100644 --- a/app/admin/md/md_central_kitchen_for_school_export_records.go +++ b/app/admin/md/md_central_kitchen_for_school_export_records.go @@ -1,8 +1,11 @@ package md type CentralKitchenForSchoolExportRecordsListReq struct { - Page int `json:"page" label:"页码"` - Limit int `json:"limit" label:"每页数量"` + 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 CentralKitchenForSchoolDataStatisticsExportReq struct { diff --git a/app/customer/hdl/hdl_central_kitchen_for_school_order.go b/app/customer/hdl/hdl_central_kitchen_for_school_order.go index 54a638a..5e51470 100644 --- a/app/customer/hdl/hdl_central_kitchen_for_school_order.go +++ b/app/customer/hdl/hdl_central_kitchen_for_school_order.go @@ -28,9 +28,15 @@ func CentralKitchenForSchoolOrderList(c *gin.Context) { e.OutErr(c, e.ERR, err.Error()) return } + sumTotal, err := svc.OrderStatistic(req) + if err != nil { + e.OutErr(c, e.ERR, err.Error()) + return + } e.OutSuc(c, map[string]interface{}{ - "list": list, - "total": total, + "list": list, + "sum_total": sumTotal, + "total": total, "ord_state_list": []map[string]interface{}{ { "name": enum.CentralKitchenForSchoolPackageOrdOrdState.String(enum.CentralKitchenForSchoolPackageOrdOrdStateForWait), diff --git a/app/customer/md/md_order.go b/app/customer/md/md_order.go index 7506f35..cd110fa 100644 --- a/app/customer/md/md_order.go +++ b/app/customer/md/md_order.go @@ -1,10 +1,12 @@ package md type CentralKitchenForSchoolOrderListReq struct { - UserIdentityId int `json:"user_identity_id" label:"用户身份id"` - Limit int `json:"limit"` - Page int `json:"page" ` - OrdState int `json:"ord_state" ` + UserIdentityId int `json:"user_identity_id" label:"用户身份id"` + Limit int `json:"limit"` + Page int `json:"page" ` + OrdState int `json:"ord_state" ` + StartDate string `json:"start_date" ` + EndDate string `json:"end_date" ` } type CentralKitchenForSchoolOrderRefundReq struct { @@ -23,7 +25,8 @@ type CentralKitchenForSchoolOrderRefundListResp struct { OutTradeNo string `json:"out_trade_no" label:"订单号"` OutRequestNo string `json:"out_request_no" label:"退款请求号"` Kind int `json:"kind" label:"预定类型"` - CreateAt string `json:"create_at" label:"退款时间"` + CreateAt string `json:"create_at" label:"申请时间"` + RefundDate string `json:"refund_date" label:"退款时间"` Date string `json:"date" label:"预定时间"` State int `json:"state" label:"退款状态"` Memo string `json:"memo" label:"备注"` diff --git a/app/customer/svc/order/svc_central_kitchen_for_school_order.go b/app/customer/svc/order/svc_central_kitchen_for_school_order.go index c8c4b63..5b9de38 100644 --- a/app/customer/svc/order/svc_central_kitchen_for_school_order.go +++ b/app/customer/svc/order/svc_central_kitchen_for_school_order.go @@ -8,11 +8,13 @@ import ( "applet/app/enum" "applet/app/utils" "errors" + "fmt" "time" ) func OrderList(req md.CentralKitchenForSchoolOrderListReq) (m []model.CentralKitchenForSchoolPackageOrd, total int64, err error) { - sess := db.Db.Desc("id").Where("user_identity_id =?", req.UserIdentityId).Limit(req.Limit, (req.Page-1)*req.Limit) + sess := db.Db.Desc("id").Where("user_identity_id =?", req.UserIdentityId). + And("create_at >= ? And create_at <= ?", req.StartDate, req.EndDate).Limit(req.Limit, (req.Page-1)*req.Limit) sess.And("ord_state = ?", req.OrdState) total, err = sess.FindAndCount(&m) if err != nil { @@ -21,6 +23,21 @@ func OrderList(req md.CentralKitchenForSchoolOrderListReq) (m []model.CentralKit return } +func OrderStatistic(req md.CentralKitchenForSchoolOrderListReq) (total float64, err error) { + var sql = fmt.Sprintf("SELECT SUM(total_price) AS sum_total FROM central_kitchen_for_school_package_ord where "+ + "user_identity_id = '%d' and create_at >= '%s' And create_at <= '%s' and ord_state = '%d'", req.UserIdentityId, req.StartDate, req.EndDate, req.OrdState) + mapArr1, err := db.QueryNativeString(db.Db, sql) + if err != nil { + return + } + if mapArr1 == nil { + total = 0 + } else { + total = utils.StrToFloat64(mapArr1[0]["sum_total"]) + } + return +} + func CentralKitchenForSchoolOrderRefund(req md.CentralKitchenForSchoolOrderRefundReq) (err error) { sysCfgDb := db.SysCfgDb{} sysCfgDb.Set() @@ -110,6 +127,7 @@ func CentralKitchenForSchoolOrderRefundList(req md.CentralKitchenForSchoolOrderR OutRequestNo: v.CentralKitchenForSchoolUserRefundDay.OutRequestNo, Kind: v.CentralKitchenForSchoolUserWithDay.Kind, CreateAt: v.CentralKitchenForSchoolUserRefundDay.CreateAt, + RefundDate: v.CentralKitchenForSchoolUserRefundDay.RefundDate, Date: v.CentralKitchenForSchoolUserWithDay.Date, State: v.CentralKitchenForSchoolUserRefundDay.State, Memo: v.CentralKitchenForSchoolUserRefundDay.Memo, diff --git a/app/db/db_central_kitchen_for_school_export_records.go b/app/db/db_central_kitchen_for_school_export_records.go index 689baab..1b2d949 100644 --- a/app/db/db_central_kitchen_for_school_export_records.go +++ b/app/db/db_central_kitchen_for_school_export_records.go @@ -89,8 +89,17 @@ func (centralKitchenForSchoolExportRecordsDb *CentralKitchenForSchoolExportRecor } 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) + sess := centralKitchenForSchoolExportRecordsDb.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 } diff --git a/app/router/admin_router.go b/app/router/admin_router.go index bf1f8df..52442fe 100644 --- a/app/router/admin_router.go +++ b/app/router/admin_router.go @@ -88,8 +88,9 @@ func rFinanceManage(r *gin.RouterGroup) { } func rDataStatistics(r *gin.RouterGroup) { - r.POST("/centralKitchenForSchool/export", hdl2.CentralKitchenForSchoolDataStatisticsExport) //数据统计-(央厨-学校)-导出 - r.POST("/centralKitchenForSchool/list", hdl2.CentralKitchenForSchoolDataStatisticsList) //数据统计-(央厨-学校)-列表 + r.POST("/centralKitchenForSchool/export", hdl2.CentralKitchenForSchoolDataStatisticsExport) //数据统计-(央厨-学校)-导出 + r.POST("/centralKitchenForSchool/list", hdl2.CentralKitchenForSchoolDataStatisticsList) //数据统计-(央厨-学校)-列表 + r.DELETE("/centralKitchenForSchool/delete/:id", hdl2.CentralKitchenForSchoolDataStatisticsDelete) //数据统计-(央厨-学校)-列表 }