|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- package hdl
-
- import (
- "applet/app/customer/svc"
- svc2 "applet/app/customer/svc/order"
- "applet/app/db"
- "applet/app/db/model"
- "applet/app/e"
- "applet/app/enum"
- "applet/app/utils"
- "github.com/gin-gonic/gin"
- "time"
- )
-
- func UserInfo(c *gin.Context) {
- //1、获取用户信息
- userInfo := svc.GetUser(c)
- //2、获取用户身份信息
- userIdentityDb := db.UserIdentityDb{}
- userIdentityDb.Set(userInfo.Id)
- identity, err := userIdentityDb.FindUserIdentity()
- if err != nil {
- e.OutErr(c, e.ERR_DB_ORM, err.Error())
- return
- }
- var identityList []map[string]interface{}
- classWithUserDb := db.ClassWithUserDb{}
- classWithUserDb.Set()
- for _, v := range *identity {
- var tmp = map[string]interface{}{
- "identity": v.UserIdentity,
- "enterprise": v.Enterprise,
- "grade": nil,
- "class": nil,
- }
- if v.UserIdentity.Identity == enum.UserIdentityForCentralKitchenForStudent || v.UserIdentity.Identity == enum.UserIdentityForSelfSupportForStudent {
- //央厨学生 or 自营学生
- data, err1 := classWithUserDb.GetInfoByUserIdentityId(v.UserIdentity.Id)
- if err1 != nil {
- e.OutErr(c, e.ERR_DB_ORM, err1.Error())
- return
- }
- if data != nil {
- tmp["grade"] = data.Grade
- tmp["class"] = data.Class
- tmp["period"] = data.Period
- }
- }
-
- now := time.Now()
- if v.Enterprise.Pvd == enum.EnterprisePvdForFaceScanPayment && v.Enterprise.Mode == enum.EnterpriseModeForSchool {
- //TODO:: 自营-学生 or 自营-教职员工
- sMDate := utils.GetFirstDateOfMonth(now).Format("2006-01-02 15:04:05")
- eMDate := utils.GetLastDateOfMonth(now).Format("2006-01-02 15:04:05")
- sTDate, eTDate := utils.GetDateTimeRangeStr("today")
- monthStatistic, err2 := svc2.SupportUserIdentityOrderStatistic(v.UserIdentity.Id, sMDate, eMDate)
- if err2 != nil {
- e.OutErr(c, e.ERR, err2.Error())
- return
- }
- dayStatistic, err2 := svc2.SupportUserIdentityOrderStatistic(v.UserIdentity.Id, sTDate, eTDate)
- if err2 != nil {
- e.OutErr(c, e.ERR, err2.Error())
- return
- }
- tmp["month_statistic"] = monthStatistic
- tmp["day_statistic"] = dayStatistic
-
- //统计是否存在欠费
- arrearsStatistic, err2 := svc2.SupportUserIdentityOrderStatisticForArrears(v.UserIdentity.Id)
- if err2 != nil {
- e.OutErr(c, e.ERR, err2.Error())
- return
- }
- tmp["arrears_statistic"] = arrearsStatistic
-
- //查询支付宝扣款账户
- selfSupportForUserFaceInfoDb := db.SelfSupportForUserFaceInfoDb{}
- selfSupportForUserFaceInfoDb.Set(v.UserIdentity.Id)
- info, err2 := selfSupportForUserFaceInfoDb.GetSelfSupportForUserFaceInfo()
- if err2 != nil {
- e.OutErr(c, e.ERR, err2.Error())
- return
- }
-
- if info == nil {
- selfSupportForSchoolInfoDb := db.SelfSupportForSchoolInfoDb{}
- selfSupportForSchoolInfoDb.Set(v.UserIdentity.EnterpriseId)
- selfSupportForSchoolInfo, err1 := selfSupportForSchoolInfoDb.GetSelfSupportForSchoolInfo()
- if err1 != nil {
- return
- }
- if selfSupportForSchoolInfo == nil {
- e.OutErr(c, e.ERR, "当前学校暂未完成《一脸通行入驻》")
- return
- }
-
- info = &model.SelfSupportForUserFaceInfo{
- EnterpriseId: v.UserIdentity.EnterpriseId,
- UserIdentityId: v.UserIdentity.Id,
- CollectFaceType: 1, //默认个采
- SchoolCode: selfSupportForSchoolInfo.SchoolCode,
- SchoolStdCode: selfSupportForSchoolInfo.SchoolStdCode,
- ParentUserId: "",
- ParentLogonId: "",
- UserId: "",
- SchoolFacePassStatus: "CLOSE",
- SchoolFacePaymentStatus: "CLOSE",
- ConcentrateSchoolFacePassStatus: 1,
- CreateAt: now.Format("2006-01-02 15:04:05"),
- UpdateAt: now.Format("2006-01-02 15:04:05"),
- }
- _, err3 := selfSupportForUserFaceInfoDb.SelfSupportForUserFaceInfoInsert(info)
- if err3 != nil {
- e.OutErr(c, e.ERR, err3.Error())
- return
- }
- }
- tmp["parent_logon_id"] = info.ParentLogonId
- tmp["collect_face_type"] = info.CollectFaceType
- tmp["concentrate_school_face_pass_status"] = info.ConcentrateSchoolFacePassStatus
- }
-
- if v.Enterprise.Pvd == enum.EnterprisePvdForFaceScanPayment && v.UserIdentity.Identity == enum.UserIdentityForSelfSupportForWorker {
- selfSupportForUserFaceInfoDb := db.SelfSupportForUserFaceInfoDb{}
- selfSupportForUserFaceInfoDb.Set(0)
- tmp["school_face_pass_num"], _ = selfSupportForUserFaceInfoDb.CountSchoolFacePassStatus(v.EnterpriseId, "open")
- tmp["school_face_payment_num"], _ = selfSupportForUserFaceInfoDb.CountSchoolFacePaymentStatus(v.EnterpriseId, "open")
- tmp["concentrate_school_face_pass_num"], _ = selfSupportForUserFaceInfoDb.CountCollectFaceType(v.EnterpriseId, 2)
- tmp["single_school_face_pass_num"], _ = selfSupportForUserFaceInfoDb.CountCollectFaceType(v.EnterpriseId, 1)
- }
- identityList = append(identityList, tmp)
- }
-
- utils.FilePutContents("user_info", utils.SerializeStr(map[string]interface{}{
- "user_info": userInfo,
- "user_identity": identityList,
- }))
-
- e.OutSuc(c, map[string]interface{}{
- "user_info": userInfo,
- "user_identity": identityList,
- "user_identity_kind_list": []map[string]interface{}{
- {
- "name": enum.UserIdentity.String(enum.UserIdentityForCentralKitchenForStudent),
- "value": enum.UserIdentityForCentralKitchenForStudent,
- },
- {
- "name": enum.UserIdentity.String(enum.UserIdentityForCentralKitchenForTeacher),
- "value": enum.UserIdentityForCentralKitchenForTeacher,
- },
- {
- "name": enum.UserIdentity.String(enum.UserIdentityForCentralKitchenForWorker),
- "value": enum.UserIdentityForCentralKitchenForWorker,
- },
- {
- "name": enum.UserIdentity.String(enum.UserIdentityForSelfSupportForStudent),
- "value": enum.UserIdentityForSelfSupportForStudent,
- },
- {
- "name": enum.UserIdentity.String(enum.UserIdentityForSelfSupportForTeacher),
- "value": enum.UserIdentityForSelfSupportForTeacher,
- },
- {
- "name": enum.UserIdentity.String(enum.UserIdentityForSelfSupportForWorker),
- "value": enum.UserIdentityForSelfSupportForWorker,
- },
- },
- }, nil)
- return
- }
|