问诊订单-导出
This commit is contained in:
+204
-23
@@ -206,6 +206,42 @@ type PatientFamilyData struct {
|
||||
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 // 创建时间
|
||||
}
|
||||
|
||||
// DoctorWithdrawal 提现记录
|
||||
func (r *ExportService) DoctorWithdrawal(doctorWithdrawals []*model.DoctorWithdrawal) (string, error) {
|
||||
header := []utils.HeaderCellData{
|
||||
@@ -952,15 +988,26 @@ func (r *ExportService) OrderInquiryForAccount(d []*model.OrderInquiry) (string,
|
||||
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,
|
||||
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.CancelReasonToString(v.CancelReason),
|
||||
}
|
||||
|
||||
if v.UserDoctor != nil {
|
||||
@@ -976,16 +1023,6 @@ func (r *ExportService) OrderInquiryForAccount(d []*model.OrderInquiry) (string,
|
||||
data.PatientMobile = v.User.Mobile
|
||||
}
|
||||
|
||||
// 性别
|
||||
data.PatientSex = utils.SexToString(v.PatientSex)
|
||||
data.InquiryType = utils.InquiryTypeToString(v.InquiryType)
|
||||
data.InquiryMode = utils.InquiryModeToString(v.InquiryMode)
|
||||
data.InquiryStatus = utils.InquiryStatusToString(v.InquiryStatus)
|
||||
data.IsDelete = utils.IsDeleteToString(v.IsDelete)
|
||||
data.InquiryRefundStatus = utils.RefundStatusToString(v.InquiryRefundStatus)
|
||||
data.InquiryPayChannel = utils.PayChannelToString(v.InquiryPayChannel)
|
||||
data.InquiryPayStatus = utils.PayStatusToString(v.InquiryPayStatus)
|
||||
|
||||
if v.PayTime != (model.LocalTime{}) {
|
||||
t := time.Time(v.PayTime)
|
||||
data.PayTime = t
|
||||
@@ -1026,10 +1063,6 @@ func (r *ExportService) OrderInquiryForAccount(d []*model.OrderInquiry) (string,
|
||||
data.CreatedAt = t
|
||||
}
|
||||
|
||||
data.StatisticsStatus = utils.StatisticsStatusToString(v.StatisticsStatus)
|
||||
data.IsWithdrawal = utils.IsWithdrawalToString(v.IsWithdrawal)
|
||||
data.CancelReason = utils.CancelReasonToString(v.CancelReason)
|
||||
|
||||
// 处理入账状态(0:未入账 1:已入账 2:入账中 3:入账失败 4:入账取消)
|
||||
entryStatus := orderInquiryService.GetOrderInquiryEntryStatus(v.InquiryStatus, v.StatisticsStatus)
|
||||
data.EntryStatus = utils.EntryStatusToString(entryStatus)
|
||||
@@ -1198,3 +1231,151 @@ func (r *ExportService) PatientFamily(d []*model.PatientFamily) (string, error)
|
||||
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.CancelReasonToString(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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user