药品订单-导出
This commit is contained in:
+179
-2
@@ -242,6 +242,43 @@ type OrderInquiry struct {
|
||||
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 // 创建时间
|
||||
}
|
||||
|
||||
// DoctorWithdrawal 提现记录
|
||||
func (r *ExportService) DoctorWithdrawal(doctorWithdrawals []*model.DoctorWithdrawal) (string, error) {
|
||||
header := []utils.HeaderCellData{
|
||||
@@ -1007,7 +1044,7 @@ func (r *ExportService) OrderInquiryForAccount(d []*model.OrderInquiry) (string,
|
||||
InquiryPayStatus: utils.PayStatusToString(v.InquiryPayStatus),
|
||||
StatisticsStatus: utils.StatisticsStatusToString(v.StatisticsStatus),
|
||||
IsWithdrawal: utils.IsWithdrawalToString(v.IsWithdrawal),
|
||||
CancelReason: utils.CancelReasonToString(v.CancelReason),
|
||||
CancelReason: utils.InquiryCancelReasonToString(v.CancelReason),
|
||||
}
|
||||
|
||||
if v.UserDoctor != nil {
|
||||
@@ -1293,7 +1330,7 @@ func (r *ExportService) OrderInquiry(d []*model.OrderInquiry) (string, error) {
|
||||
InquiryPayStatus: utils.PayStatusToString(v.InquiryPayStatus),
|
||||
StatisticsStatus: utils.StatisticsStatusToString(v.StatisticsStatus),
|
||||
IsWithdrawal: utils.IsWithdrawalToString(v.IsWithdrawal),
|
||||
CancelReason: utils.CancelReasonToString(v.CancelReason),
|
||||
CancelReason: utils.InquiryCancelReasonToString(v.CancelReason),
|
||||
}
|
||||
|
||||
if v.UserDoctor != nil {
|
||||
@@ -1379,3 +1416,143 @@ func (r *ExportService) OrderInquiry(d []*model.OrderInquiry) (string, error) {
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user