智慧食堂
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

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