package controllers import ( "XT_New/enums" "XT_New/service" "github.com/astaxie/beego" "time" ) type HisChargeApiController struct { BaseAuthAPIController } func HisChargeApiRegistRouters() { beego.Router("/api/his/chargestatistics/detail", &HisChargeApiController{}, "get:GetChargeStatisticsDetail") beego.Router("/api/his/chargestatistics/settle", &HisChargeApiController{}, "get:GetChargeStatisticsSettle") } func (c *HisChargeApiController) GetChargeStatisticsDetail() { start_time := c.GetString("start_time") end_time := c.GetString("end_time") keyword := c.GetString("keyword") item_type, _ := c.GetInt64("type") adminUser := c.GetAdminUserInfo() timeLayout := "2006-01-02" loc, _ := time.LoadLocation("Local") startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc) if err != nil { } startRecordDateTime := startTime.Unix() endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc) if err != nil { } endRecordDateTime := endTime.Unix() chargePatient, err := service.GetAllPatientChargeDetails(adminUser.CurrentOrgId, startRecordDateTime, endRecordDateTime, keyword, item_type) if err == nil { c.ServeSuccessJSON(map[string]interface{}{ "patients": chargePatient, }) return } else { c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError) return } } func (c *HisChargeApiController) GetChargeStatisticsSettle() { start_time := c.GetString("start_time") end_time := c.GetString("end_time") keyword := c.GetString("keyword") item_type, _ := c.GetInt64("type") adminUser := c.GetAdminUserInfo() timeLayout := "2006-01-02" loc, _ := time.LoadLocation("Local") startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc) if err != nil { } startRecordDateTime := startTime.Unix() endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc) if err != nil { } endRecordDateTime := endTime.Unix() chargePatient, err := service.GetAllPatientChargeSettle(adminUser.CurrentOrgId, startRecordDateTime, endRecordDateTime, keyword, item_type) if err == nil { c.ServeSuccessJSON(map[string]interface{}{ "patients": chargePatient, }) return } else { c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError) return } }