智慧食堂
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

174 Zeilen
6.2 KiB

  1. package hdl
  2. import (
  3. "applet/app/customer/svc"
  4. svc2 "applet/app/customer/svc/order"
  5. "applet/app/db"
  6. "applet/app/db/model"
  7. "applet/app/e"
  8. "applet/app/enum"
  9. "applet/app/utils"
  10. "github.com/gin-gonic/gin"
  11. "time"
  12. )
  13. func UserInfo(c *gin.Context) {
  14. //1、获取用户信息
  15. userInfo := svc.GetUser(c)
  16. //2、获取用户身份信息
  17. userIdentityDb := db.UserIdentityDb{}
  18. userIdentityDb.Set(userInfo.Id)
  19. identity, err := userIdentityDb.FindUserIdentity()
  20. if err != nil {
  21. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  22. return
  23. }
  24. var identityList []map[string]interface{}
  25. classWithUserDb := db.ClassWithUserDb{}
  26. classWithUserDb.Set()
  27. for _, v := range *identity {
  28. var tmp = map[string]interface{}{
  29. "identity": v.UserIdentity,
  30. "enterprise": v.Enterprise,
  31. "grade": nil,
  32. "class": nil,
  33. }
  34. if v.UserIdentity.Identity == enum.UserIdentityForCentralKitchenForStudent || v.UserIdentity.Identity == enum.UserIdentityForSelfSupportForStudent {
  35. //央厨学生 or 自营学生
  36. data, err1 := classWithUserDb.GetInfoByUserIdentityId(v.UserIdentity.Id)
  37. if err1 != nil {
  38. e.OutErr(c, e.ERR_DB_ORM, err1.Error())
  39. return
  40. }
  41. if data != nil {
  42. tmp["grade"] = data.Grade
  43. tmp["class"] = data.Class
  44. tmp["period"] = data.Period
  45. }
  46. }
  47. now := time.Now()
  48. if c.GetHeader("platform") != "wx_applet" && v.Enterprise.Pvd == enum.EnterprisePvdForFaceScanPayment && v.Enterprise.Mode == enum.EnterpriseModeForSchool {
  49. if v.UserIdentity.Identity == enum.UserIdentityForSelfSupportForWorker {
  50. //TODO::自营-工作人员
  51. selfSupportForUserFaceInfoDb := db.SelfSupportForUserFaceInfoDb{}
  52. selfSupportForUserFaceInfoDb.Set(0)
  53. tmp["school_face_pass_num"], _ = selfSupportForUserFaceInfoDb.CountSchoolFacePassStatus(v.EnterpriseId, "open")
  54. tmp["school_face_payment_num"], _ = selfSupportForUserFaceInfoDb.CountSchoolFacePaymentStatus(v.EnterpriseId, "open")
  55. tmp["concentrate_school_face_pass_num"], _ = selfSupportForUserFaceInfoDb.CountCollectFaceType(v.EnterpriseId, 2)
  56. tmp["single_school_face_pass_num"], _ = selfSupportForUserFaceInfoDb.CountCollectFaceType(v.EnterpriseId, 1)
  57. } else {
  58. //TODO:: 自营-学生 or 自营-教职员工
  59. sMDate := utils.GetFirstDateOfMonth(now).Format("2006-01-02 15:04:05")
  60. eMDate := utils.GetLastDateOfMonth(now).Format("2006-01-02 15:04:05")
  61. sTDate, eTDate := utils.GetDateTimeRangeStr("today")
  62. monthStatistic, err2 := svc2.SupportUserIdentityOrderStatistic(v.UserIdentity.Id, sMDate, eMDate)
  63. if err2 != nil {
  64. e.OutErr(c, e.ERR, err2.Error())
  65. return
  66. }
  67. dayStatistic, err2 := svc2.SupportUserIdentityOrderStatistic(v.UserIdentity.Id, sTDate, eTDate)
  68. if err2 != nil {
  69. e.OutErr(c, e.ERR, err2.Error())
  70. return
  71. }
  72. tmp["month_statistic"] = monthStatistic
  73. tmp["day_statistic"] = dayStatistic
  74. //统计是否存在欠费
  75. arrearsStatistic, err2 := svc2.SupportUserIdentityOrderStatisticForArrears(v.UserIdentity.Id)
  76. if err2 != nil {
  77. e.OutErr(c, e.ERR, err2.Error())
  78. return
  79. }
  80. tmp["arrears_statistic"] = arrearsStatistic
  81. //查询支付宝扣款账户
  82. selfSupportForUserFaceInfoDb := db.SelfSupportForUserFaceInfoDb{}
  83. selfSupportForUserFaceInfoDb.Set(v.UserIdentity.Id)
  84. info, err2 := selfSupportForUserFaceInfoDb.GetSelfSupportForUserFaceInfo()
  85. if err2 != nil {
  86. e.OutErr(c, e.ERR, err2.Error())
  87. return
  88. }
  89. if info == nil {
  90. selfSupportForSchoolInfoDb := db.SelfSupportForSchoolInfoDb{}
  91. selfSupportForSchoolInfoDb.Set(v.UserIdentity.EnterpriseId)
  92. selfSupportForSchoolInfo, err1 := selfSupportForSchoolInfoDb.GetSelfSupportForSchoolInfo()
  93. if err1 != nil {
  94. return
  95. }
  96. if selfSupportForSchoolInfo == nil {
  97. e.OutErr(c, e.ERR, "当前学校暂未完成《一脸通行入驻》")
  98. return
  99. }
  100. info = &model.SelfSupportForUserFaceInfo{
  101. EnterpriseId: v.UserIdentity.EnterpriseId,
  102. UserIdentityId: v.UserIdentity.Id,
  103. CollectFaceType: 1, //默认个采
  104. SchoolCode: selfSupportForSchoolInfo.SchoolCode,
  105. SchoolStdCode: selfSupportForSchoolInfo.SchoolStdCode,
  106. ParentUserId: "",
  107. ParentLogonId: "",
  108. UserId: "",
  109. SchoolFacePassStatus: "CLOSE",
  110. SchoolFacePaymentStatus: "CLOSE",
  111. ConcentrateSchoolFacePassStatus: 1,
  112. CreateAt: now.Format("2006-01-02 15:04:05"),
  113. UpdateAt: now.Format("2006-01-02 15:04:05"),
  114. }
  115. _, err3 := selfSupportForUserFaceInfoDb.SelfSupportForUserFaceInfoInsert(info)
  116. if err3 != nil {
  117. e.OutErr(c, e.ERR, err3.Error())
  118. return
  119. }
  120. }
  121. tmp["parent_logon_id"] = info.ParentLogonId
  122. tmp["collect_face_type"] = info.CollectFaceType
  123. tmp["concentrate_school_face_pass_status"] = info.ConcentrateSchoolFacePassStatus
  124. }
  125. }
  126. identityList = append(identityList, tmp)
  127. }
  128. utils.FilePutContents("user_info", utils.SerializeStr(map[string]interface{}{
  129. "user_info": userInfo,
  130. "user_identity": identityList,
  131. }))
  132. e.OutSuc(c, map[string]interface{}{
  133. "user_info": userInfo,
  134. "user_identity": identityList,
  135. "user_identity_kind_list": []map[string]interface{}{
  136. {
  137. "name": enum.UserIdentity.String(enum.UserIdentityForCentralKitchenForStudent),
  138. "value": enum.UserIdentityForCentralKitchenForStudent,
  139. },
  140. {
  141. "name": enum.UserIdentity.String(enum.UserIdentityForCentralKitchenForTeacher),
  142. "value": enum.UserIdentityForCentralKitchenForTeacher,
  143. },
  144. {
  145. "name": enum.UserIdentity.String(enum.UserIdentityForCentralKitchenForWorker),
  146. "value": enum.UserIdentityForCentralKitchenForWorker,
  147. },
  148. {
  149. "name": enum.UserIdentity.String(enum.UserIdentityForSelfSupportForStudent),
  150. "value": enum.UserIdentityForSelfSupportForStudent,
  151. },
  152. {
  153. "name": enum.UserIdentity.String(enum.UserIdentityForSelfSupportForTeacher),
  154. "value": enum.UserIdentityForSelfSupportForTeacher,
  155. },
  156. {
  157. "name": enum.UserIdentity.String(enum.UserIdentityForSelfSupportForWorker),
  158. "value": enum.UserIdentityForSelfSupportForWorker,
  159. },
  160. },
  161. }, nil)
  162. return
  163. }