2039 lines
86 KiB
Go
2039 lines
86 KiB
Go
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"
|
||
"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 // 第三方支付流水号
|
||
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 // 科室名称(如未自己输入,填入标准科室名称)
|
||
DepartmentName string // 标准科室名称
|
||
DepartmentCode string // 标准科室编码
|
||
DepartmentCustomMobile string // 科室电话
|
||
HospitalName string // 医院名称
|
||
ServedPatientsNum string // 服务患者数量(订单结束时统计)
|
||
PraiseRate float64 // 好评率(百分制。订单平均评价中超过4-5分的订单总数 / 总订单数 * 5)
|
||
AvgResponseTime float64 // 平均响应时间(分钟制)
|
||
NumberOfFans string // 被关注数量
|
||
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 // 订单编号
|
||
OrderProductStatus string // 订单状态(1:待支付 2:待发货 3:已发货 4:已签收 5:已取消)
|
||
AmountTotal float64 // 订单金额
|
||
CouponAmountTotal float64 // 优惠卷总金额
|
||
PaymentAmountTotal float64 // 实际付款金额
|
||
LogisticsFee float64 // 运费金额
|
||
CreatedAt string // 创建时间
|
||
Remarks string // 订单备注
|
||
DoctorName string // 医生姓名
|
||
DoctorMobile string // 医生电话
|
||
PatientName string // 患者姓名-就诊人
|
||
PatientSex string // 患者性别-就诊人(0:未知 1:男 2:女)
|
||
PatientAge string // 患者年龄-就诊人
|
||
PatientMobile string // 患者电话
|
||
HistoryBuyCount string // 历史购买次数
|
||
HistoryBuyOrderProductNo string // 历史购买单号(逗号分隔)
|
||
EscrowTradeNo string // 第三方支付流水号
|
||
PayStatus string // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||
PayTime string // 支付时间
|
||
PayChannel string // 支付渠道(1:小程序支付 2:微信扫码支付);NOT NULL
|
||
PrescriptionCode string // 处方编号
|
||
ReportPreStatus string // 上报处方平台状态(0:未上报 1:已上报 2:上报失败))
|
||
ReportPreTime string // 上报处方平台时间
|
||
ReportPreFailReason string // 上报失败原因
|
||
LogisticsNo string // 物流编号
|
||
LogisticsCompanyCode string // 快递公司编码
|
||
DeliveryTime string // 发货时间
|
||
ProductItem []OrderProductItemData // 药品列表
|
||
RefundStatus string // 商品订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常)
|
||
CancelTime string // 订单取消时间
|
||
CancelRemarks string // 订单取消备注(自动添加)
|
||
CancelReason string // 订单取消原因(1:主动取消 2:复核失败/库存不足 3:支付超时 4:客服取消)
|
||
ConsigneeName string // 收货人姓名
|
||
ConsigneeTel string // 收货人电话
|
||
Province string // 省份
|
||
City string // 城市
|
||
County string // 区县
|
||
Address string // 详细地址
|
||
}
|
||
|
||
// OrderProductItemData 药品订单-药品列表
|
||
type OrderProductItemData struct {
|
||
ProductName string // 商品名称
|
||
ProductPlatformCode string // 处方平台商品编码
|
||
ProductSpec string // 商品规格
|
||
AvailableDays float64 // 可用天数(3)
|
||
ProductAmount string // 药品数量
|
||
ProductPrice float64 // 商品价格
|
||
}
|
||
|
||
// OrderServicePackageDto 订单-服务包
|
||
type OrderServicePackageDto struct {
|
||
OrderServiceNo string // 系统订单编号
|
||
DoctorName string // 医生姓名
|
||
PatientName string // 患者姓名-就诊人
|
||
PatientSex string // 患者性别-就诊人(0:未知 1:男 2:女)
|
||
PatientAge int // 患者年龄-就诊人
|
||
PatientMobile string // 患者电话
|
||
EscrowTradeNo string // 第三方支付流水号
|
||
OrderServiceType string // 服务包类型(1:健康包 2:随访包)
|
||
OrderServiceStatus string // 订单状态(1:待支付 2:未开始 3:服务中 4:服务完成 5:服务取消)
|
||
PayChannel string // 支付渠道(1:小程序支付 2:微信扫码支付 3:模拟支付)
|
||
PayStatus string // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||
CancelReason string // 取消订单原因(1:医生未接受服务 2:主动取消 4:客服取消 5:支付超时)
|
||
AmountTotal float64 // 订单金额
|
||
PaymentAmountTotal float64 // 实际付款金额
|
||
PayTime time.Time // 支付时间
|
||
StartTime time.Time // 开始服务时间
|
||
FinishTime time.Time // 结束服务时间
|
||
RefundStatus string // 订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常 7:部分退款)
|
||
CancelTime time.Time // 订单取消时间
|
||
CancelRemarks string // 取消订单备注
|
||
AddFinishStatus string // 添加完成订单延迟队列状态(0:未添加 1:已添加 2:添加失败)
|
||
AddFinishTime time.Time // 添加完成订单延迟队列时间
|
||
AddFinishFailReason 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 // 处方编号
|
||
ProductNames string // 药品列表
|
||
PatientName string // 患者姓名-就诊人
|
||
PatientSex string // 患者性别-就诊人(1:男 2:女)
|
||
PatientAge string // 患者年龄-就诊人
|
||
PatientMobile string // 患者电话
|
||
DoctorAdvice string // 医嘱
|
||
OrderPrescriptionIcd string // 处方诊断疾病
|
||
CreatedAt time.Time // 创建时间
|
||
}
|
||
|
||
// ProductData 系统商品
|
||
type ProductData struct {
|
||
ProductName string // 商品名称
|
||
CommonName string // 商品通用名
|
||
Stock string // 库存
|
||
ProductStatus string // 商品状态(1:正常 2:下架)
|
||
IsDelete string // 是否删除(0:否 1:是)
|
||
PrescriptionNum string // 处方可开具的数量
|
||
ProductPrice float64 // 商品价格
|
||
MnemonicCode string // 商品助记码(首字母简拼)
|
||
ProductType string // 药品类型(0:未知 1:中成药 2:西药)
|
||
ProductPlatformCode string // 处方平台商品编码
|
||
ProductPharmacyCode string // 第三方药店商品编码
|
||
ProductSpec string // 商品规格
|
||
LicenseNumber string // 批准文号
|
||
Manufacturer string // 生产厂家
|
||
SingleUnit string // 单次剂量(例:1次1包)
|
||
SingleUse string // 单次用法(例:口服)
|
||
PackagingUnit string // 基本包装单位(例:盒/瓶)
|
||
FrequencyUse string // 使用频率(例:1天3次)
|
||
AvailableDays float64 // 可用天数(3)
|
||
ProductRemarks 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 dataSlice []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: math.Floor(v.AppliedWithdrawalAmount*100) / 100,
|
||
ActualWithdrawalAmount: math.Floor(v.ActualWithdrawalAmount*100) / 100,
|
||
IncomeTax: math.Floor(v.IncomeTax*100) / 100,
|
||
BankName: bankName,
|
||
BankCardCode: bankCardCode,
|
||
BankCardAddress: bankCardAddress,
|
||
ExamineStatus: examineStatus,
|
||
ExamineFailReason: v.ExamineFailReason,
|
||
ExamineTime: examineTime,
|
||
ExamineBy: examineBy,
|
||
PaymentStatus: paymentStatus,
|
||
PaymentTime: paymentTime,
|
||
PaymentBy: paymentBy,
|
||
CreatedAt: createdAt,
|
||
}
|
||
|
||
dataSlice = append(dataSlice, doctorWithdrawalData)
|
||
}
|
||
|
||
file, err := utils.Export(header, dataSlice)
|
||
if err != nil {
|
||
return "", err
|
||
}
|
||
|
||
// 设置文件名字
|
||
now := time.Now()
|
||
dateTimeString := now.Format("20060102150405") // 当前时间字符串
|
||
rand.New(rand.NewSource(time.Now().UnixNano())) // 设置随机数
|
||
ossPath := "admin/export/提现记录" + 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: "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 dataSlice []interface{}
|
||
for _, v := range doctorWithdrawalOrders {
|
||
// 医生姓名
|
||
doctorName := ""
|
||
if v.UserDoctor != nil {
|
||
doctorName = v.UserDoctor.UserName
|
||
}
|
||
|
||
// 就诊人数据
|
||
patientName := "未知"
|
||
patientSex := ""
|
||
patientAge := ""
|
||
patientMobile := ""
|
||
payChannel := "未知"
|
||
inquiryNo := "未知"
|
||
escrowTradeNo := "未知"
|
||
var amountTotal float64
|
||
var couponAmountTotal float64
|
||
var paymentAmountTotal float64
|
||
var doctorAmount float64
|
||
var payTime time.Time
|
||
if v.Order.OrderInquiry != nil {
|
||
patientName = v.Order.OrderInquiry.PatientName
|
||
|
||
// 患者性别
|
||
patientSex = utils.SexToString(v.Order.OrderInquiry.PatientSex)
|
||
|
||
// 患者年龄
|
||
patientAge = fmt.Sprintf("%d", v.Order.OrderInquiry.PatientAge)
|
||
|
||
// 患者电话
|
||
if v.Order.OrderInquiry.User != nil {
|
||
patientMobile = v.Order.OrderInquiry.User.Mobile
|
||
}
|
||
|
||
// 支付渠道
|
||
payChannel = utils.PayChannelToString(v.Order.OrderInquiry.InquiryPayChannel)
|
||
|
||
inquiryNo = v.Order.OrderInquiry.InquiryNo
|
||
escrowTradeNo = v.Order.OrderInquiry.EscrowTradeNo
|
||
|
||
amountTotal = v.Order.OrderInquiry.AmountTotal
|
||
couponAmountTotal = v.Order.OrderInquiry.CouponAmountTotal
|
||
paymentAmountTotal = v.Order.OrderInquiry.PaymentAmountTotal
|
||
|
||
// 医生收益
|
||
doctorAmount, _ = decimal.NewFromFloat(v.Order.OrderInquiry.AmountTotal).Mul(decimal.NewFromFloat(0.75)).Round(2).Float64()
|
||
|
||
// 时间处理
|
||
|
||
if v.Order.OrderInquiry.PayTime != (model.LocalTime{}) {
|
||
t := time.Time(v.Order.OrderInquiry.PayTime)
|
||
payTime = t
|
||
}
|
||
}
|
||
|
||
doctorWithdrawalOrderData := DoctorWithdrawalOrderData{
|
||
DoctorName: doctorName,
|
||
PatientName: patientName,
|
||
PatientSex: patientSex,
|
||
PatientAge: patientAge,
|
||
PatientMobile: patientMobile,
|
||
PayChannel: payChannel,
|
||
PayTime: payTime,
|
||
InquiryNo: inquiryNo,
|
||
EscrowTradeNo: escrowTradeNo,
|
||
AmountTotal: amountTotal,
|
||
CouponAmountTotal: couponAmountTotal,
|
||
PaymentAmountTotal: paymentAmountTotal,
|
||
DoctorAmount: doctorAmount,
|
||
}
|
||
|
||
dataSlice = append(dataSlice, doctorWithdrawalOrderData)
|
||
}
|
||
|
||
file, err := utils.Export(header, dataSlice)
|
||
if err != nil {
|
||
return "", err
|
||
}
|
||
|
||
// 设置文件名字
|
||
now := time.Now()
|
||
dateTimeString := now.Format("20060102150405") // 当前时间字符串
|
||
rand.New(rand.NewSource(time.Now().UnixNano())) // 设置随机数
|
||
ossPath := "admin/export/提现记录-关联订单" + 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: 20},
|
||
{Value: "标准科室名称", CellType: "string", NumberFmt: "", ColWidth: 20},
|
||
{Value: "标准科室编码", CellType: "string", NumberFmt: "", ColWidth: 20},
|
||
{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: 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 dataSlice []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),
|
||
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, ",")
|
||
}
|
||
}
|
||
|
||
// 科室
|
||
if v.DepartmentCustomId != 0 {
|
||
// 获取自定义科室数据
|
||
hospitalDepartmentCustomDao := dao.HospitalDepartmentCustomDao{}
|
||
hospitalDepartmentCustom, _ := hospitalDepartmentCustomDao.GetHospitalDepartmentCustomById(v.DepartmentCustomId)
|
||
if hospitalDepartmentCustom != nil {
|
||
userDoctorData.DepartmentName = hospitalDepartmentCustom.DepartmentName
|
||
userDoctorData.DepartmentCode = hospitalDepartmentCustom.DepartmentCode
|
||
}
|
||
}
|
||
|
||
dataSlice = append(dataSlice, userDoctorData)
|
||
}
|
||
|
||
file, err := utils.Export(header, dataSlice)
|
||
if err != nil {
|
||
return "", err
|
||
}
|
||
|
||
// 设置文件名字
|
||
now := time.Now()
|
||
dateTimeString := now.Format("20060102150405") // 当前时间字符串
|
||
rand.New(rand.NewSource(time.Now().UnixNano())) // 设置随机数
|
||
ossPath := "admin/export/医生列表" + 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.New(rand.NewSource(time.Now().UnixNano())) // 设置随机数
|
||
ossPath := "admin/export/医生银行卡列表" + 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: math.Floor(v.TotalAmount*100) / 100,
|
||
BalanceAccount: math.Floor(v.BalanceAccount*100) / 100,
|
||
AppliedWithdrawalAmount: math.Floor(v.AppliedWithdrawalAmount*100) / 100,
|
||
ActualWithdrawalAmount: math.Floor(v.ActualWithdrawalAmount*100) / 100,
|
||
IncomeTax: math.Floor(v.IncomeTax*100) / 100,
|
||
}
|
||
|
||
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.New(rand.NewSource(time.Now().UnixNano())) // 设置随机数
|
||
ossPath := "admin/export/医生账户" + 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: math.Floor(v.AmountTotal*100) / 100,
|
||
CouponAmountTotal: math.Floor(v.CouponAmountTotal*100) / 100,
|
||
PaymentAmountTotal: math.Floor(v.PaymentAmountTotal*100) / 100,
|
||
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.New(rand.NewSource(time.Now().UnixNano())) // 设置随机数
|
||
ossPath := "admin/export/医生账户-关联订单" + 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.New(rand.NewSource(time.Now().UnixNano())) // 设置随机数
|
||
ossPath := "admin/export/患者列表" + 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,
|
||
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.Relation != nil {
|
||
data.Relation = utils.RelationToString(*v.Relation)
|
||
}
|
||
|
||
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.New(rand.NewSource(time.Now().UnixNano())) // 设置随机数
|
||
ossPath := "admin/export/就诊人列表" + 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: "",
|
||
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.New(rand.NewSource(time.Now().UnixNano())) // 设置随机数
|
||
ossPath := "admin/export/问诊订单" + 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, Colour: "#FFD700"},
|
||
{Value: "订单状态", CellType: "string", NumberFmt: "", ColWidth: 18, Colour: "#FFD700"},
|
||
{Value: "订单金额", CellType: "float64", NumberFmt: "0.0000", ColWidth: 18, Colour: "#FFD700"},
|
||
{Value: "优惠卷总金额", CellType: "float64", NumberFmt: "0.0000", ColWidth: 18, Colour: "#FFD700"},
|
||
{Value: "实际付款金额", CellType: "float64", NumberFmt: "0.0000", ColWidth: 18, Colour: "#FFD700"},
|
||
{Value: "运费金额", CellType: "float64", NumberFmt: "0.0000", ColWidth: 18, Colour: "#FFD700"},
|
||
{Value: "创建时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30, Colour: "#FFD700"},
|
||
{Value: "订单备注", CellType: "string", NumberFmt: "", ColWidth: 18, Colour: "#FFD700"},
|
||
{Value: "医生姓名", CellType: "string", NumberFmt: "", ColWidth: 18, Colour: "#EE9A49"},
|
||
{Value: "医生手机号", CellType: "string", NumberFmt: "", ColWidth: 18, Colour: "#EE9A49"},
|
||
{Value: "患者姓名-就诊人", CellType: "string", NumberFmt: "", ColWidth: 18, Colour: "#40E0D0"},
|
||
{Value: "患者性别-就诊人", CellType: "string", NumberFmt: "", ColWidth: 18, Colour: "#40E0D0"},
|
||
{Value: "患者年龄-就诊人", CellType: "string", NumberFmt: "", ColWidth: 18, Colour: "#40E0D0"},
|
||
{Value: "患者电话", CellType: "string", NumberFmt: "", ColWidth: 18, Colour: "#40E0D0"},
|
||
{Value: "历史购买次数", CellType: "string", NumberFmt: "", ColWidth: 18, Colour: "#40E0D0"},
|
||
{Value: "历史购买单号", CellType: "string", NumberFmt: "", ColWidth: 40, Colour: "#40E0D0"},
|
||
{Value: "第三方支付流水号", CellType: "string", NumberFmt: "", ColWidth: 35, Colour: "#90EE90"},
|
||
{Value: "支付状态", CellType: "string", NumberFmt: "", ColWidth: 18, Colour: "#90EE90"},
|
||
{Value: "支付时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30, Colour: "#90EE90"},
|
||
{Value: "支付渠道", CellType: "string", NumberFmt: "", ColWidth: 18, Colour: "#90EE90"},
|
||
{Value: "处方编号", CellType: "string", NumberFmt: "", ColWidth: 28, Colour: "#FFE4E1"},
|
||
{Value: "上报处方平台状态", CellType: "string", NumberFmt: "", ColWidth: 18, Colour: "#FFE4E1"},
|
||
{Value: "上报处方平台时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30, Colour: "#FFE4E1"},
|
||
{Value: "上报失败原因", CellType: "string", NumberFmt: "", ColWidth: 18, Colour: "#FFE4E1"},
|
||
{Value: "物流编号", CellType: "string", NumberFmt: "", ColWidth: 18, Colour: "#CAE1FF"},
|
||
{Value: "快递公司编码", CellType: "string", NumberFmt: "", ColWidth: 18, Colour: "#CAE1FF"},
|
||
{Value: "发货时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30, Colour: "#CAE1FF"},
|
||
{Value: "药品名称", CellType: "string", NumberFmt: "", ColWidth: 40, Colour: "#AB82FF"},
|
||
{Value: "处方平台编码", CellType: "string", NumberFmt: "", ColWidth: 30, Colour: "#AB82FF"},
|
||
{Value: "商品规格", CellType: "string", NumberFmt: "", ColWidth: 30, Colour: "#AB82FF"},
|
||
{Value: "用药天数", CellType: "string", NumberFmt: "", ColWidth: 18, Colour: "#AB82FF"},
|
||
{Value: "药品数量", CellType: "string", NumberFmt: "", ColWidth: 18, Colour: "#AB82FF"},
|
||
{Value: "药品价格", CellType: "float64", NumberFmt: "0.0000", ColWidth: 18, Colour: "#AB82FF"},
|
||
{Value: "退款状态", CellType: "string", NumberFmt: "", ColWidth: 18, Colour: "#90EE90"},
|
||
{Value: "订单取消时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30, Colour: "#90EE90"},
|
||
{Value: "订单取消备注", CellType: "string", NumberFmt: "", ColWidth: 18, Colour: "#90EE90"},
|
||
{Value: "订单取消原因", CellType: "string", NumberFmt: "", ColWidth: 18, Colour: "#90EE90"},
|
||
{Value: "收货人姓名", CellType: "string", NumberFmt: "", ColWidth: 18, Colour: "#FFDEAD"},
|
||
{Value: "收货人电话", CellType: "string", NumberFmt: "", ColWidth: 18, Colour: "#FFDEAD"},
|
||
{Value: "省份", CellType: "string", NumberFmt: "", ColWidth: 20, Colour: "#FFDEAD"},
|
||
{Value: "城市", CellType: "string", NumberFmt: "", ColWidth: 22, Colour: "#FFDEAD"},
|
||
{Value: "区县", CellType: "string", NumberFmt: "", ColWidth: 25, Colour: "#FFDEAD"},
|
||
{Value: "详细地址", CellType: "string", NumberFmt: "", ColWidth: 35, Colour: "#FFDEAD"},
|
||
}
|
||
|
||
orderProductDao := dao.OrderProductDao{}
|
||
|
||
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,
|
||
CouponAmountTotal: v.CouponAmountTotal,
|
||
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.UserDoctor.User != nil {
|
||
// 医生电话
|
||
data.DoctorMobile = v.UserDoctor.User.Mobile
|
||
}
|
||
}
|
||
|
||
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{}) {
|
||
data.DeliveryTime = time.Time(v.DeliveryTime).Format("2006-01-02 15:04:05")
|
||
}
|
||
|
||
if v.PayTime != (model.LocalTime{}) {
|
||
data.PayTime = time.Time(v.PayTime).Format("2006-01-02 15:04:05")
|
||
}
|
||
|
||
if v.CancelTime != (model.LocalTime{}) {
|
||
data.CancelTime = time.Time(v.CancelTime).Format("2006-01-02 15:04:05")
|
||
}
|
||
|
||
if v.ReportPreTime != (model.LocalTime{}) {
|
||
data.ReportPreTime = time.Time(v.ReportPreTime).Format("2006-01-02 15:04:05")
|
||
}
|
||
|
||
if v.CreatedAt != (model.LocalTime{}) {
|
||
data.CreatedAt = time.Time(v.CreatedAt).Format("2006-01-02 15:04:05")
|
||
}
|
||
|
||
// 历史购买次数
|
||
maps := make(map[string]interface{})
|
||
maps["patient_id"] = v.PatientId
|
||
orderProducts, err := orderProductDao.GetOrderProductNormalList(maps, v.CreatedAt)
|
||
if err != nil {
|
||
return "", err
|
||
}
|
||
data.HistoryBuyCount = fmt.Sprintf("%d", len(orderProducts))
|
||
|
||
// 历史购买单号(逗号分隔)
|
||
var HistoryBuyOrderProductNo []string
|
||
for _, product := range orderProducts {
|
||
HistoryBuyOrderProductNo = append(HistoryBuyOrderProductNo, fmt.Sprintf("%s", product.OrderProductNo))
|
||
}
|
||
|
||
data.HistoryBuyOrderProductNo = strings.Join(HistoryBuyOrderProductNo, ",")
|
||
|
||
// 处理药品列表
|
||
for _, item := range v.OrderProductItem {
|
||
productItem := OrderProductItemData{
|
||
ProductName: item.ProductName,
|
||
ProductPlatformCode: item.ProductPlatformCode,
|
||
ProductSpec: item.ProductSpec,
|
||
AvailableDays: item.Product.AvailableDays,
|
||
ProductAmount: fmt.Sprintf("%d", item.Amount),
|
||
ProductPrice: item.ProductPrice,
|
||
}
|
||
|
||
data.ProductItem = append(data.ProductItem, productItem)
|
||
}
|
||
|
||
dataSlice = append(dataSlice, data)
|
||
}
|
||
|
||
file, err := utils.Export(header, dataSlice)
|
||
if err != nil {
|
||
return "", err
|
||
}
|
||
|
||
// 设置文件名字
|
||
now := time.Now()
|
||
dateTimeString := now.Format("20060102150405") // 当前时间字符串
|
||
rand.New(rand.NewSource(time.Now().UnixNano())) // 设置随机数
|
||
ossPath := "admin/export/药品订单" + 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
|
||
}
|
||
|
||
// OrderServicePackage 服务包订单
|
||
func (r *ExportService) OrderServicePackage(d []*model.OrderServicePackage) (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: 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: "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: "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: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
|
||
}
|
||
|
||
var dataSlice []interface{}
|
||
for _, v := range d {
|
||
data := OrderServicePackageDto{
|
||
OrderServiceNo: v.OrderServiceNo,
|
||
PatientName: v.PatientName,
|
||
PatientSex: utils.SexToString(v.PatientSex),
|
||
PatientAge: v.PatientAge,
|
||
EscrowTradeNo: v.EscrowTradeNo,
|
||
OrderServiceType: utils.OrderServiceTypeToString(v.OrderServiceType),
|
||
OrderServiceStatus: utils.OrderServiceStatusToString(v.OrderServiceStatus),
|
||
PayChannel: utils.PayChannelToString(v.PayChannel),
|
||
PayStatus: utils.PayStatusToString(v.PayStatus),
|
||
CancelReason: utils.OrderServicePackageCancelReasonToString(v.CancelReason),
|
||
AmountTotal: v.AmountTotal,
|
||
PaymentAmountTotal: v.AmountTotal,
|
||
RefundStatus: utils.RefundStatusToString(v.RefundStatus),
|
||
CancelRemarks: v.CancelRemarks,
|
||
AddFinishStatus: utils.AddFinishStatusToString(v.AddFinishStatus),
|
||
AddFinishFailReason: v.AddFinishFailReason,
|
||
}
|
||
|
||
if v.UserDoctor != nil {
|
||
// 医生姓名
|
||
data.DoctorName = v.UserDoctor.UserName
|
||
}
|
||
|
||
if v.UserPatient != nil {
|
||
if v.UserPatient.User != nil {
|
||
data.PatientMobile = v.UserPatient.User.Mobile
|
||
}
|
||
}
|
||
|
||
if v.PayTime != (model.LocalTime{}) {
|
||
t := time.Time(v.PayTime)
|
||
data.PayTime = t
|
||
}
|
||
|
||
if v.StartTime != (model.LocalTime{}) {
|
||
t := time.Time(v.StartTime)
|
||
data.StartTime = t
|
||
}
|
||
|
||
if v.FinishTime != (model.LocalTime{}) {
|
||
t := time.Time(v.FinishTime)
|
||
data.FinishTime = t
|
||
}
|
||
|
||
if v.CancelTime != (model.LocalTime{}) {
|
||
t := time.Time(v.CancelTime)
|
||
data.CancelTime = t
|
||
}
|
||
|
||
if v.AddFinishTime != (model.LocalTime{}) {
|
||
t := time.Time(v.AddFinishTime)
|
||
data.AddFinishTime = 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.New(rand.NewSource(time.Now().UnixNano())) // 设置随机数
|
||
ossPath := "admin/export/服务包订单" + 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: 35},
|
||
{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
|
||
}
|
||
|
||
// 处理厨房药品列表
|
||
orderPrescriptionProductDao := dao.OrderPrescriptionProductDao{}
|
||
orderPrescriptionProducts, err := orderPrescriptionProductDao.GetOrderPrescriptionProductListByOrderPrescriptionId(v.OrderPrescriptionId)
|
||
if err == nil && len(orderPrescriptionProducts) > 0 {
|
||
var products []string
|
||
for _, v := range orderPrescriptionProducts {
|
||
prescriptionProductNum := fmt.Sprintf("%d", v.PrescriptionProductNum)
|
||
product := v.ProductName + "(N:" + prescriptionProductNum + ")"
|
||
products = append(products, product)
|
||
}
|
||
|
||
data.ProductNames = strings.Join(products, "; ")
|
||
}
|
||
|
||
dataSlice = append(dataSlice, data)
|
||
}
|
||
|
||
file, err := utils.Export(header, dataSlice)
|
||
if err != nil {
|
||
return "", err
|
||
}
|
||
|
||
// 设置文件名字
|
||
now := time.Now()
|
||
dateTimeString := now.Format("20060102150405") // 当前时间字符串
|
||
rand.New(rand.NewSource(time.Now().UnixNano())) // 设置随机数
|
||
ossPath := "admin/export/处方" + 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
|
||
}
|
||
|
||
// Product 系统药品
|
||
func (r *ExportService) Product(d []*model.Product) (string, error) {
|
||
header := []utils.HeaderCellData{
|
||
{Value: "商品名称", CellType: "string", NumberFmt: "", ColWidth: 40},
|
||
{Value: "商品通用名", CellType: "string", NumberFmt: "", ColWidth: 40},
|
||
{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: "string", NumberFmt: "", ColWidth: 30},
|
||
{Value: "药品类型", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||
{Value: "处方平台商品编码", CellType: "string", NumberFmt: "", ColWidth: 30},
|
||
{Value: "第三方药店商品编码", CellType: "string", NumberFmt: "", ColWidth: 30},
|
||
{Value: "商品规格", CellType: "string", NumberFmt: "", ColWidth: 30},
|
||
{Value: "批准文号", CellType: "string", NumberFmt: "", ColWidth: 30},
|
||
{Value: "生产厂家", CellType: "string", NumberFmt: "", ColWidth: 40},
|
||
{Value: "单次剂量(例:1次1包)", CellType: "string", NumberFmt: "", ColWidth: 30},
|
||
{Value: "单次用法(例:口服)", CellType: "string", NumberFmt: "", ColWidth: 30},
|
||
{Value: "基本包装单位(例:盒/瓶)", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||
{Value: "使用频率(例:1天3次)", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||
{Value: "可用天数(3)", CellType: "float64", NumberFmt: "0.0000", ColWidth: 18},
|
||
{Value: "商品备注", CellType: "string", NumberFmt: "", ColWidth: 40},
|
||
{Value: "创建时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
|
||
}
|
||
|
||
var dataSlice []interface{}
|
||
for _, v := range d {
|
||
data := ProductData{
|
||
ProductName: v.ProductName,
|
||
CommonName: v.CommonName,
|
||
Stock: "0",
|
||
ProductStatus: utils.IsProductStatusToString(v.ProductStatus),
|
||
IsDelete: utils.IsIsDeleteToString(v.IsDelete),
|
||
PrescriptionNum: fmt.Sprintf("%d", v.PrescriptionNum),
|
||
ProductPrice: v.ProductPrice,
|
||
MnemonicCode: v.MnemonicCode,
|
||
ProductType: utils.IsProductTypeToString(v.ProductType),
|
||
ProductPlatformCode: v.ProductPlatformCode,
|
||
ProductPharmacyCode: v.ProductPharmacyCode,
|
||
ProductSpec: v.ProductSpec,
|
||
LicenseNumber: v.LicenseNumber,
|
||
Manufacturer: v.Manufacturer,
|
||
SingleUnit: v.SingleUnit,
|
||
SingleUse: v.SingleUse,
|
||
PackagingUnit: v.PackagingUnit,
|
||
FrequencyUse: v.FrequencyUse,
|
||
AvailableDays: v.AvailableDays,
|
||
ProductRemarks: v.ProductRemarks,
|
||
}
|
||
|
||
if v.ProductPlatformAmount != nil {
|
||
data.Stock = strconv.Itoa(int(v.ProductPlatformAmount.Stock))
|
||
}
|
||
|
||
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.New(rand.NewSource(time.Now().UnixNano())) // 设置随机数
|
||
ossPath := "admin/export/药品" + 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
|
||
}
|