From 6612f9ef7715f80b52fc738574343317bbe03b96 Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Tue, 5 Sep 2023 16:05:14 +0800 Subject: [PATCH] update --- .../hdl_self_support_for_school.go | 55 ++++++++++++++++++- app/customer/md/md_curl_smart_pay.go | 10 ++++ app/customer/svc/svc_curl_smart_pay.go | 52 ++++++++++++++++-- app/router/admin_router.go | 47 ++++++++-------- 4 files changed, 136 insertions(+), 28 deletions(-) diff --git a/app/admin/hdl/enterprise_manage/hdl_self_support_for_school.go b/app/admin/hdl/enterprise_manage/hdl_self_support_for_school.go index 018380d..8714862 100644 --- a/app/admin/hdl/enterprise_manage/hdl_self_support_for_school.go +++ b/app/admin/hdl/enterprise_manage/hdl_self_support_for_school.go @@ -811,7 +811,6 @@ func SelfSupportForSchoolEducateSceneKidsClose(c *gin.Context) { return } - //请求支付宝 alipay.commerce.educate.scene.token.query(查询刷脸用户开通详细信息) sysCfgDb := db.SysCfgDb{} sysCfgDb.Set() sysCfg := sysCfgDb.SysCfgFindWithDb(enum.OpenAppletAppid, enum.OpenAppletAppPrivateKey, enum.OpenAppletPublicKey) @@ -837,3 +836,57 @@ func SelfSupportForSchoolEducateSceneKidsClose(c *gin.Context) { e.OutSuc(c, info, nil) return } + +func SelfSupportForSchoolEducateFacepayClose(c *gin.Context) { + userIdentityId := c.DefaultQuery("user_identity_id", "") + userIdentityDb := db.UserIdentityDb{} + userIdentityDb.Set(0) + identity, err := userIdentityDb.GetUserIdentity(utils.StrToInt(userIdentityId)) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + + selfSupportForSchoolInfoDb := db.SelfSupportForSchoolInfoDb{} + selfSupportForSchoolInfoDb.Set(identity.EnterpriseId) + selfSupportForSchoolInfo, err := selfSupportForSchoolInfoDb.GetSelfSupportForSchoolInfo() + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + if selfSupportForSchoolInfo == nil { + e.OutErr(c, e.ERR_NO_DATA, "当前学校暂未完成《一脸通行入驻》") + return + } + + selfSupportForUserFaceInfoDb := db.SelfSupportForUserFaceInfoDb{} + selfSupportForUserFaceInfoDb.Set(identity.Id) + selfSupportForUserFaceInfo, err := selfSupportForUserFaceInfoDb.GetSelfSupportForUserFaceInfo() + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + + sysCfgDb := db.SysCfgDb{} + sysCfgDb.Set() + sysCfg := sysCfgDb.SysCfgFindWithDb(enum.OpenAppletAppid, enum.OpenAppletAppPrivateKey, enum.OpenAppletPublicKey) + err, info := svc.CurlEducateFacepayClose(md2.CurlEducateFacepayCloseReq{ + Config: struct { + AliAppId string `json:"ali_app_id" label:"支付宝开放平台-小程序-appid"` + AliPrivateKey string `json:"ali_private_key" label:"支付宝开放平台-小程序-应用私钥"` + AliPublicKey string `json:"ali_public_key" label:"支付宝开放平台-小程序-支付宝公钥"` + }{ + AliAppId: sysCfg[enum.OpenAppletAppid], + AliPrivateKey: sysCfg[enum.OpenAppletAppPrivateKey], + AliPublicKey: sysCfg[enum.OpenAppletPublicKey], + }, + SchoolStdCode: selfSupportForSchoolInfo.SchoolStdCode, + FaceUid: selfSupportForUserFaceInfo.UserId, + }) + if err != nil { + e.OutErr(c, e.ERR, err.Error()) + return + } + e.OutSuc(c, info, nil) + return +} diff --git a/app/customer/md/md_curl_smart_pay.go b/app/customer/md/md_curl_smart_pay.go index e781bbd..33354ec 100644 --- a/app/customer/md/md_curl_smart_pay.go +++ b/app/customer/md/md_curl_smart_pay.go @@ -91,6 +91,16 @@ type CurlEducateSceneKidsCloseReq struct { SchoolStdCode string `json:"school_std_code" label:"学校外标"` } +type CurlEducateFacepayCloseReq struct { + Config struct { + AliAppId string `json:"ali_app_id" label:"支付宝开放平台-小程序-appid"` + AliPrivateKey string `json:"ali_private_key" label:"支付宝开放平台-小程序-应用私钥"` + AliPublicKey string `json:"ali_public_key" label:"支付宝开放平台-小程序-支付宝公钥"` + } `json:"config" label:"配置信息"` + FaceUid string `json:"face_uid" label:"刷脸用户的UID"` + SchoolStdCode string `json:"school_std_code" label:"学校外标"` +} + type CurlEducateFacepayApplyReq struct { Config struct { AliAppId string `json:"ali_app_id" label:"支付宝开放平台-小程序-appid"` diff --git a/app/customer/svc/svc_curl_smart_pay.go b/app/customer/svc/svc_curl_smart_pay.go index 9a3d8ca..b06c991 100644 --- a/app/customer/svc/svc_curl_smart_pay.go +++ b/app/customer/svc/svc_curl_smart_pay.go @@ -328,10 +328,10 @@ func CurlEducateSceneKidsClose(args md.CurlEducateSceneKidsCloseReq) (err error, "ali_private_key": args.Config.AliPrivateKey, "ali_public_key": args.Config.AliPublicKey, }, - "cert_no": args.CertNo, - "school_std_code": args.SchoolStdCode, - "user_id": args.UserId, - "parent_uid": args.ParentUid, + "cert_no": args.CertNo, + "school_stdcode": args.SchoolStdCode, + "user_id": args.UserId, + "parent_uid": args.ParentUid, }), nil) if err1 != nil { return @@ -361,6 +361,50 @@ func CurlEducateSceneKidsClose(args md.CurlEducateSceneKidsCloseReq) (err error, return nil, result.Data } +func CurlEducateFacepayClose(args md.CurlEducateFacepayCloseReq) (err error, resp interface{}) { + utils.FilePutContents("CurlEducateFacepayClose", utils.SerializeStr(map[string]interface{}{ + "args": args, + })) + + //1、TODO::生成用户信息token(使用 alipay.commerce.educate.scene.token.create 接口生成用户信息token) + url := cfg.SmartCanteenPay + "/alipay/faceCollection/educateFacepayClose" + bytes, err1 := utils.CurlPost(url, utils.Serialize(map[string]interface{}{ + "config": map[string]string{ + "ali_app_id": args.Config.AliAppId, + "ali_private_key": args.Config.AliPrivateKey, + "ali_public_key": args.Config.AliPublicKey, + }, + "school_stdcode": args.SchoolStdCode, + "face_uid": args.FaceUid, + }), nil) + if err1 != nil { + return + } + var result struct { + Code int `json:"code"` + Msg string `json:"msg"` + Data interface{} `json:"data"` + } + utils.FilePutContents("CurlEducateFacepayClose", utils.SerializeStr(result)) + err = json.Unmarshal(bytes, &result) + if err != nil { + return + } + if result.Code != 0 { + if result.Msg != "" { + err = errors.New(result.Msg) + return + } + err = errors.New("请求智慧餐厅支付 异常/失败") + return + } + err = json.Unmarshal(utils.Serialize(result.Data), &resp) + if err != nil { + return + } + return nil, result.Data +} + func CurlEducateSceneTokenCreateForApplet(args md.CurlEducateSceneTokenReq) (err error, resp interface{}) { utils.FilePutContents("CurlEducateSceneTokenCreateForApplet", utils.SerializeStr(map[string]interface{}{ "args": args, diff --git a/app/router/admin_router.go b/app/router/admin_router.go index bf0baee..647f3ec 100644 --- a/app/router/admin_router.go +++ b/app/router/admin_router.go @@ -154,29 +154,30 @@ func rEnterpriseManage(r *gin.RouterGroup) { r.POST("/saveCentralKitchenForSchoolPackage", hdl.SaveCentralKitchenForSchoolPackage) //新增/编辑 "央厨-学校-套餐" r.DELETE("/deleteCentralKitchenForSchoolPackage/:id", hdl.DeleteCentralKitchenForSchoolPackage) //删除 "央厨-学校-套餐" - r.POST("/selfSupportForSchool/userUpdate", hdl.SelfSupportForSchoolUserUpdate) //"自营-学校"用户编辑 - r.POST("/selfSupportForSchool/userDelete", hdl.SelfSupportForSchoolUserDelete) //"自营-学校"用户删除 - r.POST("/selfSupportForSchool/studentList", hdl.SelfSupportForSchoolStudentList) //"自营-学校"学生列表 - r.POST("/selfSupportForSchool/studentUpdate", hdl.SelfSupportForSchoolStudentUpdate) //"自营-学校"学生编辑 - r.POST("/selfSupportForSchool/studentDelete", hdl.SelfSupportForSchoolStudentDelete) //"自营-学校"学生删除 - r.POST("/selfSupportForSchool/studentAdmission", hdl.SelfSupportForSchoolStudentAdmission) //"自营-学校"学生升学 - r.POST("/selfSupportForSchool/teacherList", hdl.SelfSupportForSchoolTeacherList) //"自营-学校"教师列表 - r.POST("/selfSupportForSchool/teacherUpdate", hdl.SelfSupportForSchoolTeacherUpdate) //"自营-学校"教师编辑 - r.POST("/selfSupportForSchool/teacherDelete", hdl.SelfSupportForSchoolTeacherDelete) //"自营-学校"教师删除 - r.POST("/selfSupportForSchool/workerList", hdl.SelfSupportForSchoolWorkerList) //"自营-学校"工作人员列表 - r.POST("/selfSupportForSchool/workerUpdate", hdl.SelfSupportForSchoolWorkerUpdate) //"自营-学校"工作人员编辑 - r.POST("/selfSupportForSchool/workerDelete", hdl.SelfSupportForSchoolWorkerDelete) //"自营-学校"工作人员删除 - r.POST("/selfSupportForSchool/gradeList", hdl.SelfSupportForSchoolGradeList) //"自营-学校"年级列表 - r.DELETE("/selfSupportForSchool/gradeDelete/:id", hdl.SelfSupportForSchoolGradeDelete) //"自营-学校"年级删除 - r.POST("/selfSupportForSchool/classList", hdl.SelfSupportForSchoolClassList) //"自营-学校"班级列表 - r.DELETE("/selfSupportForSchool/classDelete/:id", hdl.SelfSupportForSchoolClassDelete) //"自营-学校"班级删除 - r.POST("/selfSupportForSchool/addWorker", hdl.SelfSupportForSchoolAddWorker) //"自营-学校"添加工作人员 - r.POST("/selfSupportForSchool/addTeacher", hdl.SelfSupportForSchoolAddTeacher) //"自营-学校"添加老师 - r.POST("/selfSupportForSchool/ordList", hdl.SelfSupportForSchoolOrdList) //"自营-学校"订单列表 - r.POST("/selfSupportForSchool/arrearsOrdList", hdl.SelfSupportForSchoolArrearsOrdList) //"自营-学校"订单欠费列表 - r.POST("/selfSupportForSchool/arrearsOrdDebtRepay", hdl.SelfSupportForSchoolArrearsOrdDebtRepay) //"自营-学校"订单欠费催缴 - r.POST("/selfSupportForSchool/arrearsOrdDebtCancel", hdl.SelfSupportForSchoolArrearsOrdDebtCancel) //"自营-学校"撤销欠款 - r.POST("/selfSupportForSchool/educateSceneKidsClose", hdl.SelfSupportForSchoolEducateSceneKidsClose) //"自营-学校"人脸识别关闭 + r.POST("/selfSupportForSchool/userUpdate", hdl.SelfSupportForSchoolUserUpdate) //"自营-学校"用户编辑 + r.POST("/selfSupportForSchool/userDelete", hdl.SelfSupportForSchoolUserDelete) //"自营-学校"用户删除 + r.POST("/selfSupportForSchool/studentList", hdl.SelfSupportForSchoolStudentList) //"自营-学校"学生列表 + r.POST("/selfSupportForSchool/studentUpdate", hdl.SelfSupportForSchoolStudentUpdate) //"自营-学校"学生编辑 + r.POST("/selfSupportForSchool/studentDelete", hdl.SelfSupportForSchoolStudentDelete) //"自营-学校"学生删除 + r.POST("/selfSupportForSchool/studentAdmission", hdl.SelfSupportForSchoolStudentAdmission) //"自营-学校"学生升学 + r.POST("/selfSupportForSchool/teacherList", hdl.SelfSupportForSchoolTeacherList) //"自营-学校"教师列表 + r.POST("/selfSupportForSchool/teacherUpdate", hdl.SelfSupportForSchoolTeacherUpdate) //"自营-学校"教师编辑 + r.POST("/selfSupportForSchool/teacherDelete", hdl.SelfSupportForSchoolTeacherDelete) //"自营-学校"教师删除 + r.POST("/selfSupportForSchool/workerList", hdl.SelfSupportForSchoolWorkerList) //"自营-学校"工作人员列表 + r.POST("/selfSupportForSchool/workerUpdate", hdl.SelfSupportForSchoolWorkerUpdate) //"自营-学校"工作人员编辑 + r.POST("/selfSupportForSchool/workerDelete", hdl.SelfSupportForSchoolWorkerDelete) //"自营-学校"工作人员删除 + r.POST("/selfSupportForSchool/gradeList", hdl.SelfSupportForSchoolGradeList) //"自营-学校"年级列表 + r.DELETE("/selfSupportForSchool/gradeDelete/:id", hdl.SelfSupportForSchoolGradeDelete) //"自营-学校"年级删除 + r.POST("/selfSupportForSchool/classList", hdl.SelfSupportForSchoolClassList) //"自营-学校"班级列表 + r.DELETE("/selfSupportForSchool/classDelete/:id", hdl.SelfSupportForSchoolClassDelete) //"自营-学校"班级删除 + r.POST("/selfSupportForSchool/addWorker", hdl.SelfSupportForSchoolAddWorker) //"自营-学校"添加工作人员 + r.POST("/selfSupportForSchool/addTeacher", hdl.SelfSupportForSchoolAddTeacher) //"自营-学校"添加老师 + r.POST("/selfSupportForSchool/ordList", hdl.SelfSupportForSchoolOrdList) //"自营-学校"订单列表 + r.POST("/selfSupportForSchool/arrearsOrdList", hdl.SelfSupportForSchoolArrearsOrdList) //"自营-学校"订单欠费列表 + r.POST("/selfSupportForSchool/arrearsOrdDebtRepay", hdl.SelfSupportForSchoolArrearsOrdDebtRepay) //"自营-学校"订单欠费催缴 + r.POST("/selfSupportForSchool/arrearsOrdDebtCancel", hdl.SelfSupportForSchoolArrearsOrdDebtCancel) //"自营-学校"撤销欠款 + r.GET("/selfSupportForSchool/educateSceneKidsClose", hdl.SelfSupportForSchoolEducateSceneKidsClose) //"自营-学校"人脸识别关闭 + r.GET("/selfSupportForSchool/educateFacepayClose", hdl.SelfSupportForSchoolEducateFacepayClose) //"自营-学校"刷脸支付关闭 }