diff --git a/api/controller/export.go b/api/controller/export.go index 596d292..0cb0d7b 100644 --- a/api/controller/export.go +++ b/api/controller/export.go @@ -80,3 +80,39 @@ func (r *Export) DoctorWithdrawalOrder(c *gin.Context) { responses.OkWithData(ossAddress, c) } + +// UserDoctor 医生列表 +func (r *Export) UserDoctor(c *gin.Context) { + userDoctorRequest := requests.UserDoctorRequest{} + req := userDoctorRequest.UserDoctorExportList + + if err := c.ShouldBind(&req); err != nil { + responses.FailWithMessage(err.Error(), c) + return + } + + // 参数验证 + if err := global.Validate.Struct(req); err != nil { + responses.FailWithMessage(utils.Translate(err), c) + return + } + + // 获取数据 + userDoctorDao := dao.UserDoctorDao{} + userDoctors, err := userDoctorDao.GetUserDoctorExportListSearch(req) + + if err != nil { + responses.FailWithMessage(err.Error(), c) + return + } + + // 业务处理 + exportService := service.ExportService{} + ossAddress, err := exportService.UserDoctor(userDoctors) + if err != nil { + responses.FailWithMessage(err.Error(), c) + return + } + + responses.OkWithData(ossAddress, c) +} diff --git a/api/dao/userDoctor.go b/api/dao/userDoctor.go index 74ff45a..70940ce 100644 --- a/api/dao/userDoctor.go +++ b/api/dao/userDoctor.go @@ -1,12 +1,14 @@ package dao import ( + "errors" "gorm.io/gorm" "gorm.io/gorm/clause" "hospital-admin-api/api/model" "hospital-admin-api/api/requests" "hospital-admin-api/global" "strings" + "time" ) type UserDoctorDao struct { @@ -174,44 +176,20 @@ func (r *UserDoctorDao) GetUserDoctorPageSearch(req requests.GetUserDoctorPage, query = query.Where("doctor_title = ?", req.DoctorTitle) } - // // 问诊类型 - // if req.InquiryService != "" { - // result := strings.Split(req.InquiryService, ",") - // if len(result) > 0 { - // subQuery := global.Db - // for _, v := range result { - // if v == "1" { - // subQuery = subQuery.Where("is_img_expert_reception = ?", 1) - // } - // - // if v == "2" { - // if subQuery != nil { - // subQuery = subQuery.Or("is_img_quick_reception = ?", 1) - // } else { - // subQuery = subQuery.Where("is_img_quick_reception = ?", 1) - // } - // } - // - // if v == "3" { - // if subQuery != nil { - // subQuery = subQuery.Or("is_img_welfare_reception = ?", 1) - // } else { - // subQuery = subQuery.Where("is_img_welfare_reception = ?", 1) - // } - // } - // - // if v == "4" { - // if subQuery != nil { - // subQuery = subQuery.Or("multi_point_status = ?", 1) - // } else { - // subQuery = subQuery.Where("multi_point_status = ?", 1) - // } - // } - // - // } - // query = query.Where(subQuery) - // } - // } + // 注册时间 + if req.CreatedAt != "" { + createdAt := strings.Split(req.CreatedAt, "&") + if len(createdAt) == 2 { + startTime, _ := time.Parse("2006-01-02", createdAt[0]) + endTime, _ := time.Parse("2006-01-02", createdAt[1]) + + if startTime == endTime { + endTime = endTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second) + } + + query = query.Where("created_at BETWEEN ? AND ?", startTime, endTime) + } + } // 排序 query = query.Order("created_at desc") @@ -435,3 +413,145 @@ func (r *UserDoctorDao) GetUserDoctorListSearch(req requests.GetUserDoctorList) } return m, nil } + +// GetUserDoctorExportListSearch 医生列表-导出 +func (r *UserDoctorDao) GetUserDoctorExportListSearch(req requests.UserDoctorExportList) (m []*model.UserDoctor, err error) { + // 构建查询条件 + query := global.Db.Model(&model.UserDoctor{}).Omit("open_id", "union_id", "wx_session_key") + + // 用户 + query = query.Preload("User", func(db *gorm.DB) *gorm.DB { + return db.Omit("user_password", "salt") + }) + + // 医生详情 + query = query.Preload("UserDoctorInfo") + + // 医院 + query = query.Preload("Hospital", func(db *gorm.DB) *gorm.DB { + return db.Select("hospital_id,hospital_name,hospital_level_name") + }) + + // 医生问诊配置 + query = query.Preload("DoctorInquiryConfig") + + // 当前搜索数据 + if req.Type == 1 { + // 医生问诊配置 + if req.InquiryService != "" { + result := strings.Split(req.InquiryService, ",") + if len(result) > 0 { + subQuery := global.Db.Model(&model.DoctorInquiryConfig{}). + Where("gdxz_doctor_inquiry_config.doctor_id = gdxz_user_doctor.doctor_id"). + Where("gdxz_doctor_inquiry_config.inquiry_type IN (?)", req.InquiryService). + Where("gdxz_doctor_inquiry_config.inquiry_mode = ?", 1). + Where("gdxz_doctor_inquiry_config.is_enable = ?", 1).Select("1") + + query = query.Where("EXISTS (?)", subQuery) + } + } + + // 手机号 + if req.Mobile != "" { + subQuery := global.Db.Model(&model.User{}). + Select("user_id"). + Where("mobile LIKE ?", "%"+req.Mobile+"%") + + query = query.Where(gorm.Expr("user_id IN (?)", subQuery)) + } + + // 用户名称 + if req.UserName != "" { + query = query.Where("user_name LIKE ?", "%"+req.UserName+"%") + } + + // 状态 + if req.UserStatus != nil { + query = query.Where("status = ?", req.UserStatus) + } + + // 医院名称 + if req.HospitalName != "" { + subQuery := global.Db.Model(&model.Hospital{}). + Select("hospital_id"). + Where("hospital_name LIKE ?", "%"+req.HospitalName+"%") + + query = query.Where(gorm.Expr("hospital_id IN (?)", subQuery)) + } + + // 科室名称 + if req.DepartmentCustomName != "" { + query = query.Where("department_custom_name = ?", req.DepartmentCustomName) + } + + // 实名认证状态 + if req.IDCardStatus != nil { + query = query.Where("idcard_status = ?", req.IDCardStatus) + } + + // 身份认证状态 + if req.IdenAuthStatus != nil { + query = query.Where("iden_auth_status = ?", req.IdenAuthStatus) + } + + // 医生多点执业认证状态 + if req.MultiPointStatus != nil { + query = query.Where("multi_point_status = ?", req.MultiPointStatus) + } + + // 是否首页推荐 + if req.IsRecommend != nil { + query = query.Where("is_recommend = ?", req.IsRecommend) + } + + if req.DoctorTitle != nil { + query = query.Where("doctor_title = ?", req.DoctorTitle) + } + + // 注册时间 + if req.CreatedAt != "" { + createdAt := strings.Split(req.CreatedAt, "&") + if len(createdAt) == 2 { + startTime, _ := time.Parse("2006-01-02", createdAt[0]) + endTime, _ := time.Parse("2006-01-02", createdAt[1]) + + if startTime == endTime { + endTime = endTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second) + } + + query = query.Where("created_at BETWEEN ? AND ?", startTime, endTime) + } + } + } + + // 当前选择数据 + if req.Type == 2 { + if req.Id == "" { + return nil, errors.New("未提供需导出数据编号") + } + + id := strings.Split(req.Id, ",") + query = query.Where("doctor_id IN (?)", id) + } + + // 排序 + query = query.Order("created_at desc") + + if req.IsEnterpriseDeepCooperation != nil { + query = query.Where("is_enterprise_deep_cooperation = ?", req.IsEnterpriseDeepCooperation) + } + + if req.IsPlatformDeepCooperation != nil { + query = query.Where("is_platform_deep_cooperation = ?", req.IsPlatformDeepCooperation) + } + + if req.IsSysDiagnoCooperation != nil { + query = query.Where("is_sys_diagno_cooperation = ?", req.IsSysDiagnoCooperation) + } + + err = query.Find(&m).Error + if err != nil { + return nil, err + } + return m, nil +} diff --git a/api/dto/UserDoctor.go b/api/dto/UserDoctor.go index 27f7b9d..5459808 100644 --- a/api/dto/UserDoctor.go +++ b/api/dto/UserDoctor.go @@ -171,7 +171,7 @@ func GetUserDoctorListDto(m []*model.UserDoctor) []*UserDoctorDto { } // 加载医生服务类型 - if v.User != nil { + if v.DoctorInquiryConfig != nil { response = response.LoadDoctorInquiryType(v.DoctorInquiryConfig) } else { response.InquiryType = "暂无" diff --git a/api/requests/userDoctor.go b/api/requests/userDoctor.go index 8aee96d..64f9fb2 100644 --- a/api/requests/userDoctor.go +++ b/api/requests/userDoctor.go @@ -10,6 +10,7 @@ type UserDoctorRequest struct { PutMulti // 多点-审核医生 GetUserDoctorList // 获取医生列表 GetUserDoctorBankCardPage // 获取医生银行卡列表-分页 + UserDoctorExportList // 医生列表-导出 } // GetUserDoctorPage 获取医生列表-分页 @@ -30,6 +31,7 @@ type GetUserDoctorPage struct { IsEnterpriseDeepCooperation *int `json:"is_enterprise_deep_cooperation" form:"is_enterprise_deep_cooperation" label:"是否企业深度合作"` // (0:否 1:是) IsPlatformDeepCooperation *int `json:"is_platform_deep_cooperation" form:"is_platform_deep_cooperation" label:"平台深度合作医生"` // 是否平台深度合作医生(0:否 1:是) IsSysDiagnoCooperation *int `json:"is_sys_diagno_cooperation" form:"is_sys_diagno_cooperation" label:"是否先思达合作医生"` // (0:否 1:是) + CreatedAt string `json:"created_at" form:"created_at" label:"注册时间"` } // PutUserDoctor 修改医生 @@ -149,3 +151,24 @@ type GetUserDoctorBankCardPage struct { BankCardCode string `json:"bank_card_code" form:"bank_card_code" label:"银行卡号"` BankName string `json:"bank_name" form:"bank_name" label:"银行名称"` } + +// UserDoctorExportList 医生列表-导出 +type UserDoctorExportList struct { + Type int `json:"type" form:"type" label:"类型" validate:"required,oneof=1 2 3"` // 1:当前搜索数据 2:当前选择数据 3:全部数据 + Id string `json:"id" form:"id" label:"id"` + Mobile string `json:"mobile" form:"mobile" label:"手机号"` + UserName string `json:"user_name" form:"user_name" label:"用户名"` + UserStatus *int `json:"user_status" form:"user_status" label:"用户状态"` // (0:禁用 1:正常 2:删除) + HospitalName string `json:"hospital_name" form:"hospital_name" label:"医院名称"` + DepartmentCustomName string `json:"department_custom_name" form:"department_custom_name" label:"科室名称"` + IDCardStatus *int `json:"idcard_status" form:"idcard_status" label:"身份证状态"` // (0:未认证 1:认证通过 2:认证失败) + IdenAuthStatus *int `json:"iden_auth_status" form:"iden_auth_status" label:"认证状态"` // (0:未认证 1:认证通过 2:审核中 3:认证失败) + MultiPointStatus *int `json:"multi_point_status" form:"multi_point_status" label:"多点执业状态"` // 医生多点执业认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败) + IsRecommend *int `json:"is_recommend" form:"is_recommend" label:"是否推荐"` // (0:否 1:是) + DoctorTitle *int `json:"doctor_title" form:"doctor_title" label:"医生职称"` // (1:主任医师 2:主任中医师 3:副主任医师 4:副主任中医师 5:主治医师 6:住院医师) + InquiryService string `json:"inquiry_service" form:"inquiry_service" label:"问诊服务"` // (1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药) + IsEnterpriseDeepCooperation *int `json:"is_enterprise_deep_cooperation" form:"is_enterprise_deep_cooperation" label:"是否企业深度合作"` // (0:否 1:是) + IsPlatformDeepCooperation *int `json:"is_platform_deep_cooperation" form:"is_platform_deep_cooperation" label:"平台深度合作医生"` // 是否平台深度合作医生(0:否 1:是) + IsSysDiagnoCooperation *int `json:"is_sys_diagno_cooperation" form:"is_sys_diagno_cooperation" label:"是否先思达合作医生"` // (0:否 1:是) + CreatedAt string `json:"created_at" form:"created_at" label:"注册时间"` +} diff --git a/api/router/router.go b/api/router/router.go index 3f5abed..1637870 100644 --- a/api/router/router.go +++ b/api/router/router.go @@ -609,7 +609,7 @@ func privateRouter(r *gin.Engine, api controller.Api) { doctorGroup := exportGroup.Group("/doctor") { // 医生列表 - doctorGroup.POST("", api.UserCaCert.RenewUserCloudCert) + doctorGroup.POST("", api.Export.UserDoctor) // 医生银行卡 doctorGroup.POST("/bank/card", api.UserCaCert.RenewUserCloudCert) diff --git a/api/service/export.go b/api/service/export.go index 8b4aa5b..dc0a88e 100644 --- a/api/service/export.go +++ b/api/service/export.go @@ -8,6 +8,8 @@ import ( "hospital-admin-api/extend/aliyun" "hospital-admin-api/utils" "math/rand" + "strconv" + "strings" "time" ) @@ -37,6 +39,7 @@ type DoctorWithdrawalData struct { CreatedAt time.Time // 创建时间 } +// DoctorWithdrawalOrderData 提现记录-关联订单 type DoctorWithdrawalOrderData struct { DoctorName string // 医生姓名 PatientName string // 患者姓名-就诊人 @@ -55,6 +58,59 @@ type DoctorWithdrawalOrderData struct { } +// UserDoctorData 医生列表 +type UserDoctorData struct { + UserName string // 用户名称 + Status string // 状态(0:禁用 1:正常 2:删除) + IdcardStatus string // 实名认证状态(0:未认证 1:认证通过 2:认证失败) + IdenAuthStatus string // 身份认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败) + IdenAuthTime time.Time // 审核时间 + IdenAuthFailReason string // 身份认证失败原因 + MultiPointStatus string // 医生多点执业认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败) + MultiPointTime time.Time // 审核时间 + MultiPointFailReason string // 多点执业认证失败原因 + IsRecommend string // 是否首页推荐(0:否 1:是) + Avatar string // 头像 + DoctorTitle string // 医生职称(1:主任医师 2:主任中医师 3:副主任医师 4:副主任中医师 5:主治医师 6:住院医师) + DepartmentCustomName string // 科室名称(如未自己输入,填入标准科室名称) + DepartmentCustomMobile string // 科室电话 + HospitalName string // 医院名称 + ServedPatientsNum string // 服务患者数量(订单结束时统计) + PraiseRate float64 // 好评率(百分制。订单平均评价中超过4-5分的订单总数 / 总订单数 * 5) + AvgResponseTime float64 // 平均响应时间(分钟制) + NumberOfFans string // 被关注数量 + IsOnline string // 是否在线(0:不在线 1:在线) + IsPlatformDeepCooperation string // 是否平台深度合作医生(0:否 1:是) + IsEnterpriseDeepCooperation string // 是否企业深度合作医生(0:否 1:是) + IsSysDiagnoCooperation string // 是否先思达合作医生(0:否 1:是) + QrCode string // 分享二维码 + BeGoodAt string // 擅长 + BriefIntroduction string // 医生简介 + CreatedAt time.Time // 创建时间 + Mobile string // 手机号 + Age string // 年龄 + Sex string // 性别(0:未知 1:男 2:女) + RegisterMethod string // 注册方式(1:微信小程序 2:后台添加 ) + CreatedBy string // 创建者 + InquiryType string // 服务类型 + CardType string // 类型(1:身份证 2:护照 3:港澳通行证 4:台胞证);NOT NULL + CardName string // 证件姓名 + CardNum string // 证件号码 + LicenseCert string // 医师执业证(逗号分隔) + QualificationCert string // 医师资格证(逗号分隔) + QualificationCertNum string // 医师资格证号(逗号分隔) + WorkCert string // 医师工作证(逗号分隔) + MultiPointImages string // 多点执业备案信息(逗号分隔) + IdCardFront string // 身份证正面图片 + IdCardBack string // 身份证背面图片 + SignImage string // 签名图片 + CertApplicationTime time.Time // ca证书申请时间 + CertExpireTime time.Time // ca证书过期时间 + BankName string // 开户银行名称 + BankCardCode string // 开户银行卡号 + BankCardAddress string // 开户银行地址 +} + // DoctorWithdrawal 提现记录 func (r *ExportService) DoctorWithdrawal(doctorWithdrawals []*model.DoctorWithdrawal) (string, error) { header := []utils.HeaderCellData{ @@ -81,14 +137,7 @@ func (r *ExportService) DoctorWithdrawal(doctorWithdrawals []*model.DoctorWithdr var interfaceSlice []interface{} for _, v := range doctorWithdrawals { // 审核状态 - examineStatus := "未知" - if v.ExamineStatus == 1 { - examineStatus = "审核中" - } else if v.ExamineStatus == 2 { - examineStatus = "审核通过" - } else if v.ExamineStatus == 3 { - examineStatus = "审核未通过" - } + examineStatus := utils.WithdrawalExamineStatusToString(v.ExamineStatus) // 审核人员 examineBy := "" @@ -250,11 +299,8 @@ func (r *ExportService) DoctorWithdrawalOrder(doctorWithdrawalOrders []*model.Do if v.OrderInquiry != nil { patientName = v.OrderInquiry.PatientName - if v.OrderInquiry.PatientSex == 1 { - patientSex = "男" - } else if v.OrderInquiry.PatientSex == 2 { - patientSex = "女" - } + // 患者性别 + patientSex = utils.SexToString(v.OrderInquiry.PatientSex) // 患者年龄 patientAge = fmt.Sprintf("%d", v.OrderInquiry.PatientAge) @@ -265,32 +311,13 @@ func (r *ExportService) DoctorWithdrawalOrder(doctorWithdrawalOrders []*model.Do } // 支付渠道 - if v.OrderInquiry.InquiryPayChannel == 1 { - payChannel = "小程序支付" - } else if v.OrderInquiry.InquiryPayChannel == 2 { - payChannel = "微信扫码支付" - } else if v.OrderInquiry.InquiryPayChannel == 3 { - payChannel = "模拟支付" - } + payChannel = utils.PayChannelToString(v.OrderInquiry.InquiryPayChannel) inquiryNo = v.OrderInquiry.InquiryNo escrowTradeNo = v.OrderInquiry.EscrowTradeNo - if v.OrderInquiry.InquiryStatus == 1 { - inquiryStatus = "待支付" - } else if v.OrderInquiry.InquiryStatus == 2 { - inquiryStatus = "待分配" - } else if v.OrderInquiry.InquiryStatus == 3 { - inquiryStatus = "待接诊" - } else if v.OrderInquiry.InquiryStatus == 4 { - inquiryStatus = "已接诊" - } else if v.OrderInquiry.InquiryStatus == 5 { - inquiryStatus = "已完成" - } else if v.OrderInquiry.InquiryStatus == 6 { - inquiryStatus = "已结束" - } else if v.OrderInquiry.InquiryStatus == 7 { - inquiryStatus = "已取消" - } + // 问诊订单状态 + inquiryStatus = utils.InquiryStatusToString(v.OrderInquiry.InquiryStatus) amountTotal = v.OrderInquiry.AmountTotal couponAmountTotal = v.OrderInquiry.CouponAmountTotal @@ -347,3 +374,311 @@ func (r *ExportService) DoctorWithdrawalOrder(doctorWithdrawalOrders []*model.Do ossPath = utils.AddOssDomain("/" + ossPath) return ossPath, nil } + +// UserDoctor 医生列表 +func (r *ExportService) UserDoctor(userDoctors []*model.UserDoctor) (string, error) { + header := []utils.HeaderCellData{ + {Value: "医生姓名", CellType: "string", NumberFmt: "", ColWidth: 18}, + {Value: "医生状态", CellType: "string", NumberFmt: "", ColWidth: 18}, + {Value: "实名认证状态", CellType: "string", NumberFmt: "", ColWidth: 18}, + {Value: "身份认证状态", CellType: "string", NumberFmt: "", ColWidth: 18}, + {Value: "身份认证审核时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30}, + {Value: "身份认证失败原因", CellType: "string", NumberFmt: "", ColWidth: 18}, + {Value: "多点执业认证状态", CellType: "string", NumberFmt: "", ColWidth: 18}, + {Value: "多点执业审核时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30}, + {Value: "多点执业认证失败原因", CellType: "string", NumberFmt: "", ColWidth: 25}, + {Value: "首页推荐", CellType: "string", NumberFmt: "", ColWidth: 18}, + {Value: "头像", CellType: "string", NumberFmt: "", ColWidth: 50}, + {Value: "医生职称", CellType: "string", NumberFmt: "", ColWidth: 18}, + {Value: "科室名称", CellType: "string", NumberFmt: "", ColWidth: 18}, + {Value: "科室电话", CellType: "string", NumberFmt: "", ColWidth: 18}, + {Value: "医院名称", CellType: "string", NumberFmt: "", ColWidth: 35}, + {Value: "服务患者数量", CellType: "string", NumberFmt: "", ColWidth: 18}, + {Value: "好评率(百分制)", CellType: "string", NumberFmt: "", ColWidth: 18}, + {Value: "平均响应时间(分钟制)", CellType: "string", NumberFmt: "", ColWidth: 25}, + {Value: "被关注数量", CellType: "string", NumberFmt: "", ColWidth: 18}, + {Value: "在线", CellType: "string", NumberFmt: "", ColWidth: 18}, + {Value: "平台深度合作医生", CellType: "string", NumberFmt: "", ColWidth: 18}, + {Value: "企业深度合作医生", CellType: "string", NumberFmt: "", ColWidth: 18}, + {Value: "先思达合作医生", CellType: "string", NumberFmt: "", ColWidth: 18}, + {Value: "分享二维码", CellType: "string", NumberFmt: "", ColWidth: 50}, + {Value: "擅长", CellType: "string", NumberFmt: "", ColWidth: 40}, + {Value: "医生简介", CellType: "string", NumberFmt: "", ColWidth: 40}, + {Value: "创建时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30}, + {Value: "手机号", CellType: "string", NumberFmt: "", ColWidth: 18}, + {Value: "年龄", CellType: "string", NumberFmt: "", ColWidth: 18}, + {Value: "性别", CellType: "string", NumberFmt: "", ColWidth: 18}, + {Value: "注册方式", CellType: "string", NumberFmt: "", ColWidth: 18}, + {Value: "创建者", CellType: "string", NumberFmt: "", ColWidth: 18}, + {Value: "服务类型", CellType: "string", NumberFmt: "", ColWidth: 18}, + {Value: "证件类型", CellType: "string", NumberFmt: "", ColWidth: 18}, + {Value: "证件姓名", CellType: "string", NumberFmt: "", ColWidth: 18}, + {Value: "证件号码", CellType: "string", NumberFmt: "", ColWidth: 18}, + {Value: "医师执业证", CellType: "string", NumberFmt: "", ColWidth: 50}, + {Value: "医师资格证", CellType: "string", NumberFmt: "", ColWidth: 50}, + {Value: "医师资格证号", CellType: "string", NumberFmt: "", ColWidth: 18}, + {Value: "医师工作证", CellType: "string", NumberFmt: "", ColWidth: 50}, + {Value: "多点执业备案信息", CellType: "string", NumberFmt: "", ColWidth: 50}, + {Value: "身份证正面图片", CellType: "string", NumberFmt: "", ColWidth: 50}, + {Value: "身份证背面图片", CellType: "string", NumberFmt: "", ColWidth: 50}, + {Value: "签名图片", CellType: "string", NumberFmt: "", ColWidth: 50}, + {Value: "ca证书申请时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30}, + {Value: "ca证书过期时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30}, + {Value: "银行名称", CellType: "string", NumberFmt: "", ColWidth: 25}, + {Value: "银行卡号", CellType: "string", NumberFmt: "", ColWidth: 27}, + {Value: "银行地址", CellType: "string", NumberFmt: "", ColWidth: 46}, + } + + var interfaceSlice []interface{} + for _, v := range userDoctors { + userDoctorData := UserDoctorData{ + UserName: v.UserName, + Status: utils.UserDoctorStatusToString(v.Status), + IdcardStatus: utils.IdcardStatusToString(v.IdcardStatus), + IdenAuthStatus: utils.IdenAuthStatusToString(v.IdenAuthStatus), + IdenAuthFailReason: v.IdenAuthFailReason, + MultiPointStatus: utils.MultiPointStatusToString(v.MultiPointStatus), + MultiPointFailReason: v.MultiPointFailReason, + IsRecommend: utils.IsRecommendToString(v.IsRecommend), + Avatar: utils.AddOssDomain(v.Avatar), + DoctorTitle: utils.DoctorTitleToString(v.DoctorTitle), + DepartmentCustomName: v.DepartmentCustomName, + DepartmentCustomMobile: v.DepartmentCustomMobile, + ServedPatientsNum: fmt.Sprintf("%d", v.ServedPatientsNum), + PraiseRate: v.PraiseRate, + AvgResponseTime: v.AvgResponseTime, + NumberOfFans: fmt.Sprintf("%d", v.NumberOfFans), + IsOnline: utils.IsOnlineToString(v.IsOnline), + IsPlatformDeepCooperation: utils.IsPlatformDeepCooperationToString(v.IsPlatformDeepCooperation), + IsEnterpriseDeepCooperation: utils.IsEnterpriseDeepCooperationToString(v.IsEnterpriseDeepCooperation), + IsSysDiagnoCooperation: utils.IsSysDiagnoCooperationToString(v.IsSysDiagnoCooperation), + QrCode: utils.AddOssDomain(v.QrCode), + BeGoodAt: v.BeGoodAt, + BriefIntroduction: v.BriefIntroduction, + } + + if v.User != nil { + // 性别 + userDoctorData.Sex = utils.SexToString(v.User.Sex) + + // 注册方式 + userDoctorData.RegisterMethod = utils.RegisterMethodToString(v.User.RegisterMethod) + + // 手机号 + userDoctorData.Mobile = v.User.Mobile + + // 年龄 + userDoctorData.Age = fmt.Sprintf("%d", v.User.Age) + + // 性别 + userDoctorData.Sex = utils.SexToString(v.User.Sex) + + // 创建者 + if v.User.CreatedBy != "" { + if v.User.RegisterMethod == 1 { + // 注册方式-微信小程序 + userDoctorData.CreatedBy = v.User.UserName + } else { + // 注册方式-后台添加 + userId, err := strconv.ParseInt(v.User.CreatedBy, 10, 64) + if err == nil { + // 获取用户详情 + AdminUserDao := dao.AdminUserDao{} + adminUser, _ := AdminUserDao.GetAdminUserFirstById(userId) + if adminUser != nil { + userDoctorData.CreatedBy = adminUser.NickName + } + } + + } + } else { + // 注册方式-微信小程序 + userDoctorData.CreatedBy = v.User.UserName + } + } + + if v.UserDoctorInfo != nil { + // 身份类型 + userDoctorData.CardType = utils.CardTypeToString(v.UserDoctorInfo.CardType) + + // 证件姓名 + userDoctorData.CardName = v.UserDoctorInfo.CardName + + // 证件号码 + userDoctorData.CardNum = v.UserDoctorInfo.CardNum + + // 医师执业证 + var licenseCertSlice []string + if v.UserDoctorInfo.LicenseCert != "" { + result := strings.Split(v.UserDoctorInfo.LicenseCert, ",") + if len(result) > 0 { + for _, v := range result { + v = utils.AddOssDomain(v) + licenseCertSlice = append(licenseCertSlice, v) + } + + userDoctorData.LicenseCert = strings.Join(licenseCertSlice, ",") + } + } + + // 医师资格证 + var QualificationCertSlice []string + if v.UserDoctorInfo.QualificationCert != "" { + result := strings.Split(v.UserDoctorInfo.QualificationCert, ",") + if len(result) > 0 { + for _, v := range result { + v = utils.AddOssDomain(v) + QualificationCertSlice = append(QualificationCertSlice, v) + } + + userDoctorData.QualificationCert = strings.Join(QualificationCertSlice, ",") + } + } + + // 医师资格证号 + userDoctorData.QualificationCertNum = v.UserDoctorInfo.QualificationCertNum + + // 医师工作证 + var WorkCertSlice []string + if v.UserDoctorInfo.QualificationCert != "" { + result := strings.Split(v.UserDoctorInfo.QualificationCert, ",") + if len(result) > 0 { + for _, v := range result { + v = utils.AddOssDomain(v) + WorkCertSlice = append(WorkCertSlice, v) + } + + userDoctorData.WorkCert = strings.Join(WorkCertSlice, ",") + } + } + + // 多点执业备案信息 + var MultiPointImagesSlice []string + if v.UserDoctorInfo.MultiPointImages != "" { + result := strings.Split(v.UserDoctorInfo.MultiPointImages, ",") + if len(result) > 0 { + for _, v := range result { + v = utils.AddOssDomain(v) + MultiPointImagesSlice = append(MultiPointImagesSlice, v) + } + + userDoctorData.MultiPointImages = strings.Join(MultiPointImagesSlice, ",") + } + } + + // 身份证正面图片 + userDoctorData.IdCardFront = utils.AddOssDomain(v.UserDoctorInfo.IdCardFront) + + // 身份证背面图片 + userDoctorData.IdCardBack = utils.AddOssDomain(v.UserDoctorInfo.IdCardBack) + + // 签名图片 + userDoctorData.SignImage = utils.AddOssDomain(v.UserDoctorInfo.SignImage) + } + + // 医院名称 + if v.Hospital != nil { + userDoctorData.HospitalName = v.Hospital.HospitalName + } + + // 获取银行卡数据 + doctorBankCardDao := dao.DoctorBankCardDao{} + doctorBankCard, _ := doctorBankCardDao.GetDoctorBankCardByDoctorId(v.DoctorId) + if doctorBankCard != nil { + basicBankDao := dao.BasicBankDao{} + basicBank, _ := basicBankDao.GetBasicBankById(doctorBankCard.BankId) + if basicBank != nil { + // 银行名称 + userDoctorData.BankName = basicBank.BankName + } + + // 银行卡号 + userDoctorData.BankCardCode = doctorBankCard.BankCardCode + + // 开户行地址 + userDoctorData.BankCardAddress = doctorBankCard.Province + doctorBankCard.City + doctorBankCard.County + } + + // 身份审核时间 + if v.IdenAuthTime != (model.LocalTime{}) { + t := time.Time(v.IdenAuthTime) + userDoctorData.IdenAuthTime = t + } + + // 多点审核时间 + if v.MultiPointTime != (model.LocalTime{}) { + t := time.Time(v.MultiPointTime) + userDoctorData.MultiPointTime = t + } + + // 创建时间 + if v.CreatedAt != (model.LocalTime{}) { + t := time.Time(v.CreatedAt) + userDoctorData.CreatedAt = t + } + + // 获取ca证书 + userCaCertDao := dao.UserCaCertDao{} + userCaCert, _ := userCaCertDao.GetUserCaCertByUserId(v.UserId) + if userCaCert != nil { + // ca证书申请时间 + if userCaCert.CertApplicationTime != (model.LocalTime{}) { + t := time.Time(userCaCert.CertApplicationTime) + userDoctorData.CertApplicationTime = t + } + + // ca证书过期时间 + if userCaCert.CertExpireTime != (model.LocalTime{}) { + t := time.Time(userCaCert.CertExpireTime) + userDoctorData.CertExpireTime = t + } + } + + if len(v.DoctorInquiryConfig) > 0 { + var inquiryTypes []string + for _, v := range v.DoctorInquiryConfig { + if v.InquiryType == 1 && v.InquiryMode == 1 && v.IsEnable == 1 { + inquiryTypes = append(inquiryTypes, "专家问诊") + } + + if v.InquiryType == 2 && v.InquiryMode == 1 && v.IsEnable == 1 { + inquiryTypes = append(inquiryTypes, "快速问诊") + } + + if v.InquiryType == 3 && v.InquiryMode == 1 && v.IsEnable == 1 { + inquiryTypes = append(inquiryTypes, "公益问诊") + } + + if v.InquiryType == 4 && v.InquiryMode == 1 && v.IsEnable == 1 { + inquiryTypes = append(inquiryTypes, "问诊购药") + } + } + + if len(inquiryTypes) > 0 { + // 服务类型 + userDoctorData.InquiryType = strings.Join(inquiryTypes, ",") + } + } + interfaceSlice = append(interfaceSlice, userDoctorData) + } + + file, err := utils.Export(header, interfaceSlice) + if err != nil { + return "", err + } + + // 设置文件名字 + now := time.Now() + dateTimeString := now.Format("20060102150405") // 当前时间字符串 + rand.Seed(time.Now().UnixNano()) // 设置随机数 + ossPath := "admin/export/output" + dateTimeString + fmt.Sprintf("%d", rand.Intn(9000)+1000) + ".xlsx" + + // 上传oss + _, err = aliyun.PutObjectByte(ossPath, file.Bytes()) + if err != nil { + return "", err + } + + ossPath = utils.AddOssDomain("/" + ossPath) + return ossPath, nil +} diff --git a/output.xlsx b/output.xlsx new file mode 100755 index 0000000..0ebf1a1 Binary files /dev/null and b/output.xlsx differ diff --git a/utils/export.go b/utils/export.go index 50a43e5..a726458 100644 --- a/utils/export.go +++ b/utils/export.go @@ -283,14 +283,16 @@ func Export(header []HeaderCellData, data []interface{}) (*bytes.Buffer, error) } } - // 保存文件 - // if err := f.SaveAs("output.xlsx"); err != nil { - // return nil, err - // } buffer, err := f.WriteToBuffer() if err != nil { return nil, err } return buffer, nil + + // 保存文件 + // if err := f.SaveAs("output.xlsx"); err != nil { + // return nil, err + // } + // return nil, errors.New("已导出文件") } diff --git a/utils/intToString.go b/utils/intToString.go new file mode 100644 index 0000000..470ab70 --- /dev/null +++ b/utils/intToString.go @@ -0,0 +1,235 @@ +package utils + +// int抓字符串 + +// UserDoctorStatusToString 用户状态(0:禁用 1:正常 2:删除) +func UserDoctorStatusToString(i int) string { + switch i { + case 0: + return "禁用" + case 1: + return "正常" + case 2: + return "删除" + default: + return "未知" + } +} + +// IdcardStatusToString 实名认证状态(0:未认证 1:认证通过 2:认证失败) +func IdcardStatusToString(i int) string { + switch i { + case 0: + return "未认证" + case 1: + return "认证通过" + case 2: + return "认证失败" + default: + return "未知" + } +} + +// IdenAuthStatusToString 身份认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败) +func IdenAuthStatusToString(i int) string { + switch i { + case 0: + return "未认证" + case 1: + return "认证通过" + case 2: + return "审核中" + case 3: + return "认证失败" + default: + return "未知" + } +} + +// MultiPointStatusToString 医生多点执业认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败) +func MultiPointStatusToString(i int) string { + switch i { + case 0: + return "未认证" + case 1: + return "认证通过" + case 2: + return "审核中" + case 3: + return "认证失败" + default: + return "未知" + } +} + +// IsRecommendToString 是否首页推荐(0:否 1:是) +func IsRecommendToString(i int) string { + switch i { + case 0: + return "否" + case 1: + return "是" + default: + return "" + } +} + +// DoctorTitleToString 医生职称(1:主任医师 2:主任中医师 3:副主任医师 4:副主任中医师 5:主治医师 6:住院医师) +func DoctorTitleToString(i int) string { + switch i { + case 1: + return "主任医师" + case 2: + return "主任中医师" + case 3: + return "副主任医师" + case 4: + return "副主任中医师" + case 5: + return "主治医师" + case 6: + return "住院医师" + default: + return "" + } +} + +// IsOnlineToString 是否在线(0:不在线 1:在线) +func IsOnlineToString(i int) string { + switch i { + case 0: + return "不在线" + case 1: + return "在线" + default: + return "" + } +} + +// IsPlatformDeepCooperationToString 是否平台深度合作医生(0:否 1:是) +func IsPlatformDeepCooperationToString(i int) string { + switch i { + case 0: + return "否" + case 1: + return "是" + default: + return "" + } +} + +// IsEnterpriseDeepCooperationToString 是否企业深度合作医生(0:否 1:是) +func IsEnterpriseDeepCooperationToString(i int) string { + switch i { + case 0: + return "否" + case 1: + return "是" + default: + return "" + } +} + +// IsSysDiagnoCooperationToString 是否先思达合作医生(0:否 1:是) +func IsSysDiagnoCooperationToString(i int) string { + switch i { + case 0: + return "否" + case 1: + return "是" + default: + return "" + } +} + +// SexToString 性别(0:未知 1:男 2:女) +func SexToString(i int) string { + switch i { + case 0: + return "未知" + case 1: + return "男" + case 2: + return "女" + default: + return "未知" + } +} + +// RegisterMethodToString 注册方式(1:微信小程序 2:后台添加 ) +func RegisterMethodToString(i int) string { + switch i { + case 1: + return "微信小程序" + case 2: + return "后台添加" + default: + return "" + } +} + +// CardTypeToString 身份类型(1:身份证 2:护照 3:港澳通行证 4:台胞证) +func CardTypeToString(i int) string { + switch i { + case 1: + return "身份证" + case 2: + return "护照" + case 3: + return "港澳通行证" + case 4: + return "台胞证" + default: + return "" + } +} + +// PayChannelToString 支付渠道(1:小程序支付 2:微信扫码支付 3:模拟支付) +func PayChannelToString(i int) string { + switch i { + case 1: + return "小程序支付" + case 2: + return "微信扫码支付" + case 3: + return "模拟支付" + default: + return "" + } +} + +// InquiryStatusToString 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消) +func InquiryStatusToString(i int) string { + switch i { + case 1: + return "待支付" + case 2: + return "待分配" + case 3: + return "待接诊" + case 4: + return "已接诊" + case 5: + return "已完成" + case 6: + return "已结束" + case 7: + return "已取消" + default: + return "未知" + } +} + +// WithdrawalExamineStatusToString 提现审核状态(1:审核中 2:审核通过 3:审核未通过) +func WithdrawalExamineStatusToString(i int) string { + switch i { + case 1: + return "审核中" + case 2: + return "审核通过" + case 3: + return "审核未通过" + default: + return "未知" + } +}