diff --git a/app/admin/svc/enterprise_manage/svc_self_support_for_school.go b/app/admin/svc/enterprise_manage/svc_self_support_for_school.go index 46619d0..3b2e22c 100644 --- a/app/admin/svc/enterprise_manage/svc_self_support_for_school.go +++ b/app/admin/svc/enterprise_manage/svc_self_support_for_school.go @@ -412,11 +412,44 @@ func SelfSupportForSchoolStudentUpdate(req md.SelfSupportForSchoolStudentUpdateR _ = session.Rollback() return } - info.CollectFaceType = req.CollectFaceType - _, err = selfSupportForUserFaceInfoDb.SelfSupportForUserFaceInfoUpdate(info, "collect_face_type") - if err != nil { - _ = session.Rollback() + if info == nil { + now := time.Now() + selfSupportForSchoolInfoDb := db.SelfSupportForSchoolInfoDb{} + selfSupportForSchoolInfoDb.Set(req.EnterpriseId) + selfSupportForSchoolInfo, err := selfSupportForSchoolInfoDb.GetSelfSupportForSchoolInfo() + if err != nil { + return + } + if selfSupportForSchoolInfo == nil { + return errors.New("当前学校暂未完成《一脸通行入驻》") + } + info = &model.SelfSupportForUserFaceInfo{ + EnterpriseId: req.EnterpriseId, + UserIdentityId: req.UserIdentityId, + CollectFaceType: req.CollectFaceType, + 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"), + } + _, err1 := selfSupportForUserFaceInfoDb.SelfSupportForUserFaceInfoInsert(info) + if err1 != nil { + return err1 + } + } else { + info.CollectFaceType = req.CollectFaceType + _, err = selfSupportForUserFaceInfoDb.SelfSupportForUserFaceInfoUpdate(info, "collect_face_type") + if err != nil { + _ = session.Rollback() + } } + return session.Commit() }