新增申请云证书接口
This commit is contained in:
parent
70f9c47e0c
commit
d0d86826bc
@ -12,6 +12,7 @@ type Api struct {
|
|||||||
caseManage // 病例管理
|
caseManage // 病例管理
|
||||||
orderPrescriptionManage // 处方管理
|
orderPrescriptionManage // 处方管理
|
||||||
inquiryManage // 问诊管理
|
inquiryManage // 问诊管理
|
||||||
|
caManage // ca管理
|
||||||
}
|
}
|
||||||
|
|
||||||
// SysSetting 系统设置
|
// SysSetting 系统设置
|
||||||
@ -65,3 +66,8 @@ type orderPrescriptionManage struct {
|
|||||||
type inquiryManage struct {
|
type inquiryManage struct {
|
||||||
InquiryConfig // 问诊配置
|
InquiryConfig // 问诊配置
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ca管理
|
||||||
|
type caManage struct {
|
||||||
|
UserCaCert // 证书
|
||||||
|
}
|
||||||
|
|||||||
49
api/controller/userCaCert.go
Normal file
49
api/controller/userCaCert.go
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
package controller
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"hospital-admin-api/api/responses"
|
||||||
|
"hospital-admin-api/api/service"
|
||||||
|
"hospital-admin-api/config"
|
||||||
|
"hospital-admin-api/global"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
type UserCaCert struct{}
|
||||||
|
|
||||||
|
// GetUserCloudCert 申请云证书-个人
|
||||||
|
func (r *UserCaCert) GetUserCloudCert(c *gin.Context) {
|
||||||
|
id := c.Param("user_id")
|
||||||
|
if id == "" {
|
||||||
|
responses.FailWithMessage("缺少参数", c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将 id 转换为 int64 类型
|
||||||
|
userId, err := strconv.ParseInt(id, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
responses.Fail(c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 业务处理
|
||||||
|
tx := global.Db.Begin()
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
tx.Rollback()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
if config.C.Env == "prod" {
|
||||||
|
userCaCertService := service.UserCaCertService{}
|
||||||
|
_, err = userCaCertService.GetUserCloudCert(tx, userId)
|
||||||
|
if err != nil {
|
||||||
|
tx.Rollback()
|
||||||
|
responses.FailWithMessage(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tx.Commit()
|
||||||
|
responses.Ok(c)
|
||||||
|
}
|
||||||
@ -53,6 +53,15 @@ func (r *UserCaCert) GetUserCaCertList(maps interface{}) (m []*model.UserCaCert,
|
|||||||
return m, nil
|
return m, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetUserCaCert 获取监管证书
|
||||||
|
func (r *UserCaCert) GetUserCaCert(maps interface{}) (m *model.UserCaCert, err error) {
|
||||||
|
err = global.Db.Where(maps).First(&m).Error
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
|
|
||||||
// DeleteUserCaCertById 删除监管证书-监管证书id
|
// DeleteUserCaCertById 删除监管证书-监管证书id
|
||||||
func (r *UserCaCert) DeleteUserCaCertById(tx *gorm.DB, certId int64) error {
|
func (r *UserCaCert) DeleteUserCaCertById(tx *gorm.DB, certId int64) error {
|
||||||
if err := tx.Delete(&model.UserCaCert{}, certId).Error; err != nil {
|
if err := tx.Delete(&model.UserCaCert{}, certId).Error; err != nil {
|
||||||
|
|||||||
@ -21,6 +21,15 @@ func (r *UserDoctorDao) GetUserDoctorById(doctorId int64) (m *model.UserDoctor,
|
|||||||
return m, nil
|
return m, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetUserDoctorByUserId 获取医生数据-用户id
|
||||||
|
func (r *UserDoctorDao) GetUserDoctorByUserId(userId int64) (m *model.UserDoctor, err error) {
|
||||||
|
err = global.Db.Where("user_id = ?", userId).First(&m).Error
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
|
|
||||||
// GetUserDoctorPreloadById 获取医生数据-加载全部关联-医生id
|
// GetUserDoctorPreloadById 获取医生数据-加载全部关联-医生id
|
||||||
func (r *UserDoctorDao) GetUserDoctorPreloadById(doctorId int64) (m *model.UserDoctor, err error) {
|
func (r *UserDoctorDao) GetUserDoctorPreloadById(doctorId int64) (m *model.UserDoctor, err error) {
|
||||||
err = global.Db.Preload(clause.Associations).First(&m, doctorId).Error
|
err = global.Db.Preload(clause.Associations).First(&m, doctorId).Error
|
||||||
|
|||||||
@ -8,16 +8,19 @@ import (
|
|||||||
|
|
||||||
// UserCaCert 医师/药师ca监管证书表
|
// UserCaCert 医师/药师ca监管证书表
|
||||||
type UserCaCert struct {
|
type UserCaCert struct {
|
||||||
CertId int64 `gorm:"column:cert_id;type:bigint(19);primary_key;comment:主键id" json:"cert_id"`
|
CertId int64 `gorm:"column:cert_id;type:bigint(19);primary_key;comment:主键id" json:"cert_id"`
|
||||||
UserId *int64 `gorm:"column:user_id;type:bigint(19);comment:用户id(系统证书时为null)" json:"user_id"`
|
UserId *int64 `gorm:"column:user_id;type:bigint(19);comment:用户id(系统证书时为null)" json:"user_id"`
|
||||||
IsSystem int `gorm:"column:is_system;type:tinyint(1);default:0;comment:是否系统证书(0:否 1:是)" json:"is_system"`
|
IsSystem int `gorm:"column:is_system;type:tinyint(1);default:0;comment:是否系统证书(0:否 1:是)" json:"is_system"`
|
||||||
Type int `gorm:"column:type;type:tinyint(1);comment:证书类型(1:线下 2:线上)" json:"type"`
|
IsLatest int `gorm:"column:is_latest;type:tinyint(1);default:1;comment:是否最新(0:否 1:是)" json:"is_latest"`
|
||||||
CertBase64 string `gorm:"column:cert_base64;type:text;comment:签名值证书" json:"cert_base64"`
|
Type int `gorm:"column:type;type:tinyint(1);comment:证书类型(1:线下 2:线上)" json:"type"`
|
||||||
CertChainP7 string `gorm:"column:cert_chain_p7;type:text;comment:证书链" json:"cert_chain_p7"`
|
CertBase64 string `gorm:"column:cert_base64;type:text;comment:签名值证书" json:"cert_base64"`
|
||||||
CertSerialNumber string `gorm:"column:cert_serial_number;type:varchar(100);comment:证书序列号" json:"cert_serial_number"`
|
CertChainP7 string `gorm:"column:cert_chain_p7;type:text;comment:证书链" json:"cert_chain_p7"`
|
||||||
CaPin string `gorm:"column:ca_pin;type:varchar(100);comment:ca认证pin值" json:"ca_pin"`
|
CertSerialNumber string `gorm:"column:cert_serial_number;type:varchar(100);comment:证书序列号" json:"cert_serial_number"`
|
||||||
IsSignConfig int `gorm:"column:is_sign_config;type:tinyint(1);default:0;comment:是否已添加签章配置(第一次需申请)" json:"is_sign_config"`
|
CaPin string `gorm:"column:ca_pin;type:varchar(100);comment:ca认证pin值" json:"ca_pin"`
|
||||||
SignConfig string `gorm:"column:sign_config;type:text;comment:签章坐标配置" json:"sign_config"`
|
IsSignConfig int `gorm:"column:is_sign_config;type:tinyint(1);default:0;comment:是否已添加签章配置(第一次需申请)" json:"is_sign_config"`
|
||||||
|
SignConfig string `gorm:"column:sign_config;type:text;comment:签章坐标配置" json:"sign_config"`
|
||||||
|
CertApplicationTime LocalTime `gorm:"column:cert_application_time;type:datetime;comment:证书申请时间" json:"cert_application_time"`
|
||||||
|
CertExpireTime LocalTime `gorm:"column:cert_expire_time;type:datetime;comment:证书过期时间" json:"cert_expire_time"`
|
||||||
Model
|
Model
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -225,7 +225,7 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
|||||||
menuGroup.GET("/:menu_id", api.Menu.GetMenu)
|
menuGroup.GET("/:menu_id", api.Menu.GetMenu)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 用户
|
// 后台用户
|
||||||
userGroup := adminGroup.Group("/user")
|
userGroup := adminGroup.Group("/user")
|
||||||
{
|
{
|
||||||
// 获取用户列表-分页
|
// 获取用户列表-分页
|
||||||
@ -504,4 +504,82 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 财务管理
|
||||||
|
financeGroup := adminGroup.Group("/finance")
|
||||||
|
{
|
||||||
|
// 提现记录
|
||||||
|
withdrawalGroup := financeGroup.Group("/withdrawal")
|
||||||
|
{
|
||||||
|
// 获取提现列表-分页
|
||||||
|
withdrawalGroup.GET("", api.OrderPrescription.GetOrderPrescriptionPage)
|
||||||
|
|
||||||
|
// 提现详情
|
||||||
|
withdrawalGroup.GET("/:withdrawal_id", api.OrderPrescription.GetOrderPrescriptionPage)
|
||||||
|
|
||||||
|
// 提现详情-关联订单列表-分页
|
||||||
|
withdrawalGroup.GET("/order/:withdrawal_id", api.OrderPrescription.GetOrderPrescriptionPage)
|
||||||
|
|
||||||
|
// 修改提现个人所得税
|
||||||
|
withdrawalGroup.PUT("/income/:withdrawal_id", api.OrderPrescription.GetOrderPrescriptionPage)
|
||||||
|
|
||||||
|
// 修改提现审核状态
|
||||||
|
withdrawalGroup.PUT("/examine/:withdrawal_id", api.OrderPrescription.GetOrderPrescriptionPage)
|
||||||
|
|
||||||
|
// 修改打款审核状态
|
||||||
|
withdrawalGroup.PUT("/payment/:withdrawal_id", api.OrderPrescription.GetOrderPrescriptionPage)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 银行卡管理
|
||||||
|
bankGroup := financeGroup.Group("/bank")
|
||||||
|
{
|
||||||
|
// 获取银行卡列表-分页
|
||||||
|
bankGroup.GET("", api.OrderPrescription.GetOrderPrescriptionPage)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ca管理
|
||||||
|
caGroup := adminGroup.Group("/ca")
|
||||||
|
{
|
||||||
|
// 云证书
|
||||||
|
certGroup := caGroup.Group("/cert")
|
||||||
|
{
|
||||||
|
// 用户
|
||||||
|
userGroup := certGroup.Group("/user")
|
||||||
|
{
|
||||||
|
// 更新云证书-个人
|
||||||
|
userGroup.GET("/renew/:user_id", api.OrderPrescription.GetOrderPrescriptionPage)
|
||||||
|
|
||||||
|
// 注销云证书-个人
|
||||||
|
userGroup.PUT("/remove/:user_id", api.OrderPrescription.GetOrderPrescriptionPage)
|
||||||
|
|
||||||
|
// 申请云证书-个人
|
||||||
|
userGroup.GET("/:user_id", api.UserCaCert.GetUserCloudCert)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 医院
|
||||||
|
hospitalGroup := certGroup.Group("/hospital")
|
||||||
|
{
|
||||||
|
// 更新云证书-个人
|
||||||
|
hospitalGroup.GET("/renew/:user_id", api.OrderPrescription.GetOrderPrescriptionPage)
|
||||||
|
|
||||||
|
// 注销云证书-个人
|
||||||
|
hospitalGroup.PUT("/remove/:user_id", api.OrderPrescription.GetOrderPrescriptionPage)
|
||||||
|
|
||||||
|
// 申请云证书-个人
|
||||||
|
hospitalGroup.GET("/:user_id", api.UserCaCert.GetUserCloudCert)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 签章
|
||||||
|
signGroup := caGroup.Group("/sign")
|
||||||
|
{
|
||||||
|
// 申请
|
||||||
|
signGroup.GET("/renew/:user_id", api.OrderPrescription.GetOrderPrescriptionPage)
|
||||||
|
|
||||||
|
// 更新
|
||||||
|
signGroup.GET("/:user_id", api.OrderPrescription.GetOrderPrescriptionPage)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
257
api/service/UserCaCert.go
Normal file
257
api/service/UserCaCert.go
Normal file
@ -0,0 +1,257 @@
|
|||||||
|
package service
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
"hospital-admin-api/api/dao"
|
||||||
|
"hospital-admin-api/api/model"
|
||||||
|
"hospital-admin-api/extend/ca"
|
||||||
|
"strconv"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type UserCaCertService struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUserCloudCert 申请云证书-个人
|
||||||
|
func (r *UserCaCertService) GetUserCloudCert(tx *gorm.DB, userId int64) (bool, error) {
|
||||||
|
userCaCertDao := dao.UserCaCert{}
|
||||||
|
|
||||||
|
// 检测是否存在云证书
|
||||||
|
maps := make(map[string]interface{})
|
||||||
|
maps["user_id"] = userId
|
||||||
|
maps["type"] = 2
|
||||||
|
userCaCert, _ := userCaCertDao.GetUserCaCert(maps)
|
||||||
|
if userCaCert != nil {
|
||||||
|
return false, errors.New("医生存在正常使用的云证书,请注销后重新申请")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取用户数据
|
||||||
|
userDao := dao.UserDao{}
|
||||||
|
user, err := userDao.GetUserById(userId)
|
||||||
|
if err != nil || user == nil {
|
||||||
|
return false, errors.New("用户数据错误")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 定义所需变量
|
||||||
|
var departmentCustomId int64 // 自定义科室id
|
||||||
|
var cardName string // 身份证名称
|
||||||
|
var cardNum string // 身份证号码
|
||||||
|
|
||||||
|
// 医生
|
||||||
|
if user.UserType == 2 {
|
||||||
|
// 获取医生数据
|
||||||
|
userDoctorDao := dao.UserDoctorDao{}
|
||||||
|
userDoctor, err := userDoctorDao.GetUserDoctorByUserId(userId)
|
||||||
|
if err != nil || userDoctor == nil {
|
||||||
|
return false, errors.New("医生数据错误")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取医生详情数据
|
||||||
|
userDoctorInfoDao := dao.UserDoctorInfoDao{}
|
||||||
|
userDoctorInfo, err := userDoctorInfoDao.GetUserDoctorInfoByDoctorId(userDoctor.DoctorId)
|
||||||
|
if err != nil || userDoctorInfo == nil {
|
||||||
|
return false, errors.New("医生详情数据错误")
|
||||||
|
}
|
||||||
|
|
||||||
|
if userDoctor.IdenAuthStatus != 1 {
|
||||||
|
return false, errors.New("请先通过身份认证")
|
||||||
|
}
|
||||||
|
|
||||||
|
if userDoctor.MultiPointStatus != 1 {
|
||||||
|
return false, errors.New("请先完成多点执业认证")
|
||||||
|
}
|
||||||
|
|
||||||
|
departmentCustomId = userDoctor.DepartmentCustomId // 自定义科室id
|
||||||
|
cardName = userDoctorInfo.CardName // 身份证名称
|
||||||
|
cardNum = userDoctorInfo.CardNum // 身份证号码
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取自定义科室数据
|
||||||
|
hospitalDepartmentCustomDao := dao.HospitalDepartmentCustomDao{}
|
||||||
|
hospitalDepartmentCustom, err := hospitalDepartmentCustomDao.GetHospitalDepartmentCustomById(departmentCustomId)
|
||||||
|
if err != nil || hospitalDepartmentCustom == nil {
|
||||||
|
return false, errors.New("科室错误")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取标准科室数据
|
||||||
|
hospitalDepartmentDao := dao.HospitalDepartment{}
|
||||||
|
hospitalDepartment, err := hospitalDepartmentDao.GetHospitalDepartmentById(hospitalDepartmentCustom.DepartmentId)
|
||||||
|
if err != nil || hospitalDepartment == nil {
|
||||||
|
return false, errors.New("科室错误")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 申请云证书
|
||||||
|
cloudCertRequestData := &ca.AddCloudCertRequest{
|
||||||
|
EntityId: fmt.Sprintf("%d", userId),
|
||||||
|
EntityType: "Personal",
|
||||||
|
PersonalPhone: user.Mobile,
|
||||||
|
PersonalName: cardName,
|
||||||
|
PersonalIdNumber: cardNum,
|
||||||
|
OrgName: "",
|
||||||
|
OrgNumber: "",
|
||||||
|
Pin: fmt.Sprintf("%d", userId),
|
||||||
|
OrgDept: hospitalDepartment.DepartmentName, // // 卫生证书:医院部门
|
||||||
|
Province: "四川省",
|
||||||
|
Locality: "成都市",
|
||||||
|
AuthType: "实人认证",
|
||||||
|
AuthTime: strconv.FormatInt(time.Now().Unix(), 10),
|
||||||
|
AuthResult: "认证通过",
|
||||||
|
AuthNoticeType: "数字证书申请告知",
|
||||||
|
}
|
||||||
|
|
||||||
|
cloudCertResponse, err := ca.AddCloudCert(cloudCertRequestData)
|
||||||
|
if err != nil || cloudCertResponse == nil {
|
||||||
|
return false, errors.New(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增ca监管证书表
|
||||||
|
userCaCert = &model.UserCaCert{
|
||||||
|
UserId: &userId,
|
||||||
|
IsSystem: 0,
|
||||||
|
IsLatest: 1,
|
||||||
|
Type: 2,
|
||||||
|
CertBase64: cloudCertResponse.CertBase64,
|
||||||
|
CertChainP7: cloudCertResponse.CertP7,
|
||||||
|
CertSerialNumber: cloudCertResponse.CertSerialnumber,
|
||||||
|
CaPin: fmt.Sprintf("%d", userId),
|
||||||
|
IsSignConfig: 0,
|
||||||
|
SignConfig: "",
|
||||||
|
CertApplicationTime: model.LocalTime(time.Now()),
|
||||||
|
CertExpireTime: model.LocalTime(time.Now().AddDate(0, 0, 180)), // 180天以后的时间
|
||||||
|
}
|
||||||
|
|
||||||
|
userCaCert, err = userCaCertDao.AddUserCaCert(tx, userCaCert)
|
||||||
|
if err != nil || userCaCert == nil {
|
||||||
|
return false, errors.New(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// EditUserCloudCert 修改云证书-个人
|
||||||
|
func (r *UserCaCertService) EditUserCloudCert(tx *gorm.DB, userId int64) (bool, error) {
|
||||||
|
userCaCertDao := dao.UserCaCert{}
|
||||||
|
|
||||||
|
// 检测是否存在云证书
|
||||||
|
maps := make(map[string]interface{})
|
||||||
|
maps["user_id"] = userId
|
||||||
|
maps["type"] = 2
|
||||||
|
userCaCert, _ := userCaCertDao.GetUserCaCert(maps)
|
||||||
|
if userCaCert == nil {
|
||||||
|
return false, errors.New("用户未申请云证书,无法修改")
|
||||||
|
}
|
||||||
|
|
||||||
|
if userCaCert.IsLatest == 1 {
|
||||||
|
return false, errors.New("用户云证书为最新证书,无法修改")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取用户数据
|
||||||
|
userDao := dao.UserDao{}
|
||||||
|
user, err := userDao.GetUserById(userId)
|
||||||
|
if err != nil || user == nil {
|
||||||
|
return false, errors.New("用户数据错误")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 定义所需变量
|
||||||
|
var departmentCustomId int64 // 自定义科室id
|
||||||
|
var cardName string // 身份证名称
|
||||||
|
var cardNum string // 身份证号码
|
||||||
|
|
||||||
|
// 医生
|
||||||
|
if user.UserType == 2 {
|
||||||
|
// 获取医生数据
|
||||||
|
userDoctorDao := dao.UserDoctorDao{}
|
||||||
|
userDoctor, err := userDoctorDao.GetUserDoctorByUserId(userId)
|
||||||
|
if err != nil || userDoctor == nil {
|
||||||
|
return false, errors.New("医生数据错误")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取医生详情数据
|
||||||
|
userDoctorInfoDao := dao.UserDoctorInfoDao{}
|
||||||
|
userDoctorInfo, err := userDoctorInfoDao.GetUserDoctorInfoByDoctorId(userDoctor.DoctorId)
|
||||||
|
if err != nil || userDoctorInfo == nil {
|
||||||
|
return false, errors.New("医生详情数据错误")
|
||||||
|
}
|
||||||
|
|
||||||
|
if userDoctor.IdenAuthStatus != 1 {
|
||||||
|
return false, errors.New("请先通过身份认证")
|
||||||
|
}
|
||||||
|
|
||||||
|
if userDoctor.MultiPointStatus != 1 {
|
||||||
|
return false, errors.New("请先完成多点执业认证")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检测是否存在正在审核中的处方
|
||||||
|
orderPrescriptionDao := dao.OrderPrescriptionDao{}
|
||||||
|
|
||||||
|
maps := make(map[string]interface{})
|
||||||
|
maps["doctor_id"] = userDoctor.DoctorId
|
||||||
|
maps["prescription_status"] = 1
|
||||||
|
orderPrescription, err := orderPrescriptionDao.GetList(maps)
|
||||||
|
if err != nil {
|
||||||
|
return false, errors.New("更新云证书失败")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(orderPrescription) > 0 {
|
||||||
|
return false, errors.New("存在审核中的处方,请勿更新云证书")
|
||||||
|
}
|
||||||
|
|
||||||
|
departmentCustomId = userDoctor.DepartmentCustomId // 自定义科室id
|
||||||
|
cardName = userDoctorInfo.CardName // 身份证名称
|
||||||
|
cardNum = userDoctorInfo.CardNum // 身份证号码
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取自定义科室数据
|
||||||
|
hospitalDepartmentCustomDao := dao.HospitalDepartmentCustomDao{}
|
||||||
|
hospitalDepartmentCustom, err := hospitalDepartmentCustomDao.GetHospitalDepartmentCustomById(departmentCustomId)
|
||||||
|
if err != nil || hospitalDepartmentCustom == nil {
|
||||||
|
return false, errors.New("科室错误")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取标准科室数据
|
||||||
|
hospitalDepartmentDao := dao.HospitalDepartment{}
|
||||||
|
hospitalDepartment, err := hospitalDepartmentDao.GetHospitalDepartmentById(hospitalDepartmentCustom.DepartmentId)
|
||||||
|
if err != nil || hospitalDepartment == nil {
|
||||||
|
return false, errors.New("科室错误")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改云证书
|
||||||
|
cloudCertRequestData := &ca.EditCloudCertRequestData{
|
||||||
|
EntityId: fmt.Sprintf("%d", userId),
|
||||||
|
EntityType: "Personal",
|
||||||
|
PersonalPhone: user.Mobile,
|
||||||
|
PersonalName: cardName,
|
||||||
|
PersonalIdNumber: cardNum,
|
||||||
|
OrgName: "",
|
||||||
|
OrgNumber: "",
|
||||||
|
Pin: fmt.Sprintf("%d", userId),
|
||||||
|
OrgDept: hospitalDepartment.DepartmentName, // // 卫生证书:医院部门
|
||||||
|
Province: "四川省",
|
||||||
|
Locality: "成都市",
|
||||||
|
AuthType: "实人认证",
|
||||||
|
AuthTime: strconv.FormatInt(time.Now().Unix(), 10),
|
||||||
|
AuthResult: "认证通过",
|
||||||
|
AuthNoticeType: "数字证书变更告知",
|
||||||
|
}
|
||||||
|
|
||||||
|
cloudCertResponse, err := ca.EditCloudCert(cloudCertRequestData)
|
||||||
|
if err != nil || cloudCertResponse == nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return false, errors.New(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改ca监管证书表
|
||||||
|
data := make(map[string]interface{})
|
||||||
|
data["cert_base64"] = cloudCertResponse.CertBase64
|
||||||
|
data["cert_chain_p7"] = cloudCertResponse.CertP7
|
||||||
|
data["cert_serial_number"] = cloudCertResponse.CertSerialnumber
|
||||||
|
err = userCaCertDao.EditUserCaCertById(tx, userCaCert.CertId, data)
|
||||||
|
if err != nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return false, errors.New("审核失败")
|
||||||
|
}
|
||||||
|
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
@ -90,9 +90,19 @@ func (r *UserDoctorService) PutUserDoctor(doctorId int64, req requests.PutUserDo
|
|||||||
doctorBankCardDao := dao.DoctorBankCardDao{}
|
doctorBankCardDao := dao.DoctorBankCardDao{}
|
||||||
doctorBankCard, _ := doctorBankCardDao.GetDoctorBankCardByDoctorId(doctorId)
|
doctorBankCard, _ := doctorBankCardDao.GetDoctorBankCardByDoctorId(doctorId)
|
||||||
|
|
||||||
|
// 获取医生云证书
|
||||||
|
userCaCertDao := dao.UserCaCert{}
|
||||||
|
|
||||||
|
maps := make(map[string]interface{})
|
||||||
|
maps["user_id"] = userDoctor.UserId
|
||||||
|
maps["type"] = 2
|
||||||
|
maps["is_latest"] = 1
|
||||||
|
userCaCert, _ := userCaCertDao.GetUserCaCert(maps)
|
||||||
|
|
||||||
userDoctorData := make(map[string]interface{}) // 医生数据
|
userDoctorData := make(map[string]interface{}) // 医生数据
|
||||||
userDoctorInfoData := make(map[string]interface{}) // 医生详情数据
|
userDoctorInfoData := make(map[string]interface{}) // 医生详情数据
|
||||||
userData := make(map[string]interface{}) // 用户数据
|
userData := make(map[string]interface{}) // 用户数据
|
||||||
|
userCaCertData := make(map[string]interface{}) // 用户云证书
|
||||||
|
|
||||||
// 处理头像
|
// 处理头像
|
||||||
avatar := utils.RemoveOssDomain(req.Avatar)
|
avatar := utils.RemoveOssDomain(req.Avatar)
|
||||||
@ -317,13 +327,16 @@ func (r *UserDoctorService) PutUserDoctor(doctorId int64, req requests.PutUserDo
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return false, errors.New("修改失败")
|
return false, errors.New("修改失败")
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(orderPrescription) > 0 {
|
if len(orderPrescription) > 0 {
|
||||||
return false, errors.New("存在审核中的处方,请勿修改科室数据")
|
return false, errors.New("存在审核中的处方,请勿修改科室数据")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if userCaCert != nil {
|
||||||
|
userCaCertData["is_latest"] = 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 审核失败、未审核情况下,如果数据存在修改,进入待审核
|
// 审核失败、未审核情况下,如果数据存在修改,重新进入待审核
|
||||||
if userDoctor.MultiPointStatus == 0 || userDoctor.MultiPointStatus == 3 {
|
if userDoctor.MultiPointStatus == 0 || userDoctor.MultiPointStatus == 3 {
|
||||||
if signImage != userDoctorInfo.SignImage || idCardBack != userDoctorInfo.IdCardBack || idCardFront != userDoctorInfo.IdCardFront {
|
if signImage != userDoctorInfo.SignImage || idCardBack != userDoctorInfo.IdCardBack || idCardFront != userDoctorInfo.IdCardFront {
|
||||||
userDoctorData["multi_point_status"] = 2
|
userDoctorData["multi_point_status"] = 2
|
||||||
@ -341,7 +354,7 @@ func (r *UserDoctorService) PutUserDoctor(doctorId int64, req requests.PutUserDo
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(orderPrescription) > 0 {
|
if len(orderPrescription) > 0 {
|
||||||
return false, errors.New("存在审核中的处方,请勿修改科室数据")
|
return false, errors.New("存在审核中的处方,请勿修改签名及身份证数据")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -551,7 +564,7 @@ func (r *UserDoctorService) PutUserDoctor(doctorId int64, req requests.PutUserDo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改医生银行卡数据
|
// 修改医生银行卡数据-新增
|
||||||
if doctorBankCard == nil {
|
if doctorBankCard == nil {
|
||||||
if provinceId != 0 && cityId != 0 && countyId != 0 && bankId != 0 && bankCardCode != "" {
|
if provinceId != 0 && cityId != 0 && countyId != 0 && bankId != 0 && bankCardCode != "" {
|
||||||
// 新增医生银行卡表
|
// 新增医生银行卡表
|
||||||
@ -582,6 +595,7 @@ func (r *UserDoctorService) PutUserDoctor(doctorId int64, req requests.PutUserDo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 修改医生银行卡数据-修改
|
||||||
if doctorBankCard != nil {
|
if doctorBankCard != nil {
|
||||||
// 修改
|
// 修改
|
||||||
doctorBankCardData := make(map[string]interface{}) // 医生银行卡数据
|
doctorBankCardData := make(map[string]interface{}) // 医生银行卡数据
|
||||||
@ -618,6 +632,15 @@ func (r *UserDoctorService) PutUserDoctor(doctorId int64, req requests.PutUserDo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 修改医生云证书状态
|
||||||
|
if len(userCaCertData) > 0 && userCaCert != nil {
|
||||||
|
err = userCaCertDao.EditUserCaCertById(tx, userCaCert.CertId, userCaCertData)
|
||||||
|
if err != nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return false, errors.New("用户云证书修改失败")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 判断头像是否修改,同步修改im
|
// 判断头像是否修改,同步修改im
|
||||||
if userDoctor.Avatar != avatar {
|
if userDoctor.Avatar != avatar {
|
||||||
profileItem := []tencentIm.ProfileItem{
|
profileItem := []tencentIm.ProfileItem{
|
||||||
@ -1391,20 +1414,6 @@ func (r *UserDoctorService) PutMulti(doctorId int64, req requests.PutMulti) (boo
|
|||||||
return false, errors.New("医生数据错误")
|
return false, errors.New("医生数据错误")
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取医生详情数据
|
|
||||||
userDoctorInfoDao := dao.UserDoctorInfoDao{}
|
|
||||||
userDoctorInfo, err := userDoctorInfoDao.GetUserDoctorInfoByDoctorId(doctorId)
|
|
||||||
if err != nil {
|
|
||||||
return false, errors.New("医生详情数据错误")
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取用户数据
|
|
||||||
userDao := dao.UserDao{}
|
|
||||||
user, err := userDao.GetUserById(userDoctor.UserId)
|
|
||||||
if err != nil || user == nil {
|
|
||||||
return false, errors.New("医生数据错误")
|
|
||||||
}
|
|
||||||
|
|
||||||
if userDoctor.MultiPointStatus == 1 {
|
if userDoctor.MultiPointStatus == 1 {
|
||||||
return false, errors.New("已审核成功,无法进行操作")
|
return false, errors.New("已审核成功,无法进行操作")
|
||||||
}
|
}
|
||||||
@ -1413,8 +1422,6 @@ func (r *UserDoctorService) PutMulti(doctorId int64, req requests.PutMulti) (boo
|
|||||||
return false, errors.New("请先通过身份认证")
|
return false, errors.New("请先通过身份认证")
|
||||||
}
|
}
|
||||||
|
|
||||||
userDoctorData := make(map[string]interface{}) // 医生数据
|
|
||||||
|
|
||||||
if userDoctor.MultiPointStatus == req.MultiPointStatus {
|
if userDoctor.MultiPointStatus == req.MultiPointStatus {
|
||||||
return false, errors.New("请勿重复操作")
|
return false, errors.New("请勿重复操作")
|
||||||
}
|
}
|
||||||
@ -1427,114 +1434,38 @@ func (r *UserDoctorService) PutMulti(doctorId int64, req requests.PutMulti) (boo
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// 检测是否存在云证书
|
// 云证书处理
|
||||||
userCaCertDao := dao.UserCaCert{}
|
if req.MultiPointStatus == 1 && config.C.Env == "prod" {
|
||||||
userCaCert, _ := userCaCertDao.GetUserCaCertByUserId(userDoctor.UserId)
|
userCaCertService := UserCaCertService{}
|
||||||
|
|
||||||
// 获取自定义科室数据
|
// 检测是否存在云证书
|
||||||
hospitalDepartmentCustomDao := dao.HospitalDepartmentCustomDao{}
|
userCaCertDao := dao.UserCaCert{}
|
||||||
hospitalDepartmentCustom, err := hospitalDepartmentCustomDao.GetHospitalDepartmentCustomById(userDoctor.DepartmentCustomId)
|
|
||||||
if err != nil || hospitalDepartmentCustom == nil {
|
|
||||||
tx.Rollback()
|
|
||||||
return false, errors.New("科室错误")
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取标准科室数据
|
maps := make(map[string]interface{})
|
||||||
hospitalDepartmentDao := dao.HospitalDepartment{}
|
maps["user_id"] = userDoctor.UserId
|
||||||
hospitalDepartment, err := hospitalDepartmentDao.GetHospitalDepartmentById(hospitalDepartmentCustom.DepartmentId)
|
maps["type"] = 2
|
||||||
if err != nil || hospitalDepartment == nil {
|
maps["is_latest"] = 1
|
||||||
tx.Rollback()
|
userCaCert, _ := userCaCertDao.GetUserCaCert(maps)
|
||||||
return false, errors.New("科室错误")
|
if userCaCert == nil {
|
||||||
}
|
// 申请云证书
|
||||||
|
_, err = userCaCertService.GetUserCloudCert(tx, userDoctor.UserId)
|
||||||
// 处理审核通过的情况
|
if err != nil {
|
||||||
if config.C.Env == "prod" {
|
tx.Rollback()
|
||||||
if req.MultiPointStatus == 1 {
|
return false, errors.New(err.Error())
|
||||||
if userCaCert == nil {
|
}
|
||||||
// 申请云证书
|
} else {
|
||||||
cloudCertRequestData := &ca.AddCloudCertRequest{
|
if userCaCert.IsLatest == 0 {
|
||||||
EntityId: strconv.FormatInt(userDoctor.UserId, 10),
|
_, err = userCaCertService.EditUserCloudCert(tx, userDoctor.UserId)
|
||||||
EntityType: "Personal",
|
|
||||||
PersonalPhone: user.Mobile,
|
|
||||||
PersonalName: userDoctorInfo.CardName,
|
|
||||||
PersonalIdNumber: userDoctorInfo.CardNum,
|
|
||||||
OrgName: "",
|
|
||||||
OrgNumber: "",
|
|
||||||
Pin: strconv.FormatInt(userDoctor.UserId, 10),
|
|
||||||
OrgDept: hospitalDepartment.DepartmentName, // // 卫生证书:医院部门
|
|
||||||
Province: "四川省",
|
|
||||||
Locality: "成都市",
|
|
||||||
AuthType: "实人认证",
|
|
||||||
AuthTime: strconv.FormatInt(time.Now().Unix(), 10),
|
|
||||||
AuthResult: "认证通过",
|
|
||||||
AuthNoticeType: "数字证书申请告知",
|
|
||||||
}
|
|
||||||
|
|
||||||
cloudCertResponse, err := ca.AddCloudCert(cloudCertRequestData)
|
|
||||||
if err != nil || cloudCertResponse == nil {
|
|
||||||
tx.Rollback()
|
|
||||||
return false, errors.New(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
// 新增ca监管证书表
|
|
||||||
userCaCert := &model.UserCaCert{
|
|
||||||
UserId: &userDoctor.UserId,
|
|
||||||
IsSystem: 0,
|
|
||||||
Type: 2,
|
|
||||||
CertBase64: cloudCertResponse.CertBase64,
|
|
||||||
CertChainP7: cloudCertResponse.CertP7,
|
|
||||||
CertSerialNumber: cloudCertResponse.CertSerialnumber,
|
|
||||||
CaPin: strconv.FormatInt(userDoctor.UserId, 10),
|
|
||||||
IsSignConfig: 0,
|
|
||||||
SignConfig: "",
|
|
||||||
}
|
|
||||||
|
|
||||||
userCaCert, err = userCaCertDao.AddUserCaCert(tx, userCaCert)
|
|
||||||
if err != nil || userCaCert == nil {
|
|
||||||
tx.Rollback()
|
|
||||||
return false, errors.New(err.Error())
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 修改云证书
|
|
||||||
cloudCertRequestData := &ca.EditCloudCertRequestData{
|
|
||||||
EntityId: strconv.FormatInt(userDoctor.UserId, 10),
|
|
||||||
EntityType: "Personal",
|
|
||||||
PersonalPhone: user.Mobile,
|
|
||||||
PersonalName: userDoctorInfo.CardName,
|
|
||||||
PersonalIdNumber: userDoctorInfo.CardNum,
|
|
||||||
OrgName: "",
|
|
||||||
OrgNumber: "",
|
|
||||||
Pin: strconv.FormatInt(userDoctor.UserId, 10),
|
|
||||||
OrgDept: hospitalDepartment.DepartmentName, // // 卫生证书:医院部门
|
|
||||||
Province: "四川省",
|
|
||||||
Locality: "成都市",
|
|
||||||
AuthType: "实人认证",
|
|
||||||
AuthTime: strconv.FormatInt(time.Now().Unix(), 10),
|
|
||||||
AuthResult: "认证通过",
|
|
||||||
AuthNoticeType: "数字证书变更告知",
|
|
||||||
}
|
|
||||||
|
|
||||||
cloudCertResponse, err := ca.EditCloudCert(cloudCertRequestData)
|
|
||||||
if err != nil || cloudCertResponse == nil {
|
|
||||||
tx.Rollback()
|
|
||||||
return false, errors.New(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
// 修改ca监管证书表
|
|
||||||
userCaCertDao := dao.UserCaCert{}
|
|
||||||
data := make(map[string]interface{})
|
|
||||||
data["cert_base64"] = cloudCertResponse.CertBase64
|
|
||||||
data["cert_chain_p7"] = cloudCertResponse.CertP7
|
|
||||||
data["cert_serial_number"] = cloudCertResponse.CertSerialnumber
|
|
||||||
err = userCaCertDao.EditUserCaCertById(tx, userCaCert.CertId, data)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
return false, errors.New("审核失败")
|
return false, errors.New(err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 医生修改数据
|
||||||
|
userDoctorData := make(map[string]interface{})
|
||||||
userDoctorData["multi_point_time"] = time.Now().Format("2006-01-02 15:04:05")
|
userDoctorData["multi_point_time"] = time.Now().Format("2006-01-02 15:04:05")
|
||||||
|
|
||||||
// 审核不通过
|
// 审核不通过
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user