智慧食堂
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.

168 lines
4.6 KiB

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