2023-11-15 15:31:35 +08:00

1702 lines
69 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package service
import (
"fmt"
"github.com/shopspring/decimal"
"hospital-admin-api/api/dao"
"hospital-admin-api/api/model"
"hospital-admin-api/extend/aliyun"
"hospital-admin-api/utils"
"math/rand"
"strconv"
"strings"
"time"
)
// ExportService 导出
type ExportService struct {
}
// DoctorWithdrawalData 提现记录数据
type DoctorWithdrawalData struct {
WithdrawalId string // 提现编号
DoctorName string // 医生姓名
Mobile string // 医生手机号
DoctorCardNum string // 医生证件号码
AppliedWithdrawalAmount float64 // 提现金额
ActualWithdrawalAmount float64 // 实际提现金额
IncomeTax float64 // 提现所得税金额
BankName string // 提现银行名称
BankCardCode string // 银行卡号
BankCardAddress string // 银行地址
ExamineStatus string // 审核状态1:审核中 2:审核通过 3:审核未通过)
ExamineFailReason string // 审核失败原因
ExamineTime time.Time // 审核日期
ExamineBy string // 审核人员名称
PaymentStatus string // 财务打款状态0:否 1:是)
PaymentTime time.Time // 财务打款时间
PaymentBy string // 财务打款人员id后台用户id
CreatedAt time.Time // 创建时间
}
// DoctorWithdrawalOrderData 提现记录-关联订单
type DoctorWithdrawalOrderData struct {
DoctorName string // 医生姓名
PatientName string // 患者姓名-就诊人
PatientSex string // 患者性别-就诊人0:未知 1:男 2:女)
PatientAge string // 患者年龄-就诊人
PatientMobile string // 患者电话
PayChannel string // 支付渠道1:小程序支付 2:微信扫码支付 3:模拟支付)
PayTime time.Time // 支付时间
InquiryNo string // 系统订单编号
EscrowTradeNo string // 第三方支付流水号
InquiryStatus string // 问诊订单状态1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
AmountTotal float64 // 订单金额
CouponAmountTotal float64 // 优惠卷金额
PaymentAmountTotal float64 // 实际付款金额
DoctorAmount float64 // 医生收益
}
// 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 // 开户银行地址
}
// DoctorBankCardData 医生银行卡列表
type DoctorBankCardData struct {
DoctorName string // 医生姓名
DoctorMobile string // 医生手机号
BankName string // 银行名称
BankCardCode string // 银行卡号
Province string // 省份
City string // 城市
County string // 区县
CreatedAt time.Time // 创建时间
}
// DoctorAccountData 医生账户
type DoctorAccountData struct {
DoctorName string // 医生姓名
DoctorMobile string // 医生手机号
TotalAmount float64 // 总金额(已结束订单的总金额)
BalanceAccount float64 // 账户余额
AppliedWithdrawalAmount float64 // 提现金额
IncomeTax float64 // 个人所得税
ActualWithdrawalAmount float64 // 实际提现金额
CompletedWaitEntryAmount float64 // 已完成待入账金额
EstimateIncome float64 // 今日预计收入
}
// OrderInquiryForAccount 医生账户-关联订单
type OrderInquiryForAccount struct {
InquiryNo string // 系统订单编号
DoctorName string // 医生姓名
UserName string // 用户姓名(患者)
PatientName string // 患者姓名-就诊人
PatientSex string // 患者性别-就诊人0:未知 1:男 2:女)
PatientAge string // 患者年龄-就诊人
PatientMobile string // 患者电话
InquiryType string // 订单类型1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药 5:检测)
InquiryMode string // 订单问诊方式1:图文 2:视频 3:语音 4:电话 5:会员)
InquiryStatus string // 问诊订单状态1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
IsDelete string // 删除状态0:否 1:是)
InquiryRefundStatus string // 问诊订单退款状态0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常)
InquiryPayChannel string // 支付渠道1:小程序支付 2:微信扫码支付 3:模拟支付)
InquiryPayStatus string // 支付状态1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
EscrowTradeNo string // 第三方支付流水号
AmountTotal float64 // 订单金额
CouponAmountTotal float64 // 优惠卷总金额
PaymentAmountTotal float64 // 实际付款金额
DoctorAmount float64 // 医生收益
PayTime time.Time // 支付时间
ReceptionTime time.Time // 接诊时间(已接诊)
CompleteTime time.Time // 订单完成时间(问诊完成时间)
FinishTime time.Time // 订单结束时间
StatisticsStatus string // 订单统计状态0:未统计 1:已统计 2:统计失败)
StatisticsTime time.Time // 订单统计时间
IsWithdrawal string // 是否提现0:否 1:是 2:提现中)
WithdrawalTime time.Time // 提现时间
CancelTime time.Time // 订单取消时间
CancelReason string // 取消订单原因1:医生未接诊 2:主动取消 3:无可分配医生 4:客服取消 5:支付超时)
CancelRemarks string // 取消订单备注(自动添加)
EntryStatus string // 入账状态0:未入账 1:已入账 2:入账中 3:入账失败)
CreatedAt time.Time // 创建时间
}
// UserPatientData 患者列表
type UserPatientData struct {
UserName string // 用户名称
Status string // 状态0:禁用 1:正常 2:删除)
Mobile string // 手机号
Avatar string // 头像
DisableReason string // 禁用理由
PatientFamilyCount string // 家庭成员数量
CreatedAt time.Time // 创建时间
}
// PatientFamilyData 就诊人列表
type PatientFamilyData struct {
UserName string `json:"user_name"` // 账号名称
CardName string `json:"card_name"` // 患者姓名
Relation string `json:"relation"` // 与患者关系1:本人 2:父母 3:爱人 4:子女 5:亲戚 6:其他)
Status string `json:"status"` // 状态1:正常 2:删除)
Mobile string `json:"mobile"` // 用户电话
IsDefault string `json:"is_default"` // 是否默认0:否 1:是)
Type string `json:"type"` // 身份类型1:身份证 2:护照 3:港澳通行证 4:台胞证)
IdNumber string `json:"id_number"` // 证件号码
Sex string `json:"sex"` // 性别0:未知 1:男 2:女)
Age string `json:"age"` // 年龄
Province string `json:"province"` // 省份
City string `json:"city"` // 城市
County string `json:"county"` // 区县
Height string `json:"height"` // 身高cm
Weight string `json:"weight"` // 体重kg
MaritalStatus string `json:"marital_status"` // 婚姻状况0:未婚 1:已婚 2:离异)
NationName string `json:"nation_name"` // 民族名称
JobName string `json:"job_name"` // 职业名称
CreatedAt time.Time `json:"created_at"` // 创建时间
}
// OrderInquiry 问诊订单
type OrderInquiry struct {
InquiryNo string // 系统订单编号
DoctorName string // 医生姓名
UserName string // 用户姓名(患者)
PatientName string // 患者姓名-就诊人
PatientSex string // 患者性别-就诊人0:未知 1:男 2:女)
PatientAge string // 患者年龄-就诊人
PatientMobile string // 患者电话
InquiryType string // 订单类型1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药 5:检测)
InquiryMode string // 订单问诊方式1:图文 2:视频 3:语音 4:电话 5:会员)
InquiryStatus string // 问诊订单状态1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
IsDelete string // 删除状态0:否 1:是)
InquiryRefundStatus string // 问诊订单退款状态0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常)
InquiryPayChannel string // 支付渠道1:小程序支付 2:微信扫码支付 3:模拟支付)
InquiryPayStatus string // 支付状态1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
EscrowTradeNo string // 第三方支付流水号
AmountTotal float64 // 订单金额
CouponAmountTotal float64 // 优惠卷总金额
PaymentAmountTotal float64 // 实际付款金额
DoctorAmount float64 // 医生收益
PayTime time.Time // 支付时间
ReceptionTime time.Time // 接诊时间(已接诊)
CompleteTime time.Time // 订单完成时间(问诊完成时间)
FinishTime time.Time // 订单结束时间
StatisticsStatus string // 订单统计状态0:未统计 1:已统计 2:统计失败)
StatisticsTime time.Time // 订单统计时间
IsWithdrawal string // 是否提现0:否 1:是 2:提现中)
WithdrawalTime time.Time // 提现时间
CancelTime time.Time // 订单取消时间
CancelReason string // 取消订单原因1:医生未接诊 2:主动取消 3:无可分配医生 4:客服取消 5:支付超时)
CancelRemarks string // 取消订单备注(自动添加)
EntryStatus string // 入账状态0:未入账 1:已入账 2:入账中 3:入账失败)
CreatedAt time.Time // 创建时间
}
// OrderProductData 药品订单
type OrderProductData struct {
OrderProductNo string // 订单编号
DoctorName string // 医生姓名
PatientName string // 患者姓名-就诊人
PatientSex string // 患者性别-就诊人0:未知 1:男 2:女)
PatientAge string // 患者年龄-就诊人
PatientMobile string // 患者电话
EscrowTradeNo string // 第三方支付流水号
PrescriptionCode string // 处方编号
OrderProductStatus string // 订单状态1:待支付 2:待发货 3:已发货 4:已签收 5:已取消)
PayChannel string // 支付渠道1:小程序支付 2:微信扫码支付);NOT NULL
PayStatus string // 支付状态1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
CancelReason string // 订单取消原因1:主动取消 2:复核失败/库存不足 3:支付超时 4:客服取消)
AmountTotal float64 // 订单金额
PaymentAmountTotal float64 // 实际付款金额
LogisticsFee float64 // 运费金额
LogisticsNo string // 物流编号
LogisticsCompanyCode string // 快递公司编码
DeliveryTime time.Time // 发货时间
PayTime time.Time // 支付时间
Remarks string // 订单备注
RefundStatus string // 商品订单退款状态0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常)
CancelTime time.Time // 订单取消时间
CancelRemarks string // 订单取消备注(自动添加)
ReportPreStatus string // 上报处方平台状态0:未上报 1:已上报 2:上报失败))
ReportPreTime time.Time // 上报处方平台时间
ReportPreFailReason string // 上报失败原因
Province string // 省份
City string // 城市
County string // 区县
Address string // 详细地址
ConsigneeName string // 收货人姓名
ConsigneeTel string // 收货人电话
CreatedAt time.Time // 创建时间
}
// OrderPrescriptionData 处方
type OrderPrescriptionData struct {
DoctorName string // 医生姓名
PharmacistName string // 药师姓名
PrescriptionStatus string // 处方状态1:待审核 2:待使用 3:已失效 4:已使用)
PharmacistAuditStatus string // 药师审核状态0:审核中 1:审核成功 2:审核驳回)
PharmacistVerifyTime time.Time // 药师审核时间
PharmacistFailReason string // 药师审核驳回原因
PlatformAuditStatus string // 处方平台审核状态0:审核中 1:审核成功 2:审核驳回)
PlatformFailTime time.Time // 平台审核失败时间
PlatformFailReason string // 处方平台驳回原因
IsAutoPharVerify string // 是否药师自动审核0:否 1:是)
DoctorCreatedTime time.Time // 医生开具处方时间
ExpiredTime time.Time // 处方过期时间
IsDelete string // 是否删除0:否 1:是)
PrescriptionCode string // 处方编号
PatientName string // 患者姓名-就诊人
PatientSex string // 患者性别-就诊人1:男 2:女)
PatientAge string // 患者年龄-就诊人
PatientMobile string // 患者电话
DoctorAdvice string // 医嘱
OrderPrescriptionIcd string // 处方诊断疾病
CreatedAt time.Time // 创建时间
}
// DoctorWithdrawal 提现记录
func (r *ExportService) DoctorWithdrawal(doctorWithdrawals []*model.DoctorWithdrawal) (string, error) {
header := []utils.HeaderCellData{
{Value: "提现编号", CellType: "string", NumberFmt: "", ColWidth: 25},
{Value: "医生姓名", CellType: "string", NumberFmt: "", ColWidth: 18},
{Value: "医生手机号", CellType: "string", NumberFmt: "", ColWidth: 18},
{Value: "医生证件号码", CellType: "string", NumberFmt: "", ColWidth: 25},
{Value: "申请提现金额", CellType: "float", NumberFmt: "0.0000", ColWidth: 18},
{Value: "实际提现金额", CellType: "float", NumberFmt: "0.0000", ColWidth: 18},
{Value: "个人所得税", CellType: "float", NumberFmt: "0.0000", ColWidth: 18},
{Value: "银行名称", CellType: "string", NumberFmt: "", ColWidth: 25},
{Value: "银行卡号", CellType: "string", NumberFmt: "", ColWidth: 27},
{Value: "银行地址", CellType: "string", NumberFmt: "", ColWidth: 46},
{Value: "审核状态", CellType: "string", NumberFmt: "", ColWidth: 18},
{Value: "审核失败原因", CellType: "string", NumberFmt: "", ColWidth: 33},
{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: 18},
{Value: "申请时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
}
var interfaceSlice []interface{}
for _, v := range doctorWithdrawals {
// 审核状态
examineStatus := utils.WithdrawalExamineStatusToString(v.ExamineStatus)
// 审核人员
examineBy := ""
if v.ExamineBy != 0 {
adminUserDao := dao.AdminUserDao{}
adminUser, err := adminUserDao.GetAdminUserFirstById(v.ExamineBy)
if err == nil && adminUser != nil {
examineBy = adminUser.NickName
}
}
// 打款状态
paymentStatus := "未知"
if v.PaymentStatus == 0 {
paymentStatus = "未打款"
} else if v.ExamineStatus == 1 {
paymentStatus = "已打款"
}
// 打款人员
paymentBy := ""
if v.PaymentBy != 0 {
adminUserDao := dao.AdminUserDao{}
adminUser, err := adminUserDao.GetAdminUserFirstById(v.PaymentBy)
if err == nil && adminUser != nil {
paymentBy = adminUser.NickName
}
}
// 银行名称
bankName := "未知"
if v.DoctorWithdrawalBank != nil {
if v.DoctorWithdrawalBank.BasicBank != nil {
if v.DoctorWithdrawalBank.BasicBank.BankName != "" {
bankName = v.DoctorWithdrawalBank.BasicBank.BankName
}
}
}
// 银行卡号
bankCardCode := "未知"
// 开户行地址
bankCardAddress := ""
if v.DoctorWithdrawalBank != nil {
if v.DoctorWithdrawalBank.BankCardCode != "" {
bankCardCode = v.DoctorWithdrawalBank.BankCardCode
}
bankCardAddress = v.DoctorWithdrawalBank.Province + v.DoctorWithdrawalBank.City + v.DoctorWithdrawalBank.County
}
// 时间处理
var examineTime time.Time
if v.ExamineTime != (model.LocalTime{}) {
t := time.Time(v.ExamineTime)
examineTime = t
}
var paymentTime time.Time
if v.PaymentTime != (model.LocalTime{}) {
t := time.Time(v.PaymentTime)
paymentTime = t
}
var createdAt time.Time
if v.CreatedAt != (model.LocalTime{}) {
t := time.Time(v.CreatedAt)
createdAt = t
}
doctorWithdrawalData := DoctorWithdrawalData{
WithdrawalId: fmt.Sprintf("%d", v.WithdrawalId),
DoctorName: v.UserDoctor.UserName,
Mobile: v.UserDoctor.User.Mobile,
DoctorCardNum: v.UserDoctor.UserDoctorInfo.CardNum,
AppliedWithdrawalAmount: v.AppliedWithdrawalAmount,
ActualWithdrawalAmount: v.ActualWithdrawalAmount,
IncomeTax: v.IncomeTax,
BankName: bankName,
BankCardCode: bankCardCode,
BankCardAddress: bankCardAddress,
ExamineStatus: examineStatus,
ExamineFailReason: v.ExamineFailReason,
ExamineTime: examineTime,
ExamineBy: examineBy,
PaymentStatus: paymentStatus,
PaymentTime: paymentTime,
PaymentBy: paymentBy,
CreatedAt: createdAt,
}
interfaceSlice = append(interfaceSlice, doctorWithdrawalData)
}
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
}
// DoctorWithdrawalOrder 提现记录-关联订单
func (r *ExportService) DoctorWithdrawalOrder(doctorWithdrawalOrders []*model.DoctorWithdrawalOrder) (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: "string", NumberFmt: "", ColWidth: 20},
{Value: "支付渠道", CellType: "float", NumberFmt: "", ColWidth: 18},
{Value: "支付时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
{Value: "系统订单编号", CellType: "string", NumberFmt: "", ColWidth: 30},
{Value: "第三方支付流水号", CellType: "string", NumberFmt: "", ColWidth: 30},
{Value: "订单状态", CellType: "string", NumberFmt: "", ColWidth: 18},
{Value: "订单金额", CellType: "float", NumberFmt: "0.0000", ColWidth: 18},
{Value: "优惠卷金额", CellType: "float", NumberFmt: "0.0000", ColWidth: 18},
{Value: "付款金额", CellType: "float", NumberFmt: "0.0000", ColWidth: 18},
{Value: "医生收益", CellType: "float", NumberFmt: "0.0000", ColWidth: 18},
}
var interfaceSlice []interface{}
for _, v := range doctorWithdrawalOrders {
// 医生姓名
doctorName := ""
if v.UserDoctor != nil {
doctorName = v.UserDoctor.UserName
}
// 就诊人数据
patientName := "未知"
patientSex := ""
patientAge := ""
patientMobile := ""
payChannel := "未知"
inquiryNo := "未知"
escrowTradeNo := "未知"
inquiryStatus := "未知"
var amountTotal float64
var couponAmountTotal float64
var paymentAmountTotal float64
var doctorAmount float64
var payTime time.Time
if v.OrderInquiry != nil {
patientName = v.OrderInquiry.PatientName
// 患者性别
patientSex = utils.SexToString(v.OrderInquiry.PatientSex)
// 患者年龄
patientAge = fmt.Sprintf("%d", v.OrderInquiry.PatientAge)
// 患者电话
if v.OrderInquiry.User != nil {
patientMobile = v.OrderInquiry.User.Mobile
}
// 支付渠道
payChannel = utils.PayChannelToString(v.OrderInquiry.InquiryPayChannel)
inquiryNo = v.OrderInquiry.InquiryNo
escrowTradeNo = v.OrderInquiry.EscrowTradeNo
// 问诊订单状态
inquiryStatus = utils.InquiryStatusToString(v.OrderInquiry.InquiryStatus)
amountTotal = v.OrderInquiry.AmountTotal
couponAmountTotal = v.OrderInquiry.CouponAmountTotal
paymentAmountTotal = v.OrderInquiry.PaymentAmountTotal
// 医生收益
doctorAmount, _ = decimal.NewFromFloat(v.OrderInquiry.AmountTotal).Mul(decimal.NewFromFloat(0.75)).Round(2).Float64()
// 时间处理
if v.OrderInquiry.PayTime != (model.LocalTime{}) {
t := time.Time(v.OrderInquiry.PayTime)
payTime = t
}
}
doctorWithdrawalOrderData := DoctorWithdrawalOrderData{
DoctorName: doctorName,
PatientName: patientName,
PatientSex: patientSex,
PatientAge: patientAge,
PatientMobile: patientMobile,
PayChannel: payChannel,
PayTime: payTime,
InquiryNo: inquiryNo,
EscrowTradeNo: escrowTradeNo,
InquiryStatus: inquiryStatus,
AmountTotal: amountTotal,
CouponAmountTotal: couponAmountTotal,
PaymentAmountTotal: paymentAmountTotal,
DoctorAmount: doctorAmount,
}
interfaceSlice = append(interfaceSlice, doctorWithdrawalOrderData)
}
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
}
// 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
}
// UserDoctorBankCard 医生银行卡列表
func (r *ExportService) UserDoctorBankCard(d []*model.DoctorBankCard) (string, error) {
header := []utils.HeaderCellData{
{Value: "医生姓名", CellType: "string", NumberFmt: "", ColWidth: 18},
{Value: "医生手机号", CellType: "string", NumberFmt: "", ColWidth: 18},
{Value: "银行名称", CellType: "string", NumberFmt: "", ColWidth: 22},
{Value: "银行卡号", CellType: "string", NumberFmt: "", ColWidth: 25},
{Value: "省份", CellType: "string", NumberFmt: "", ColWidth: 20},
{Value: "城市", CellType: "string", NumberFmt: "", ColWidth: 22},
{Value: "区县", CellType: "string", NumberFmt: "", ColWidth: 25},
{Value: "创建时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
}
var dataSlice []interface{}
for _, v := range d {
data := DoctorBankCardData{
BankCardCode: v.BankCardCode,
Province: v.Province,
City: v.City,
County: v.County,
}
if v.UserDoctor != nil {
// 医生姓名
data.DoctorName = v.UserDoctor.UserName
if v.UserDoctor.User != nil {
// 手机号
data.DoctorMobile = v.UserDoctor.User.Mobile
}
}
if v.BasicBank != nil {
data.BankName = v.BasicBank.BankName
}
// 创建时间
if v.CreatedAt != (model.LocalTime{}) {
t := time.Time(v.CreatedAt)
data.CreatedAt = t
}
dataSlice = append(dataSlice, data)
}
file, err := utils.Export(header, dataSlice)
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
}
// DoctorAccount 医生账户
func (r *ExportService) DoctorAccount(d []*model.DoctorAccount) (string, error) {
header := []utils.HeaderCellData{
{Value: "医生姓名", CellType: "string", NumberFmt: "", ColWidth: 18},
{Value: "医生手机号", CellType: "string", NumberFmt: "", ColWidth: 18},
{Value: "总金额", CellType: "float64", NumberFmt: "0.0000", ColWidth: 18},
{Value: "账户余额", CellType: "float64", NumberFmt: "0.0000", ColWidth: 18},
{Value: "提现金额", CellType: "float64", NumberFmt: "0.0000", ColWidth: 18},
{Value: "个人所得税", CellType: "float64", NumberFmt: "0.0000", ColWidth: 18},
{Value: "实际提现金额", CellType: "float64", NumberFmt: "0.0000", ColWidth: 18},
{Value: "已完成待入账金额", CellType: "float64", NumberFmt: "0.0000", ColWidth: 22},
{Value: "今日预计收入", CellType: "float64", NumberFmt: "0.0000", ColWidth: 18},
}
var dataSlice []interface{}
for _, v := range d {
data := DoctorAccountData{
TotalAmount: v.TotalAmount,
BalanceAccount: v.BalanceAccount,
AppliedWithdrawalAmount: v.AppliedWithdrawalAmount,
ActualWithdrawalAmount: v.ActualWithdrawalAmount,
IncomeTax: v.IncomeTax,
}
if v.UserDoctor != nil {
// 医生姓名
data.DoctorName = v.UserDoctor.UserName
if v.UserDoctor.User != nil {
// 手机号
data.DoctorMobile = v.UserDoctor.User.Mobile
}
}
userDoctorService := UserDoctorService{}
// 获取医生已完成待入账金额
data.CompletedWaitEntryAmount, _ = userDoctorService.GetDoctorCompletedWaitEntryAmount(v.DoctorId)
// 获取医生今日预计收入
data.EstimateIncome, _ = userDoctorService.GetDoctorEstimateIncome(v.DoctorId)
dataSlice = append(dataSlice, data)
}
file, err := utils.Export(header, dataSlice)
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
}
// OrderInquiryForAccount 医生账户-关联订单
func (r *ExportService) OrderInquiryForAccount(d []*model.OrderInquiry) (string, error) {
header := []utils.HeaderCellData{
{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: 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: 25},
{Value: "订单金额", CellType: "float64", NumberFmt: "0.0000", ColWidth: 18},
{Value: "优惠卷总金额", CellType: "float64", NumberFmt: "0.0000", ColWidth: 18},
{Value: "实际付款金额", CellType: "float64", NumberFmt: "0.0000", ColWidth: 18},
{Value: "医生收益", CellType: "float64", NumberFmt: "0.0000", ColWidth: 18},
{Value: "支付时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
{Value: "接诊时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
{Value: "订单完成时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
{Value: "订单结束时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
{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: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
{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: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
}
orderInquiryService := OrderInquiryService{}
var dataSlice []interface{}
for _, v := range d {
data := OrderInquiryForAccount{
InquiryNo: v.InquiryNo,
DoctorName: v.PatientName,
PatientName: v.PatientName,
PatientAge: fmt.Sprintf("%d", v.PatientAge),
EscrowTradeNo: v.EscrowTradeNo,
AmountTotal: v.AmountTotal,
CouponAmountTotal: v.CouponAmountTotal,
PaymentAmountTotal: v.PaymentAmountTotal,
CancelRemarks: v.CancelRemarks,
PatientSex: utils.SexToString(v.PatientSex),
InquiryType: utils.InquiryTypeToString(v.InquiryType),
InquiryMode: utils.InquiryModeToString(v.InquiryMode),
InquiryStatus: utils.InquiryStatusToString(v.InquiryStatus),
IsDelete: utils.IsDeleteToString(v.IsDelete),
InquiryRefundStatus: utils.RefundStatusToString(v.InquiryRefundStatus),
InquiryPayChannel: utils.PayChannelToString(v.InquiryPayChannel),
InquiryPayStatus: utils.PayStatusToString(v.InquiryPayStatus),
StatisticsStatus: utils.StatisticsStatusToString(v.StatisticsStatus),
IsWithdrawal: utils.IsWithdrawalToString(v.IsWithdrawal),
CancelReason: utils.InquiryCancelReasonToString(v.CancelReason),
}
if v.UserDoctor != nil {
// 医生姓名
data.DoctorName = v.UserDoctor.UserName
}
if v.User != nil {
// 用户姓名(患者)
data.UserName = v.User.UserName
// 患者电话
data.PatientMobile = v.User.Mobile
}
if v.PayTime != (model.LocalTime{}) {
t := time.Time(v.PayTime)
data.PayTime = t
}
if v.ReceptionTime != (model.LocalTime{}) {
t := time.Time(v.ReceptionTime)
data.ReceptionTime = t
}
if v.CompleteTime != (model.LocalTime{}) {
t := time.Time(v.CompleteTime)
data.CompleteTime = t
}
if v.FinishTime != (model.LocalTime{}) {
t := time.Time(v.FinishTime)
data.FinishTime = t
}
if v.StatisticsTime != (model.LocalTime{}) {
t := time.Time(v.StatisticsTime)
data.StatisticsTime = t
}
if v.WithdrawalTime != (model.LocalTime{}) {
t := time.Time(v.WithdrawalTime)
data.WithdrawalTime = t
}
if v.CancelTime != (model.LocalTime{}) {
t := time.Time(v.CancelTime)
data.CancelTime = t
}
if v.CreatedAt != (model.LocalTime{}) {
t := time.Time(v.CreatedAt)
data.CreatedAt = t
}
// 处理入账状态0:未入账 1:已入账 2:入账中 3:入账失败 4:入账取消)
entryStatus := orderInquiryService.GetOrderInquiryEntryStatus(v.InquiryStatus, v.StatisticsStatus)
data.EntryStatus = utils.EntryStatusToString(entryStatus)
// 处理医生收益
data.DoctorAmount = orderInquiryService.GetOrderInquiryDoctorAmount(v.InquiryStatus, v.AmountTotal)
dataSlice = append(dataSlice, data)
}
file, err := utils.Export(header, dataSlice)
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
}
// UserPatient 患者列表
func (r *ExportService) UserPatient(d []*model.UserPatient) (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: "string", NumberFmt: "", ColWidth: 30},
{Value: "家庭成员数量", CellType: "string", NumberFmt: "", ColWidth: 18},
{Value: "创建时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
}
var dataSlice []interface{}
for _, v := range d {
data := UserPatientData{
UserName: v.UserName,
Status: utils.UserPatientStatusToString(v.Status),
Avatar: utils.AddOssDomain(v.Avatar),
DisableReason: v.DisableReason,
}
if v.User != nil {
data.Mobile = v.User.Mobile
}
if v.CreatedAt != (model.LocalTime{}) {
t := time.Time(v.CreatedAt)
data.CreatedAt = t
}
if len(v.PatientFamily) > 0 {
data.PatientFamilyCount = fmt.Sprintf("%d", len(v.PatientFamily))
}
dataSlice = append(dataSlice, data)
}
file, err := utils.Export(header, dataSlice)
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
}
// PatientFamily 就诊人列表
func (r *ExportService) PatientFamily(d []*model.PatientFamily) (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: "string", NumberFmt: "", ColWidth: 18},
{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: 20},
{Value: "城市", CellType: "string", NumberFmt: "", ColWidth: 22},
{Value: "区县", CellType: "string", NumberFmt: "", ColWidth: 25},
{Value: "身高cm", CellType: "string", NumberFmt: "", ColWidth: 18},
{Value: "体重kg", CellType: "string", NumberFmt: "", ColWidth: 18},
{Value: "婚姻状况", CellType: "string", NumberFmt: "", ColWidth: 18},
{Value: "民族名称", CellType: "string", NumberFmt: "", ColWidth: 22},
{Value: "职业名称", CellType: "string", NumberFmt: "", ColWidth: 22},
{Value: "创建时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
}
var dataSlice []interface{}
for _, v := range d {
data := PatientFamilyData{
CardName: v.CardName,
Relation: utils.RelationToString(*v.Relation),
Status: utils.PatientFamilyStatusToString(v.Status),
IsDefault: utils.IsDefaultToString(v.IsDefault),
Type: utils.CardTypeToString(v.Type),
IdNumber: v.IdNumber,
Sex: utils.SexToString(v.Sex),
Age: fmt.Sprintf("%d", v.Age),
Province: v.Province,
City: v.City,
County: v.County,
Height: v.Height,
Weight: v.Weight,
MaritalStatus: utils.MaritalStatusToString(v.MaritalStatus),
NationName: v.NationName,
JobName: v.JobName,
}
if v.UserPatient != nil {
data.UserName = v.UserPatient.UserName
if v.UserPatient.User != nil {
data.Mobile = v.UserPatient.User.Mobile
}
}
if v.CreatedAt != (model.LocalTime{}) {
t := time.Time(v.CreatedAt)
data.CreatedAt = t
}
dataSlice = append(dataSlice, data)
}
file, err := utils.Export(header, dataSlice)
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
}
// OrderInquiry 问诊订单
func (r *ExportService) OrderInquiry(d []*model.OrderInquiry) (string, error) {
header := []utils.HeaderCellData{
{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: 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: 25},
{Value: "订单金额", CellType: "float64", NumberFmt: "0.0000", ColWidth: 18},
{Value: "优惠卷总金额", CellType: "float64", NumberFmt: "0.0000", ColWidth: 18},
{Value: "实际付款金额", CellType: "float64", NumberFmt: "0.0000", ColWidth: 18},
{Value: "医生收益", CellType: "float64", NumberFmt: "0.0000", ColWidth: 18},
{Value: "支付时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
{Value: "接诊时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
{Value: "订单完成时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
{Value: "订单结束时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
{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: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
{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: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
}
orderInquiryService := OrderInquiryService{}
var dataSlice []interface{}
for _, v := range d {
data := OrderInquiryForAccount{
InquiryNo: v.InquiryNo,
DoctorName: v.PatientName,
PatientName: v.PatientName,
PatientAge: fmt.Sprintf("%d", v.PatientAge),
EscrowTradeNo: v.EscrowTradeNo,
AmountTotal: v.AmountTotal,
CouponAmountTotal: v.CouponAmountTotal,
PaymentAmountTotal: v.PaymentAmountTotal,
CancelRemarks: v.CancelRemarks,
PatientSex: utils.SexToString(v.PatientSex),
InquiryType: utils.InquiryTypeToString(v.InquiryType),
InquiryMode: utils.InquiryModeToString(v.InquiryMode),
InquiryStatus: utils.InquiryStatusToString(v.InquiryStatus),
IsDelete: utils.IsDeleteToString(v.IsDelete),
InquiryRefundStatus: utils.RefundStatusToString(v.InquiryRefundStatus),
InquiryPayChannel: utils.PayChannelToString(v.InquiryPayChannel),
InquiryPayStatus: utils.PayStatusToString(v.InquiryPayStatus),
StatisticsStatus: utils.StatisticsStatusToString(v.StatisticsStatus),
IsWithdrawal: utils.IsWithdrawalToString(v.IsWithdrawal),
CancelReason: utils.InquiryCancelReasonToString(v.CancelReason),
}
if v.UserDoctor != nil {
// 医生姓名
data.DoctorName = v.UserDoctor.UserName
}
if v.User != nil {
// 用户姓名(患者)
data.UserName = v.User.UserName
// 患者电话
data.PatientMobile = v.User.Mobile
}
if v.PayTime != (model.LocalTime{}) {
t := time.Time(v.PayTime)
data.PayTime = t
}
if v.ReceptionTime != (model.LocalTime{}) {
t := time.Time(v.ReceptionTime)
data.ReceptionTime = t
}
if v.CompleteTime != (model.LocalTime{}) {
t := time.Time(v.CompleteTime)
data.CompleteTime = t
}
if v.FinishTime != (model.LocalTime{}) {
t := time.Time(v.FinishTime)
data.FinishTime = t
}
if v.StatisticsTime != (model.LocalTime{}) {
t := time.Time(v.StatisticsTime)
data.StatisticsTime = t
}
if v.WithdrawalTime != (model.LocalTime{}) {
t := time.Time(v.WithdrawalTime)
data.WithdrawalTime = t
}
if v.CancelTime != (model.LocalTime{}) {
t := time.Time(v.CancelTime)
data.CancelTime = t
}
if v.CreatedAt != (model.LocalTime{}) {
t := time.Time(v.CreatedAt)
data.CreatedAt = t
}
// 处理入账状态0:未入账 1:已入账 2:入账中 3:入账失败 4:入账取消)
entryStatus := orderInquiryService.GetOrderInquiryEntryStatus(v.InquiryStatus, v.StatisticsStatus)
data.EntryStatus = utils.EntryStatusToString(entryStatus)
// 处理医生收益
data.DoctorAmount = orderInquiryService.GetOrderInquiryDoctorAmount(v.InquiryStatus, v.AmountTotal)
dataSlice = append(dataSlice, data)
}
file, err := utils.Export(header, dataSlice)
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
}
// OrderProduct 药品订单
func (r *ExportService) OrderProduct(d []*model.OrderProduct) (string, error) {
header := []utils.HeaderCellData{
{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: 35},
{Value: "处方编号", CellType: "string", NumberFmt: "", ColWidth: 28},
{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: "float64", NumberFmt: "0.0000", ColWidth: 18},
{Value: "实际付款金额", CellType: "float64", NumberFmt: "0.0000", ColWidth: 18},
{Value: "运费金额", CellType: "float64", NumberFmt: "0.0000", 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: "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: 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: 20},
{Value: "城市", CellType: "string", NumberFmt: "", ColWidth: 22},
{Value: "区县", CellType: "string", NumberFmt: "", ColWidth: 25},
{Value: "详细地址", CellType: "string", NumberFmt: "", ColWidth: 35},
{Value: "收货人姓名", CellType: "string", NumberFmt: "", ColWidth: 18},
{Value: "收货人电话", CellType: "string", NumberFmt: "", ColWidth: 18},
{Value: "创建时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
}
var dataSlice []interface{}
for _, v := range d {
data := OrderProductData{
OrderProductNo: v.OrderProductNo,
EscrowTradeNo: v.EscrowTradeNo,
OrderProductStatus: utils.OrderProductStatusToString(v.OrderProductStatus),
PayChannel: utils.PayChannelToString(v.PayChannel),
PayStatus: utils.PayStatusToString(v.PayStatus),
CancelReason: utils.ProductCancelReasonToString(v.CancelReason),
AmountTotal: v.AmountTotal,
PaymentAmountTotal: v.PaymentAmountTotal,
LogisticsFee: v.LogisticsFee,
LogisticsNo: v.LogisticsNo,
LogisticsCompanyCode: v.LogisticsCompanyCode,
Remarks: v.Remarks,
RefundStatus: utils.RefundStatusToString(v.RefundStatus),
CancelRemarks: v.CancelRemarks,
ReportPreStatus: utils.ReportPreStatusToString(v.ReportPreStatus),
ReportPreFailReason: v.ReportPreFailReason,
Province: v.Province,
City: v.City,
County: v.County,
Address: v.Address,
ConsigneeName: v.ConsigneeName,
ConsigneeTel: v.ConsigneeTel,
}
if v.UserDoctor != nil {
// 医生姓名
data.DoctorName = v.UserDoctor.UserName
}
if v.OrderInquiry != nil {
// 患者姓名-就诊人
data.PatientName = v.OrderInquiry.PatientName
// 患者性别-就诊人
data.PatientSex = utils.SexToString(v.OrderInquiry.PatientSex)
// 患者年龄-就诊人
data.PatientAge = fmt.Sprintf("%d", v.OrderInquiry.PatientAge)
}
if v.UserPatient != nil {
if v.UserPatient.User != nil {
data.PatientMobile = v.UserPatient.User.Mobile
}
}
if v.OrderPrescription != nil {
data.PrescriptionCode = v.OrderPrescription.PrescriptionCode
}
if v.DeliveryTime != (model.LocalTime{}) {
t := time.Time(v.DeliveryTime)
data.DeliveryTime = t
}
if v.PayTime != (model.LocalTime{}) {
t := time.Time(v.PayTime)
data.PayTime = t
}
if v.CancelTime != (model.LocalTime{}) {
t := time.Time(v.CancelTime)
data.CancelTime = t
}
if v.ReportPreTime != (model.LocalTime{}) {
t := time.Time(v.ReportPreTime)
data.ReportPreTime = t
}
if v.CreatedAt != (model.LocalTime{}) {
t := time.Time(v.CreatedAt)
data.CreatedAt = t
}
dataSlice = append(dataSlice, data)
}
file, err := utils.Export(header, dataSlice)
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
}
// OrderPrescription 处方
func (r *ExportService) OrderPrescription(d []*model.OrderPrescription) (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: 18},
{Value: "是否药师自动审核", CellType: "string", NumberFmt: "", ColWidth: 18},
{Value: "医生开具处方时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
{Value: "处方过期时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
{Value: "是否删除", CellType: "string", NumberFmt: "", ColWidth: 18},
{Value: "处方编号", CellType: "string", NumberFmt: "", ColWidth: 28},
{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: 30},
{Value: "处方诊断疾病", CellType: "string", NumberFmt: "", ColWidth: 30},
{Value: "创建时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
}
var dataSlice []interface{}
for _, v := range d {
data := OrderPrescriptionData{
PrescriptionStatus: utils.PrescriptionStatusToString(v.PrescriptionStatus),
PharmacistAuditStatus: utils.PharmacistAuditStatusToString(v.PharmacistAuditStatus),
PharmacistFailReason: v.PharmacistFailReason,
PlatformAuditStatus: utils.PlatformAuditStatusToString(v.PlatformAuditStatus),
PlatformFailReason: v.PlatformFailReason,
IsAutoPharVerify: utils.IsAutoPharVerifyToString(v.IsAutoPharVerify),
IsDelete: utils.IsDeleteToString(v.IsDelete),
PrescriptionCode: v.PrescriptionCode,
PatientName: v.PatientName,
PatientSex: utils.SexToString(v.PatientSex),
PatientAge: fmt.Sprintf("%d", v.PatientAge),
DoctorAdvice: v.DoctorAdvice,
}
if v.UserDoctor != nil {
// 医生姓名
data.DoctorName = v.UserDoctor.UserName
}
if v.UserPharmacist != nil {
// 医生姓名
data.PharmacistName = v.UserPharmacist.UserName
}
if v.UserPatient != nil {
if v.UserPatient.User != nil {
data.PatientMobile = v.UserPatient.User.Mobile
}
}
// 处方诊断疾病
if len(v.OrderPrescriptionIcd) > 0 {
var orderPrescriptionIcd []string
for _, icd := range v.OrderPrescriptionIcd {
orderPrescriptionIcd = append(orderPrescriptionIcd, icd.IcdName)
}
data.OrderPrescriptionIcd = strings.Join(orderPrescriptionIcd, "、")
}
if v.PharmacistVerifyTime != (model.LocalTime{}) {
t := time.Time(v.PharmacistVerifyTime)
data.PharmacistVerifyTime = t
}
if v.PlatformFailTime != (model.LocalTime{}) {
t := time.Time(v.PlatformFailTime)
data.PlatformFailTime = t
}
if v.DoctorCreatedTime != (model.LocalTime{}) {
t := time.Time(v.DoctorCreatedTime)
data.DoctorCreatedTime = t
}
if v.ExpiredTime != (model.LocalTime{}) {
t := time.Time(v.ExpiredTime)
data.ExpiredTime = t
}
if v.CreatedAt != (model.LocalTime{}) {
t := time.Time(v.CreatedAt)
data.CreatedAt = t
}
dataSlice = append(dataSlice, data)
}
file, err := utils.Export(header, dataSlice)
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
}