智慧食堂
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

hdl_nursing_home_package.go 1.8 KiB

1年前
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package hdl
  2. import (
  3. "applet/app/customer/md"
  4. "applet/app/db"
  5. "applet/app/db/model"
  6. "applet/app/e"
  7. "applet/app/utils"
  8. "github.com/gin-gonic/gin"
  9. "time"
  10. )
  11. func NursingHomePackage(c *gin.Context) {
  12. enterpriseId := utils.StrToInt(c.DefaultQuery("enterprise_id", ""))
  13. //1、查询出当前合适的package
  14. var m []model.NursingHomePackage
  15. now := time.Now().Format("2006-01-02 15:04:05")
  16. err := db.Db.Where("enterprise_id =?", enterpriseId).Where("end_date > ?", now).And("is_delete = 0").And("state = 1").Desc("end_date").Find(&m)
  17. if err != nil {
  18. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  19. return
  20. }
  21. //2、循环拼接数据
  22. var resp []md.FindNursingHomePackageReq
  23. for _, v := range m {
  24. NursingHomePackageWithDayDb := db.NursingHomePackageWithDayDb{}
  25. NursingHomePackageWithDayDb.Set(v.Id)
  26. NursingHomePackageWithDay, err1 := NursingHomePackageWithDayDb.FindNursingHomePackageWithDay()
  27. if err1 != nil {
  28. e.OutErr(c, e.ERR_DB_ORM, err1.Error())
  29. return
  30. }
  31. var tempResp = md.FindNursingHomePackageReq{
  32. PackageId: v.Id,
  33. EnterpriseId: v.EnterpriseId,
  34. Year: v.Year,
  35. Month: v.Month,
  36. StartDate: v.StartDate,
  37. EndDate: v.EndDate,
  38. DateList: nil,
  39. }
  40. for _, v1 := range *NursingHomePackageWithDay {
  41. tempResp.DateList = append(tempResp.DateList, struct {
  42. Date string `json:"date"`
  43. IsOpenBreakfast int32 `json:"is_open_breakfast"`
  44. IsOpenLunch int32 `json:"is_open_lunch"`
  45. IsOpenDinner int32 `json:"is_open_dinner"`
  46. IsOpenReplenish int32 `json:"is_open_replenish"`
  47. }{Date: v1.Date, IsOpenBreakfast: int32(v1.IsOpenBreakfast), IsOpenLunch: int32(v1.IsOpenLunch), IsOpenDinner: int32(v1.IsOpenDinner), IsOpenReplenish: int32(v1.IsOpenReplenish)})
  48. }
  49. resp = append(resp, tempResp)
  50. }
  51. e.OutSuc(c, map[string]interface{}{
  52. "list": resp,
  53. }, nil)
  54. return
  55. }