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

hdl_enterprise.go 4.0 KiB

1年前
1年前
1年前
1年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. package hdl
  2. import (
  3. "applet/app/customer/lib/validate"
  4. "applet/app/customer/md"
  5. "applet/app/customer/svc"
  6. "applet/app/db"
  7. "applet/app/e"
  8. "applet/app/enum"
  9. "applet/app/utils"
  10. "github.com/gin-gonic/gin"
  11. )
  12. func EnterpriseList(c *gin.Context) {
  13. var req md.EnterpriseListReq
  14. err := c.ShouldBindJSON(&req)
  15. if err != nil {
  16. err = validate.HandleValidateErr(err)
  17. err1 := err.(e.E)
  18. e.OutErr(c, err1.Code, err1.Error())
  19. return
  20. }
  21. if req.Limit == 0 {
  22. req.Limit = 10
  23. }
  24. if req.Page == 0 {
  25. req.Page = 10
  26. }
  27. enterprises, total, err := svc.EnterpriseList(req)
  28. if err != nil {
  29. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  30. return
  31. }
  32. e.OutSuc(c, map[string]interface{}{
  33. "list": enterprises,
  34. "total": total,
  35. "kind": []map[string]interface{}{
  36. {
  37. "name": enum.EnterpriseKind(enum.EnterpriseKindByCentralKitchenForSchool).String(),
  38. "value": enum.EnterpriseKindByCentralKitchenForSchool,
  39. },
  40. {
  41. "name": enum.EnterpriseKind(enum.EnterpriseKindByCentralKitchenForFactory).String(),
  42. "value": enum.EnterpriseKindByCentralKitchenForFactory,
  43. },
  44. {
  45. "name": enum.EnterpriseKind(enum.EnterpriseKindBySelfSupportForSchool).String(),
  46. "value": enum.EnterpriseKindBySelfSupportForSchool,
  47. },
  48. {
  49. "name": enum.EnterpriseKind(enum.EnterpriseKindBySelfSupportForFactory).String(),
  50. "value": enum.EnterpriseKindBySelfSupportForFactory,
  51. },
  52. },
  53. }, nil)
  54. return
  55. }
  56. func EnterpriseInfo(c *gin.Context) {
  57. enterpriseId := utils.StrToInt(c.DefaultQuery("enterprise_id", ""))
  58. enterpriseDb := db.EnterpriseDb{}
  59. enterpriseDb.Set()
  60. enterprise, err := enterpriseDb.GetEnterprise(enterpriseId)
  61. if err != nil {
  62. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  63. return
  64. }
  65. if enterprise == nil {
  66. e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录")
  67. return
  68. }
  69. var resp interface{}
  70. //判断单位类型
  71. if enterprise.Pvd == enum.EnterprisePvdForOnlinePayment && enterprise.Mode == enum.EnterpriseModeForSchool {
  72. err, resp = svc.CentralKitchenForSchoolInfo(enterpriseId)
  73. if err != nil {
  74. e.OutErr(c, e.ERR, err.Error())
  75. return
  76. }
  77. }
  78. if enterprise.Kind == enum.EnterpriseKindByNursingHome {
  79. err, resp = svc.NursingHomePackageInfo(enterpriseId)
  80. if err != nil {
  81. e.OutErr(c, e.ERR, err.Error())
  82. return
  83. }
  84. }
  85. sysCfgDb := db.SysCfgDb{}
  86. sysCfgDb.Set()
  87. res := sysCfgDb.SysCfgFindWithDb(enum.AdministratorContactInfo, enum.CentralKitchenForSchoolReserveMealTime, enum.CentralKitchenForSchoolCancelMealTime, enum.NursingHomeReserveMealTime, enum.NursingHomeCancelMealTime)
  88. e.OutSuc(c, map[string]interface{}{
  89. "info": resp,
  90. "set_center": res,
  91. "enterprise_kind_list": []map[string]interface{}{
  92. {
  93. "name": enum.EnterpriseKind.String(enum.EnterpriseKindByCentralKitchenForSchool),
  94. "value": enum.EnterpriseKindByCentralKitchenForSchool,
  95. },
  96. {
  97. "name": enum.EnterpriseKind.String(enum.EnterpriseKindByCentralKitchenForFactory),
  98. "value": enum.EnterpriseKindByCentralKitchenForFactory,
  99. },
  100. {
  101. "name": enum.EnterpriseKind.String(enum.EnterpriseKindBySelfSupportForSchool),
  102. "value": enum.EnterpriseKindBySelfSupportForSchool,
  103. },
  104. {
  105. "name": enum.EnterpriseKind.String(enum.EnterpriseKindBySelfSupportForFactory),
  106. "value": enum.EnterpriseKindBySelfSupportForFactory,
  107. },
  108. {
  109. "name": enum.EnterpriseKind.String(enum.EnterpriseKindByNursingHome),
  110. "value": enum.EnterpriseKindByNursingHome,
  111. },
  112. },
  113. }, nil)
  114. return
  115. }
  116. func SchoolBelowGrade(c *gin.Context) {
  117. enterpriseId := c.DefaultQuery("enterprise_id", "")
  118. gradeDb := db.GradeDb{}
  119. gradeDb.Set(utils.StrToInt(enterpriseId))
  120. gradeList, err := gradeDb.FindGrade()
  121. if err != nil {
  122. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  123. return
  124. }
  125. e.OutSuc(c, map[string]interface{}{
  126. "list": gradeList,
  127. }, nil)
  128. return
  129. }
  130. func SchoolGradeBelowClass(c *gin.Context) {
  131. gradeId := c.DefaultQuery("grade_id", "")
  132. classDb := db.ClassDb{}
  133. classDb.Set(utils.StrToInt(gradeId))
  134. classList, err := classDb.FindClass()
  135. if err != nil {
  136. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  137. return
  138. }
  139. e.OutSuc(c, map[string]interface{}{
  140. "list": classList,
  141. }, nil)
  142. return
  143. }