@@ -5,6 +5,7 @@ import ( | |||||
"applet/app/admin/md" | "applet/app/admin/md" | ||||
"applet/app/db" | "applet/app/db" | ||||
"applet/app/e" | "applet/app/e" | ||||
"applet/app/utils" | |||||
"github.com/gin-gonic/gin" | "github.com/gin-gonic/gin" | ||||
) | ) | ||||
@@ -72,6 +73,28 @@ func CentralKitchenForSchoolDataStatisticsList(c *gin.Context) { | |||||
return | 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) { | func CentralKitchenForSchoolDataStatisticsExport(c *gin.Context) { | ||||
var req md.CentralKitchenForSchoolDataStatisticsExportReq | var req md.CentralKitchenForSchoolDataStatisticsExportReq | ||||
err := c.ShouldBindJSON(&req) | err := c.ShouldBindJSON(&req) | ||||
@@ -1,8 +1,11 @@ | |||||
package md | package md | ||||
type CentralKitchenForSchoolExportRecordsListReq struct { | 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 { | type CentralKitchenForSchoolDataStatisticsExportReq struct { | ||||
@@ -28,9 +28,15 @@ func CentralKitchenForSchoolOrderList(c *gin.Context) { | |||||
e.OutErr(c, e.ERR, err.Error()) | e.OutErr(c, e.ERR, err.Error()) | ||||
return | return | ||||
} | } | ||||
sumTotal, err := svc.OrderStatistic(req) | |||||
if err != nil { | |||||
e.OutErr(c, e.ERR, err.Error()) | |||||
return | |||||
} | |||||
e.OutSuc(c, map[string]interface{}{ | e.OutSuc(c, map[string]interface{}{ | ||||
"list": list, | |||||
"total": total, | |||||
"list": list, | |||||
"sum_total": sumTotal, | |||||
"total": total, | |||||
"ord_state_list": []map[string]interface{}{ | "ord_state_list": []map[string]interface{}{ | ||||
{ | { | ||||
"name": enum.CentralKitchenForSchoolPackageOrdOrdState.String(enum.CentralKitchenForSchoolPackageOrdOrdStateForWait), | "name": enum.CentralKitchenForSchoolPackageOrdOrdState.String(enum.CentralKitchenForSchoolPackageOrdOrdStateForWait), | ||||
@@ -1,10 +1,12 @@ | |||||
package md | package md | ||||
type CentralKitchenForSchoolOrderListReq struct { | 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 { | type CentralKitchenForSchoolOrderRefundReq struct { | ||||
@@ -23,7 +25,8 @@ type CentralKitchenForSchoolOrderRefundListResp struct { | |||||
OutTradeNo string `json:"out_trade_no" label:"订单号"` | OutTradeNo string `json:"out_trade_no" label:"订单号"` | ||||
OutRequestNo string `json:"out_request_no" label:"退款请求号"` | OutRequestNo string `json:"out_request_no" label:"退款请求号"` | ||||
Kind int `json:"kind" 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:"预定时间"` | Date string `json:"date" label:"预定时间"` | ||||
State int `json:"state" label:"退款状态"` | State int `json:"state" label:"退款状态"` | ||||
Memo string `json:"memo" label:"备注"` | Memo string `json:"memo" label:"备注"` | ||||
@@ -8,11 +8,13 @@ import ( | |||||
"applet/app/enum" | "applet/app/enum" | ||||
"applet/app/utils" | "applet/app/utils" | ||||
"errors" | "errors" | ||||
"fmt" | |||||
"time" | "time" | ||||
) | ) | ||||
func OrderList(req md.CentralKitchenForSchoolOrderListReq) (m []model.CentralKitchenForSchoolPackageOrd, total int64, err error) { | 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) | sess.And("ord_state = ?", req.OrdState) | ||||
total, err = sess.FindAndCount(&m) | total, err = sess.FindAndCount(&m) | ||||
if err != nil { | if err != nil { | ||||
@@ -21,6 +23,21 @@ func OrderList(req md.CentralKitchenForSchoolOrderListReq) (m []model.CentralKit | |||||
return | 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) { | func CentralKitchenForSchoolOrderRefund(req md.CentralKitchenForSchoolOrderRefundReq) (err error) { | ||||
sysCfgDb := db.SysCfgDb{} | sysCfgDb := db.SysCfgDb{} | ||||
sysCfgDb.Set() | sysCfgDb.Set() | ||||
@@ -110,6 +127,7 @@ func CentralKitchenForSchoolOrderRefundList(req md.CentralKitchenForSchoolOrderR | |||||
OutRequestNo: v.CentralKitchenForSchoolUserRefundDay.OutRequestNo, | OutRequestNo: v.CentralKitchenForSchoolUserRefundDay.OutRequestNo, | ||||
Kind: v.CentralKitchenForSchoolUserWithDay.Kind, | Kind: v.CentralKitchenForSchoolUserWithDay.Kind, | ||||
CreateAt: v.CentralKitchenForSchoolUserRefundDay.CreateAt, | CreateAt: v.CentralKitchenForSchoolUserRefundDay.CreateAt, | ||||
RefundDate: v.CentralKitchenForSchoolUserRefundDay.RefundDate, | |||||
Date: v.CentralKitchenForSchoolUserWithDay.Date, | Date: v.CentralKitchenForSchoolUserWithDay.Date, | ||||
State: v.CentralKitchenForSchoolUserRefundDay.State, | State: v.CentralKitchenForSchoolUserRefundDay.State, | ||||
Memo: v.CentralKitchenForSchoolUserRefundDay.Memo, | Memo: v.CentralKitchenForSchoolUserRefundDay.Memo, | ||||
@@ -89,8 +89,17 @@ func (centralKitchenForSchoolExportRecordsDb *CentralKitchenForSchoolExportRecor | |||||
} | } | ||||
func (centralKitchenForSchoolExportRecordsDb *CentralKitchenForSchoolExportRecordsDb) CentralKitchenForSchoolExportRecordsList(req md.CentralKitchenForSchoolExportRecordsListReq) (m []model.CentralKitchenForSchoolExportRecords, total int64, err error) { | 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 { | if err != nil { | ||||
return | return | ||||
} | } | ||||
@@ -88,8 +88,9 @@ func rFinanceManage(r *gin.RouterGroup) { | |||||
} | } | ||||
func rDataStatistics(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) //数据统计-(央厨-学校)-列表 | |||||
} | } | ||||