智慧食堂
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_user.go 7.1 KiB

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
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
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
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
1 year ago
1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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. if v.Enterprise.Pvd == enum.EnterprisePvdForAllPayment && v.Enterprise.Mode == enum.EnterpriseModeForFactory {
  133. //TODO::工厂
  134. sMDate := utils.GetFirstDateOfMonth(now).Format("2006-01-02 15:04:05")
  135. eMDate := utils.GetLastDateOfMonth(now).Format("2006-01-02 15:04:05")
  136. sTDate, eTDate := utils.GetDateTimeRangeStr("today")
  137. monthStatistic, err2 := svc2.FactoryUserIdentityOrderStatistic(v.UserIdentity.Id, sMDate, eMDate, "total_amount")
  138. if err2 != nil {
  139. e.OutErr(c, e.ERR, err2.Error())
  140. return
  141. }
  142. dayStatistic, err2 := svc2.FactoryUserIdentityOrderStatistic(v.UserIdentity.Id, sTDate, eTDate, "total_amount")
  143. if err2 != nil {
  144. e.OutErr(c, e.ERR, err2.Error())
  145. return
  146. }
  147. tmp["month_statistic"] = monthStatistic
  148. tmp["day_statistic"] = dayStatistic
  149. }
  150. identityList = append(identityList, tmp)
  151. }
  152. utils.FilePutContents("user_info", utils.SerializeStr(map[string]interface{}{
  153. "user_info": userInfo,
  154. "user_identity": identityList,
  155. }))
  156. e.OutSuc(c, map[string]interface{}{
  157. "user_info": userInfo,
  158. "user_identity": identityList,
  159. "user_identity_kind_list": []map[string]interface{}{
  160. {
  161. "name": enum.UserIdentity.String(enum.UserIdentityForCentralKitchenForStudent),
  162. "value": enum.UserIdentityForCentralKitchenForStudent,
  163. },
  164. {
  165. "name": enum.UserIdentity.String(enum.UserIdentityForCentralKitchenForTeacher),
  166. "value": enum.UserIdentityForCentralKitchenForTeacher,
  167. },
  168. {
  169. "name": enum.UserIdentity.String(enum.UserIdentityForCentralKitchenForWorker),
  170. "value": enum.UserIdentityForCentralKitchenForWorker,
  171. },
  172. {
  173. "name": enum.UserIdentity.String(enum.UserIdentityForSelfSupportForStudent),
  174. "value": enum.UserIdentityForSelfSupportForStudent,
  175. },
  176. {
  177. "name": enum.UserIdentity.String(enum.UserIdentityForSelfSupportForTeacher),
  178. "value": enum.UserIdentityForSelfSupportForTeacher,
  179. },
  180. {
  181. "name": enum.UserIdentity.String(enum.UserIdentityForSelfSupportForWorker),
  182. "value": enum.UserIdentityForSelfSupportForWorker,
  183. },
  184. },
  185. }, nil)
  186. return
  187. }