|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742 |
- package hdl
-
- import (
- "applet/app/admin/lib/validate"
- "applet/app/admin/md"
- "applet/app/admin/svc"
- svc2 "applet/app/admin/svc/enterprise_manage"
- "applet/app/db"
- "applet/app/db/model"
- "applet/app/e"
- "applet/app/enum"
- "applet/app/utils"
- "github.com/gin-gonic/gin"
- "time"
- )
-
- func NursingHomeUserUpdate(c *gin.Context) {
- var req md.NursingHomeUserUpdateReq
- err := c.ShouldBindJSON(&req)
- if err != nil {
- err = validate.HandleValidateErr(err)
- err1 := err.(e.E)
- e.OutErr(c, err1.Code, err1.Error())
- return
- }
- enterpriseDb := db.EnterpriseDb{}
- enterpriseDb.Set()
- enterprise, err := enterpriseDb.GetEnterprise(req.EnterpriseId)
- if err != nil {
- e.OutErr(c, e.ERR_DB_ORM, err.Error())
- return
- }
- if enterprise == nil {
- e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录")
- return
- }
-
- err = svc2.NursingHomeUserUpdate(req)
- if err != nil {
- e.OutErr(c, e.ERR, err.Error())
- return
- }
- e.OutSuc(c, "success", nil)
- return
- }
-
- func NursingHomeUserDelete(c *gin.Context) {
- var req md.NursingHomeUserDeleteReq
- err := c.ShouldBindJSON(&req)
- if err != nil {
- err = validate.HandleValidateErr(err)
- err1 := err.(e.E)
- e.OutErr(c, err1.Code, err1.Error())
- return
- }
- enterpriseDb := db.EnterpriseDb{}
- enterpriseDb.Set()
- enterprise, err := enterpriseDb.GetEnterprise(req.EnterpriseId)
- if err != nil {
- e.OutErr(c, e.ERR_DB_ORM, err.Error())
- return
- }
- if enterprise == nil {
- e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录")
- return
- }
-
- err = svc2.NursingHomeUserDelete(req)
- if err != nil {
- e.OutErr(c, e.ERR, err.Error())
- return
- }
- e.OutSuc(c, "success", nil)
- return
- }
-
- func GetNursingHomeWithSpec(c *gin.Context) {
- enterpriseId := utils.StrToInt(c.DefaultQuery("enterprise_id", "0"))
- nursingHomeWithSpec := db.NursingHomeWithSpec{}
- nursingHomeWithSpec.Set(enterpriseId)
- data, err := nursingHomeWithSpec.GetNursingHomeWithSpec()
- if err != nil {
- e.OutErr(c, e.ERR_DB_ORM, err.Error())
- return
- }
-
- e.OutSuc(c, map[string]interface{}{
- "data": data,
- }, nil)
- return
- }
-
- func SetNursingHomeWithSpec(c *gin.Context) {
- var req md.SetNursingHomeWithSpecReq
- err := c.ShouldBindJSON(&req)
- if err != nil {
- err = validate.HandleValidateErr(err)
- err1 := err.(e.E)
- e.OutErr(c, err1.Code, err1.Error())
- return
- }
- nursingHomeWithSpec := db.NursingHomeWithSpec{}
- nursingHomeWithSpec.Set(req.EnterpriseId)
-
- spec, err := nursingHomeWithSpec.GetNursingHomeWithSpec()
- if err != nil {
- e.OutErr(c, e.ERR_DB_ORM, err.Error())
- return
- }
-
- _, err = nursingHomeWithSpec.NursingHomeWithSpecDelete()
- if err != nil {
- e.OutErr(c, e.ERR_DB_ORM, err.Error())
- return
- }
-
- now := time.Now()
- if spec != nil {
- insertConfirm, err1 := nursingHomeWithSpec.NursingHomeWithSpecInsert(&model.NursingHomeWithSpec{
- IsOpenBreakfast: spec.IsOpenBreakfast,
- IsOpenLunch: spec.IsOpenLunch,
- IsOpenDinner: spec.IsOpenDinner,
- EnterpriseId: req.EnterpriseId,
- BreakfastUnitPrice: req.BreakfastUnitPrice,
- LunchUnitPrice: req.LunchUnitPrice,
- DinnerUnitPrice: req.DinnerUnitPrice,
- CreateAt: now.Format("2006-01-02 15:04:05"),
- UpdateAt: now.Format("2006-01-02 15:04:05"),
- })
- if err1 != nil {
- e.OutErr(c, e.ERR_DB_ORM, err1.Error())
- return
- }
- if insertConfirm <= 0 {
- e.OutErr(c, e.ERR_DB_ORM, "新增数据失败")
- return
- }
- } else {
- insertConfirm, err1 := nursingHomeWithSpec.NursingHomeWithSpecInsert(&model.NursingHomeWithSpec{
- EnterpriseId: req.EnterpriseId,
- BreakfastUnitPrice: req.BreakfastUnitPrice,
- LunchUnitPrice: req.LunchUnitPrice,
- DinnerUnitPrice: req.DinnerUnitPrice,
- CreateAt: now.Format("2006-01-02 15:04:05"),
- UpdateAt: now.Format("2006-01-02 15:04:05"),
- })
- if err1 != nil {
- e.OutErr(c, e.ERR_DB_ORM, err1.Error())
- return
- }
- if insertConfirm <= 0 {
- e.OutErr(c, e.ERR_DB_ORM, "新增数据失败")
- return
- }
- }
-
- e.OutSuc(c, "success", nil)
- return
- }
-
- func ListNursingHomePackage(c *gin.Context) {
- var req md.ListNursingHomePackageReq
- err := c.ShouldBindJSON(&req)
- if err != nil {
- err = validate.HandleValidateErr(err)
- err1 := err.(e.E)
- e.OutErr(c, err1.Code, err1.Error())
- return
- }
- nursingHomePackageDb := db.NursingHomePackageDb{}
- nursingHomePackageDb.Set()
- list, total, err := nursingHomePackageDb.NursingHomePackageList(req)
- if err != nil {
- e.OutErr(c, e.ERR_DB_ORM, err.Error())
- return
- }
- e.OutSuc(c, map[string]interface{}{
- "list": list,
- "total": total,
- "state_list": []map[string]interface{}{
- {
- "name": "可用",
- "value": 1,
- },
- {
- "name": "不可用",
- "value": 2,
- },
- },
- }, nil)
- return
- }
-
- func DetailNursingHomePackage(c *gin.Context) {
- packageId := utils.StrToInt(c.DefaultQuery("package_id", ""))
- nursingHomePackageDb := db.NursingHomePackageDb{}
- nursingHomePackageDb.Set()
- NursingHomePackage, err := nursingHomePackageDb.GetNursingHomePackage(packageId)
- if err != nil {
- e.OutErr(c, e.ERR_DB_ORM, err.Error())
- return
- }
- if NursingHomePackage == nil {
- e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录")
- return
- }
-
- nursingHomePackageWithDayDb := db.NursingHomePackageWithDayDb{}
- nursingHomePackageWithDayDb.Set(packageId)
- nursingHomePackageWithDay, err := nursingHomePackageWithDayDb.FindNursingHomePackageWithDay()
- if err != nil {
- e.OutErr(c, e.ERR_DB_ORM, err.Error())
- return
- }
-
- var resp = md.SaveNursingHomePackageReq{
- PackageId: NursingHomePackage.Id,
- EnterpriseId: NursingHomePackage.EnterpriseId,
- Year: NursingHomePackage.Year,
- Month: NursingHomePackage.Month,
- StartDate: NursingHomePackage.StartDate,
- EndDate: NursingHomePackage.EndDate,
- DateList: nil,
- }
- for _, v := range *nursingHomePackageWithDay {
- resp.DateList = append(resp.DateList, struct {
- Date string `json:"date"`
- IsOpenBreakfast int32 `json:"is_open_breakfast"`
- IsOpenLunch int32 `json:"is_open_lunch"`
- IsOpenDinner int32 `json:"is_open_dinner"`
- IsOpenReplenish int32 `json:"is_open_replenish"`
- }{Date: v.Date, IsOpenBreakfast: int32(v.IsOpenBreakfast), IsOpenLunch: int32(v.IsOpenLunch), IsOpenDinner: int32(v.IsOpenDinner), IsOpenReplenish: int32(v.IsOpenReplenish)})
- }
- e.OutSuc(c, resp, nil)
- return
- }
-
- func SaveNursingHomePackage(c *gin.Context) {
- var req md.SaveNursingHomePackageReq
- 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.PackageId > 0 {
- err = svc.UpdateNursingHomePackage(req)
- if err != nil {
- e.OutErr(c, e.ERR, err.Error())
- return
- }
- } else {
- err = svc.AddNursingHomePackage(req)
- if err != nil {
- e.OutErr(c, e.ERR, err.Error())
- return
- }
- }
- e.OutSuc(c, "success", nil)
- return
- }
-
- func SetBasicNursingHome(c *gin.Context) {
- var req md.SetBasicNursingHomeReq
- err := c.ShouldBindJSON(&req)
- if err != nil {
- err = validate.HandleValidateErr(err)
- err1 := err.(e.E)
- e.OutErr(c, err1.Code, err1.Error())
- return
- }
- now := time.Now()
-
- //1、更新 nursing_home_set
- nursingHomeSetDb := db.NursingHomeSetDb{}
- nursingHomeSetDb.Set(req.EnterpriseId)
- set, err := nursingHomeSetDb.GetNursingHomeSet()
- if err != nil {
- e.OutErr(c, e.ERR_DB_ORM, err.Error())
- return
- }
- if set != nil {
- set.IsOpenReportMealForYear = req.IsOpenReportMealForYear
- set.IsOpenReportMealForDay = req.IsOpenReportMealForDay
- set.IsOpenReportMealForMonth = req.IsOpenReportMealForMonth
- set.UpdateAt = now.Format("2006-01-02 15:04:05")
- _, err2 := nursingHomeSetDb.NursingHomeSetUpdate(set.Id, set, "is_open_report_meal_for_day", "is_open_report_meal_for_month", "is_open_report_meal_for_year", "update_at")
- if err2 != nil {
- e.OutErr(c, e.ERR_DB_ORM, err2.Error())
- return
- }
- } else {
- _, err2 := nursingHomeSetDb.NursingHomeSetInsert(&model.NursingHomeSet{
- EnterpriseId: req.EnterpriseId,
- IsOpenReportMealForYear: req.IsOpenReportMealForYear,
- IsOpenReportMealForDay: req.IsOpenReportMealForDay,
- IsOpenReportMealForMonth: req.IsOpenReportMealForMonth,
- CreateAt: now.Format("2006-01-02 15:04:05"),
- UpdateAt: now.Format("2006-01-02 15:04:05"),
- })
- if err2 != nil {
- e.OutErr(c, e.ERR_DB_ORM, err2.Error())
- return
- }
- }
-
- //2、更新 nursing_home_with_spec
- nursingHomeWithSpec := db.NursingHomeWithSpec{}
- nursingHomeWithSpec.Set(req.EnterpriseId)
- spec, err := nursingHomeWithSpec.GetNursingHomeWithSpec()
- if err != nil {
- e.OutErr(c, e.ERR_DB_ORM, err.Error())
- return
- }
- if spec != nil {
- spec.IsOpenBreakfast = req.IsOpenBreakfast
- spec.IsOpenLunch = req.IsOpenLunch
- spec.IsOpenDinner = req.IsOpenDinner
- spec.UpdateAt = now.Format("2006-01-02 15:04:05")
- _, err2 := nursingHomeWithSpec.NursingHomeWithSpecUpdate(spec.Id, spec, "is_open_breakfast", "is_open_lunch", "is_open_dinner", "update_at")
- if err2 != nil {
- e.OutErr(c, e.ERR_DB_ORM, err2.Error())
- return
- }
- } else {
- _, err2 := nursingHomeWithSpec.NursingHomeWithSpecInsert(&model.NursingHomeWithSpec{
- EnterpriseId: req.EnterpriseId,
- IsOpenBreakfast: req.IsOpenBreakfast,
- IsOpenLunch: req.IsOpenLunch,
- IsOpenDinner: req.IsOpenDinner,
- CreateAt: now.Format("2006-01-02 15:04:05"),
- UpdateAt: now.Format("2006-01-02 15:04:05"),
- })
- if err2 != nil {
- e.OutErr(c, e.ERR_DB_ORM, err2.Error())
- return
- }
- }
-
- //3、更新 `enterprise`
- enterpriseDb := db.EnterpriseDb{}
- enterpriseDb.Set()
- enterprise, err := enterpriseDb.GetEnterprise(req.EnterpriseId)
- if err != nil {
- e.OutErr(c, e.ERR_DB_ORM, err.Error())
- return
- }
- if enterprise == nil {
- e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录")
- return
- }
- enterprise.Name = req.Name
- enterprise.State = req.State
- enterprise.UpdateAt = now.Format("2006-01-02 15:04:05")
- _, err = enterpriseDb.EnterpriseUpdate(enterprise, "name", "state", "update_at")
- if err != nil {
- e.OutErr(c, e.ERR_DB_ORM, err.Error())
- return
- }
-
- e.OutSuc(c, "success", nil)
- return
- }
-
- func GetBasicNursingHome(c *gin.Context) {
- enterpriseId := utils.StrToInt(c.DefaultQuery("enterprise_id", "0"))
-
- //1、获取 nursing_home_set
- nursingHomeSetDb := db.NursingHomeSetDb{}
- nursingHomeSetDb.Set(enterpriseId)
- set, err := nursingHomeSetDb.GetNursingHomeSet()
- if err != nil {
- e.OutErr(c, e.ERR_DB_ORM, err.Error())
- return
- }
- if set == nil {
- set = &model.NursingHomeSet{
- EnterpriseId: enterpriseId,
- IsOpenReportMealForDay: 0,
- IsOpenReportMealForMonth: 0,
- IsOpenReportMealForYear: 0,
- CreateAt: time.Now().Format("2006-01-02 15:04:05"),
- UpdateAt: time.Now().Format("2006-01-02 15:04:05"),
- }
- _, err2 := nursingHomeSetDb.NursingHomeSetInsert(set)
- if err2 != nil {
- e.OutErr(c, e.ERR_DB_ORM, err2.Error())
- return
- }
- }
-
- //2、获取 nursing_home_with_spec
- nursingHomeWithSpec := db.NursingHomeWithSpec{}
- nursingHomeWithSpec.Set(enterpriseId)
- spec, err := nursingHomeWithSpec.GetNursingHomeWithSpec()
- if err != nil {
- e.OutErr(c, e.ERR_DB_ORM, err.Error())
- return
- }
- if spec == nil {
- spec = &model.NursingHomeWithSpec{
- EnterpriseId: enterpriseId,
- IsOpenBreakfast: 0,
- IsOpenLunch: 0,
- IsOpenDinner: 0,
- BreakfastUnitPrice: "0",
- LunchUnitPrice: "0",
- DinnerUnitPrice: "0",
- CreateAt: time.Now().Format("2006-01-02 15:04:05"),
- UpdateAt: time.Now().Format("2006-01-02 15:04:05"),
- }
- _, err2 := nursingHomeWithSpec.NursingHomeWithSpecInsert(spec)
- if err2 != nil {
- e.OutErr(c, e.ERR_DB_ORM, err2.Error())
- return
- }
- }
-
- //3、更新 `enterprise`
- enterpriseDb := db.EnterpriseDb{}
- enterpriseDb.Set()
- enterprise, err := enterpriseDb.GetEnterprise(enterpriseId)
- if err != nil {
- e.OutErr(c, e.ERR_DB_ORM, err.Error())
- return
- }
- if enterprise == nil {
- e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录")
- return
- }
-
- e.OutSuc(c, map[string]interface{}{
- "central_kitchen_for_school_set": set,
- "central_kitchen_for_school_with_spec": spec,
- "enterprise": enterprise,
- }, nil)
- return
- }
-
- func NursingHomeOrdList(c *gin.Context) {
- var req md.NursingHomeOrdListReq
- err := c.ShouldBindJSON(&req)
- if err != nil {
- err = validate.HandleValidateErr(err)
- err1 := err.(e.E)
- e.OutErr(c, err1.Code, err1.Error())
- return
- }
-
- resp, total, err := svc2.NursingHomeOrdList(req)
- if err != nil {
- e.OutErr(c, e.ERR, err.Error())
- return
- }
- e.OutSuc(c, map[string]interface{}{
- "list": resp,
- "total": total,
- "kind_list": []map[string]string{
- {
- "name": "按年购买",
- "value": "1",
- },
- {
- "name": "按月购买",
- "value": "2",
- },
- {
- "name": "按天购买",
- "value": "3",
- },
- {
- "name": "补餐",
- "value": "4",
- },
- },
- "state_list": []map[string]interface{}{
- {
- "name": enum.NursingHomePackageOrdState.String(enum.NursingHomePackageOrdStateForWait),
- "value": enum.NursingHomePackageOrdStateForWait,
- },
- {
- "name": enum.NursingHomePackageOrdState.String(enum.NursingHomePackageOrdStateForSuccess),
- "value": enum.NursingHomePackageOrdStateForSuccess,
- },
- {
- "name": enum.NursingHomePackageOrdState.String(enum.NursingHomePackageOrdStateForFail),
- "value": enum.NursingHomePackageOrdStateForFail,
- },
- },
- "ord_state_list": []map[string]interface{}{
- {
- "name": enum.NursingHomePackageOrdOrdState.String(enum.NursingHomePackageOrdOrdStateForWait),
- "value": enum.NursingHomePackageOrdOrdStateForWait,
- },
- {
- "name": enum.NursingHomePackageOrdOrdState.String(enum.NursingHomePackageOrdOrdStateForSuccess),
- "value": enum.NursingHomePackageOrdOrdStateForSuccess,
- },
- {
- "name": enum.NursingHomePackageOrdOrdState.String(enum.NursingHomePackageOrdOrdStateForRefunding),
- "value": enum.NursingHomePackageOrdOrdStateForRefunding,
- },
- {
- "name": enum.NursingHomePackageOrdOrdState.String(enum.NursingHomePackageOrdOrdStateForPartRefunded),
- "value": enum.NursingHomePackageOrdOrdStateForPartRefunded,
- },
- {
- "name": enum.NursingHomePackageOrdOrdState.String(enum.NursingHomePackageOrdOrdStateForRefunded),
- "value": enum.NursingHomePackageOrdOrdStateForRefunded,
- },
- {
- "name": enum.NursingHomePackageOrdOrdState.String(enum.NursingHomePackageOrdOrdStateForComplete),
- "value": enum.NursingHomePackageOrdOrdStateForComplete,
- },
- },
- "user_identity_kind_list": []map[string]interface{}{
- {
- "name": enum.UserIdentity.String(enum.UserIdentityForCentralKitchenForStudent),
- "value": enum.UserIdentityForCentralKitchenForStudent,
- },
- {
- "name": enum.UserIdentity.String(enum.UserIdentityForCentralKitchenForTeacher),
- "value": enum.UserIdentityForCentralKitchenForTeacher,
- },
- {
- "name": enum.UserIdentity.String(enum.UserIdentityForCentralKitchenForWorker),
- "value": enum.UserIdentityForCentralKitchenForWorker,
- },
- {
- "name": enum.UserIdentity.String(enum.UserIdentityForSelfSupportForStudent),
- "value": enum.UserIdentityForSelfSupportForStudent,
- },
- {
- "name": enum.UserIdentity.String(enum.UserIdentityForSelfSupportForTeacher),
- "value": enum.UserIdentityForSelfSupportForTeacher,
- },
- {
- "name": enum.UserIdentity.String(enum.UserIdentityForSelfSupportForWorker),
- "value": enum.UserIdentityForSelfSupportForWorker,
- },
- },
- }, nil)
- return
- }
-
- func NursingHomeReserveList(c *gin.Context) {
- var req md.NursingHomeReserveListReq
- err := c.ShouldBindJSON(&req)
- if err != nil {
- err = validate.HandleValidateErr(err)
- err1 := err.(e.E)
- e.OutErr(c, err1.Code, err1.Error())
- return
- }
-
- resp, total, err := svc2.NursingHomeReserveList(req)
- if err != nil {
- e.OutErr(c, e.ERR, err.Error())
- return
- }
- e.OutSuc(c, map[string]interface{}{
- "list": resp,
- "total": total,
- "kind_list": []map[string]interface{}{
- {
- "name": enum.NursingHomeUserWithDayKind.String(enum.NursingHomeUserWithDayKindForBreakfast),
- "value": enum.NursingHomeUserWithDayKindForBreakfast,
- },
- {
- "name": enum.NursingHomeUserWithDayKind.String(enum.NursingHomeUserWithDayKindForLunch),
- "value": enum.NursingHomeUserWithDayKindForLunch,
- },
- {
- "name": enum.NursingHomeUserWithDayKind.String(enum.NursingHomeUserWithDayKindForDinner),
- "value": enum.NursingHomeUserWithDayKindForDinner,
- },
- },
- }, nil)
- return
- }
-
- func NursingHomeReserveDetail(c *gin.Context) {
- id := c.DefaultQuery("id", "")
- NursingHomePackageOrdForReserveDb := db.NursingHomePackageOrdForReserve{}
- NursingHomePackageOrdForReserveDb.Set("")
- NursingHomePackageOrdForReserve, err := NursingHomePackageOrdForReserveDb.GetNursingHomePackageOrdForReserveById(utils.StrToInt(id))
- if err != nil {
- e.OutErr(c, e.ERR_DB_ORM, err.Error())
- return
- }
- if NursingHomePackageOrdForReserve == nil {
- e.OutErr(c, e.ERR_NO_DATA, "未查询到相应记录")
- return
- }
- var m []model.NursingHomeUserWithDay
- err = db.Db.Where("ord_no =?", NursingHomePackageOrdForReserve.OutTradeNo).
- And("date >=? and date <=?", NursingHomePackageOrdForReserve.MealTimeStart, NursingHomePackageOrdForReserve.MealTimeEnd).
- Find(&m)
- if err != nil {
- e.OutErr(c, e.ERR_DB_ORM, err.Error())
- return
- }
-
- e.OutSuc(c, map[string]interface{}{
- "list": m,
- "kind_list": []map[string]interface{}{
- {
- "name": enum.NursingHomeUserWithDayKind.String(enum.NursingHomeUserWithDayKindForBreakfast),
- "value": enum.NursingHomeUserWithDayKindForBreakfast,
- },
- {
- "name": enum.NursingHomeUserWithDayKind.String(enum.NursingHomeUserWithDayKindForLunch),
- "value": enum.NursingHomeUserWithDayKindForLunch,
- },
- {
- "name": enum.NursingHomeUserWithDayKind.String(enum.NursingHomeUserWithDayKindForDinner),
- "value": enum.NursingHomeUserWithDayKindForDinner,
- },
- },
- "state_list": []map[string]interface{}{
- {
- "name": enum.NursingHomeUserWithDayState.String(enum.NursingHomeUserWithDayStateForWait),
- "value": enum.NursingHomeUserWithDayStateForWait,
- },
- {
- "name": enum.NursingHomeUserWithDayState.String(enum.NursingHomeUserWithDayStateForAlready),
- "value": enum.NursingHomeUserWithDayStateForAlready,
- },
- {
- "name": enum.NursingHomeUserWithDayState.String(enum.NursingHomeUserWithDayStateForCanceling),
- "value": enum.NursingHomeUserWithDayStateForCanceling,
- },
- {
- "name": enum.NursingHomeUserWithDayState.String(enum.NursingHomeUserWithDayStateForCancel),
- "value": enum.NursingHomeUserWithDayStateForCancel,
- },
- },
- }, nil)
- return
- }
-
- func NursingHomeOrdRefund(c *gin.Context) {
- var req md.NursingHomeOrdRefundReq
- err := c.ShouldBindJSON(&req)
- if err != nil {
- err = validate.HandleValidateErr(err)
- err1 := err.(e.E)
- e.OutErr(c, err1.Code, err1.Error())
- return
- }
- enterpriseDb := db.EnterpriseDb{}
- enterpriseDb.Set()
- enterprise, err := enterpriseDb.GetEnterprise(req.EnterpriseId)
- if err != nil {
- e.OutErr(c, e.ERR_DB_ORM, err.Error())
- return
- }
- if enterprise == nil {
- e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录")
- return
- }
- err = svc2.NursingHomeOrdRefund(req)
- if err != nil {
- e.OutErr(c, e.ERR, err.Error())
- return
- }
- e.OutSuc(c, "success", nil)
- return
- }
-
- func NursingHomeOrdDetail(c *gin.Context) {
- outTradeNo := c.DefaultQuery("out_trade_no", "")
- nursingHomePackageOrd := db.NursingHomePackageOrd{}
- nursingHomePackageOrd.Set(outTradeNo)
- ord, err := nursingHomePackageOrd.GetNursingHomePackageOrd()
- if err != nil {
- e.OutErr(c, e.ERR_DB_ORM, err.Error())
- return
- }
- if ord == nil {
- e.OutErr(c, e.ERR_NO_DATA, "未查询到对应订单记录")
- return
- }
-
- nursingHomeUserWithDayDb := db.NursingHomeUserWithDayDb{}
- nursingHomeUserWithDayDb.Set(0)
- list, err := nursingHomeUserWithDayDb.FindNursingHomeUserWithDayByOrdNo(ord.OutTradeNo)
- if err != nil {
- e.OutErr(c, e.ERR_DB_ORM, err.Error())
- return
- }
-
- e.OutSuc(c, map[string]interface{}{
- "list": list,
- "kind_list": []map[string]interface{}{
- {
- "name": enum.NursingHomeUserWithDayKind.String(enum.NursingHomeUserWithDayKindForBreakfast),
- "value": enum.NursingHomeUserWithDayKindForBreakfast,
- },
- {
- "name": enum.NursingHomeUserWithDayKind.String(enum.NursingHomeUserWithDayKindForLunch),
- "value": enum.NursingHomeUserWithDayKindForLunch,
- },
- {
- "name": enum.NursingHomeUserWithDayKind.String(enum.NursingHomeUserWithDayKindForDinner),
- "value": enum.NursingHomeUserWithDayKindForDinner,
- },
- },
- "state_list": []map[string]interface{}{
- {
- "name": enum.NursingHomeUserWithDayState.String(enum.NursingHomeUserWithDayStateForWait),
- "value": enum.NursingHomeUserWithDayStateForWait,
- },
- {
- "name": enum.NursingHomeUserWithDayState.String(enum.NursingHomeUserWithDayStateForAlready),
- "value": enum.NursingHomeUserWithDayStateForAlready,
- },
- {
- "name": enum.NursingHomeUserWithDayState.String(enum.NursingHomeUserWithDayStateForCanceling),
- "value": enum.NursingHomeUserWithDayStateForCanceling,
- },
- {
- "name": enum.NursingHomeUserWithDayState.String(enum.NursingHomeUserWithDayStateForCancel),
- "value": enum.NursingHomeUserWithDayStateForCancel,
- },
- },
- }, nil)
- return
- }
-
- func DeleteNursingHomePackage(c *gin.Context) {
- packageId := c.Param("id")
- err := svc.DeleteNursingHomePackage(utils.StrToInt(packageId))
- if err != nil {
- e.OutErr(c, e.ERR, err.Error())
- return
- }
- e.OutSuc(c, "success", nil)
- return
- }
|