导出新增了合并单元格,样式处理

This commit is contained in:
2024-09-25 11:56:44 +08:00
parent e54adba26a
commit 3a124aa778
5 changed files with 768 additions and 326 deletions
+139 -98
View File
@@ -245,40 +245,54 @@ type OrderInquiry struct {
// 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 // 快递公司编码
ProductNames 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 // 创建时间
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 订单-服务包
@@ -383,7 +397,7 @@ func (r *ExportService) DoctorWithdrawal(doctorWithdrawals []*model.DoctorWithdr
{Value: "申请时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
}
var interfaceSlice []interface{}
var dataSlice []interface{}
for _, v := range doctorWithdrawals {
// 审核状态
examineStatus := utils.WithdrawalExamineStatusToString(v.ExamineStatus)
@@ -480,10 +494,10 @@ func (r *ExportService) DoctorWithdrawal(doctorWithdrawals []*model.DoctorWithdr
CreatedAt: createdAt,
}
interfaceSlice = append(interfaceSlice, doctorWithdrawalData)
dataSlice = append(dataSlice, doctorWithdrawalData)
}
file, err := utils.Export(header, interfaceSlice)
file, err := utils.Export(header, dataSlice)
if err != nil {
return "", err
}
@@ -522,7 +536,7 @@ func (r *ExportService) DoctorWithdrawalOrder(doctorWithdrawalOrders []*model.Do
{Value: "医生收益", CellType: "float", NumberFmt: "0.0000", ColWidth: 18},
}
var interfaceSlice []interface{}
var dataSlice []interface{}
for _, v := range doctorWithdrawalOrders {
// 医生姓名
doctorName := ""
@@ -594,10 +608,10 @@ func (r *ExportService) DoctorWithdrawalOrder(doctorWithdrawalOrders []*model.Do
DoctorAmount: doctorAmount,
}
interfaceSlice = append(interfaceSlice, doctorWithdrawalOrderData)
dataSlice = append(dataSlice, doctorWithdrawalOrderData)
}
file, err := utils.Export(header, interfaceSlice)
file, err := utils.Export(header, dataSlice)
if err != nil {
return "", err
}
@@ -673,7 +687,7 @@ func (r *ExportService) UserDoctor(userDoctors []*model.UserDoctor) (string, err
{Value: "银行地址", CellType: "string", NumberFmt: "", ColWidth: 46},
}
var interfaceSlice []interface{}
var dataSlice []interface{}
for _, v := range userDoctors {
userDoctorData := UserDoctorData{
UserName: v.UserName,
@@ -914,10 +928,10 @@ func (r *ExportService) UserDoctor(userDoctors []*model.UserDoctor) (string, err
}
}
interfaceSlice = append(interfaceSlice, userDoctorData)
dataSlice = append(dataSlice, userDoctorData)
}
file, err := utils.Export(header, interfaceSlice)
file, err := utils.Export(header, dataSlice)
if err != nil {
return "", err
}
@@ -1510,42 +1524,53 @@ func (r *ExportService) OrderInquiry(d []*model.OrderInquiry) (string, error) {
// 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: "string", NumberFmt: "", ColWidth: 35},
{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},
{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{
@@ -1556,6 +1581,7 @@ func (r *ExportService) OrderProduct(d []*model.OrderProduct) (string, error) {
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,
@@ -1576,6 +1602,11 @@ func (r *ExportService) OrderProduct(d []*model.OrderProduct) (string, error) {
if v.UserDoctor != nil {
// 医生姓名
data.DoctorName = v.UserDoctor.UserName
if v.UserDoctor.User != nil {
// 医生电话
data.DoctorMobile = v.UserDoctor.User.Mobile
}
}
if v.OrderInquiry != nil {
@@ -1600,44 +1631,54 @@ func (r *ExportService) OrderProduct(d []*model.OrderProduct) (string, error) {
}
if v.DeliveryTime != (model.LocalTime{}) {
t := time.Time(v.DeliveryTime)
data.DeliveryTime = t
data.DeliveryTime = time.Time(v.DeliveryTime).Format("2006-01-02 15:04:05")
}
if v.PayTime != (model.LocalTime{}) {
t := time.Time(v.PayTime)
data.PayTime = t
data.PayTime = time.Time(v.PayTime).Format("2006-01-02 15:04:05")
}
if v.CancelTime != (model.LocalTime{}) {
t := time.Time(v.CancelTime)
data.CancelTime = t
data.CancelTime = time.Time(v.CancelTime).Format("2006-01-02 15:04:05")
}
if v.ReportPreTime != (model.LocalTime{}) {
t := time.Time(v.ReportPreTime)
data.ReportPreTime = t
data.ReportPreTime = time.Time(v.ReportPreTime).Format("2006-01-02 15:04:05")
}
if v.CreatedAt != (model.LocalTime{}) {
t := time.Time(v.CreatedAt)
data.CreatedAt = t
data.CreatedAt = time.Time(v.CreatedAt).Format("2006-01-02 15:04:05")
}
// 处理药品列表
orderProductItemDao := dao.OrderProductItemDao{}
orderProductItems, err := orderProductItemDao.GetOrderProductItemByOrderProductId(v.OrderProductId)
if err == nil || len(orderProductItems) > 0 {
var products []string
for _, v := range orderProductItems {
amount := fmt.Sprintf("%d", v.Amount)
productPrice := fmt.Sprintf("%.2f", v.ProductPrice)
product := v.ProductName + "(N:" + amount + " " + "P:" + productPrice + ")"
// 历史购买次数
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))
products = append(products, product)
// 历史购买单号(逗号分隔)
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.ProductNames = strings.Join(products, "; ")
data.ProductItem = append(data.ProductItem, productItem)
}
dataSlice = append(dataSlice, data)