智慧食堂
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

hdl_enterprise.go 4.7 KiB

1 year ago
3 months ago
1 year ago
3 months ago
1 year ago
1 year ago
3 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
4 months ago
3 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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 = 100
  23. }
  24. if req.Page == 0 {
  25. req.Page = 1
  26. }
  27. req.Limit = 100
  28. platform := c.GetHeader("platform")
  29. enterprises, total, err := svc.EnterpriseList(req, platform)
  30. if err != nil {
  31. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  32. return
  33. }
  34. e.OutSuc(c, map[string]interface{}{
  35. "list": enterprises,
  36. "total": total,
  37. "kind": []map[string]interface{}{
  38. {
  39. "name": enum.EnterpriseKind(enum.EnterpriseKindByCentralKitchenForSchool).String(),
  40. "value": enum.EnterpriseKindByCentralKitchenForSchool,
  41. },
  42. {
  43. "name": enum.EnterpriseKind(enum.EnterpriseKindByCentralKitchenForFactory).String(),
  44. "value": enum.EnterpriseKindByCentralKitchenForFactory,
  45. },
  46. {
  47. "name": enum.EnterpriseKind(enum.EnterpriseKindBySelfSupportForSchool).String(),
  48. "value": enum.EnterpriseKindBySelfSupportForSchool,
  49. },
  50. {
  51. "name": enum.EnterpriseKind(enum.EnterpriseKindBySelfSupportForFactory).String(),
  52. "value": enum.EnterpriseKindBySelfSupportForFactory,
  53. },
  54. },
  55. }, nil)
  56. return
  57. }
  58. func EnterpriseInfo(c *gin.Context) {
  59. enterpriseId := utils.StrToInt(c.DefaultQuery("enterprise_id", ""))
  60. enterpriseDb := db.EnterpriseDb{}
  61. enterpriseDb.Set()
  62. enterprise, err := enterpriseDb.GetEnterprise(enterpriseId)
  63. if err != nil {
  64. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  65. return
  66. }
  67. if enterprise == nil {
  68. e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录")
  69. return
  70. }
  71. var resp interface{}
  72. //判断单位类型
  73. if enterprise.Pvd == enum.EnterprisePvdForOnlinePayment && enterprise.Mode == enum.EnterpriseModeForSchool {
  74. err, resp = svc.CentralKitchenForSchoolInfo(enterpriseId)
  75. if err != nil {
  76. e.OutErr(c, e.ERR, err.Error())
  77. return
  78. }
  79. }
  80. if enterprise.Kind == enum.EnterpriseKindByNursingHome {
  81. err, resp = svc.NursingHomePackageInfo(enterpriseId)
  82. if err != nil {
  83. e.OutErr(c, e.ERR, err.Error())
  84. return
  85. }
  86. }
  87. sysCfgDb := db.SysCfgDb{}
  88. sysCfgDb.Set()
  89. res := sysCfgDb.SysCfgFindWithDb(enum.AdministratorContactInfo, enum.CentralKitchenForSchoolReserveMealTime, enum.CentralKitchenForSchoolCancelMealTime,
  90. enum.CentralKitchenForSchoolCancelMealTimeForBreakfast, enum.CentralKitchenForSchoolCancelMealTimeForLunch, enum.CentralKitchenForSchoolCancelMealTimeForDinner, enum.CentralKitchenForSchoolTeacherMealNotice)
  91. e.OutSuc(c, map[string]interface{}{
  92. "info": resp,
  93. "set_center": res,
  94. "enterprise_kind_list": []map[string]interface{}{
  95. {
  96. "name": enum.EnterpriseKind.String(enum.EnterpriseKindByCentralKitchenForSchool),
  97. "value": enum.EnterpriseKindByCentralKitchenForSchool,
  98. },
  99. {
  100. "name": enum.EnterpriseKind.String(enum.EnterpriseKindByCentralKitchenForFactory),
  101. "value": enum.EnterpriseKindByCentralKitchenForFactory,
  102. },
  103. {
  104. "name": enum.EnterpriseKind.String(enum.EnterpriseKindBySelfSupportForSchool),
  105. "value": enum.EnterpriseKindBySelfSupportForSchool,
  106. },
  107. {
  108. "name": enum.EnterpriseKind.String(enum.EnterpriseKindBySelfSupportForFactory),
  109. "value": enum.EnterpriseKindBySelfSupportForFactory,
  110. },
  111. {
  112. "name": enum.EnterpriseKind.String(enum.EnterpriseKindByNursingHome),
  113. "value": enum.EnterpriseKindByNursingHome,
  114. },
  115. },
  116. "user_identity_cert_type_list": []map[string]interface{}{
  117. {
  118. "name": enum.UserIdentityCertType.String(enum.UserIdentityCertTypeForIdCard),
  119. "value": enum.UserIdentityCertTypeForIdCard,
  120. },
  121. {
  122. "name": enum.UserIdentityCertType.String(enum.UserIdentityCertTypeForStudentId),
  123. "value": enum.UserIdentityCertTypeForStudentId,
  124. },
  125. //{
  126. // "name": enum.UserIdentityCertType.String(enum.UserIdentityCertTypeForPassport),
  127. // "value": enum.UserIdentityCertTypeForPassport,
  128. //},
  129. },
  130. }, nil)
  131. return
  132. }
  133. func SchoolBelowGrade(c *gin.Context) {
  134. enterpriseId := c.DefaultQuery("enterprise_id", "")
  135. gradeDb := db.GradeDb{}
  136. gradeDb.Set(utils.StrToInt(enterpriseId))
  137. gradeList, err := gradeDb.FindGrade()
  138. if err != nil {
  139. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  140. return
  141. }
  142. e.OutSuc(c, map[string]interface{}{
  143. "list": gradeList,
  144. }, nil)
  145. return
  146. }
  147. func SchoolGradeBelowClass(c *gin.Context) {
  148. gradeId := c.DefaultQuery("grade_id", "")
  149. classDb := db.ClassDb{}
  150. classDb.Set(utils.StrToInt(gradeId))
  151. classList, err := classDb.FindClass()
  152. if err != nil {
  153. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  154. return
  155. }
  156. e.OutSuc(c, map[string]interface{}{
  157. "list": classList,
  158. }, nil)
  159. return
  160. }