医生银行卡列表-导出
This commit is contained in:
@@ -111,6 +111,17 @@ type UserDoctorData struct {
|
||||
BankCardAddress string // 开户银行地址
|
||||
}
|
||||
|
||||
type DoctorBankCardData struct {
|
||||
DoctorName string // 医生姓名
|
||||
DoctorMobile string // 医生手机号
|
||||
BankName string // 银行名称
|
||||
BankCardCode string // 银行卡号
|
||||
Province string // 省份
|
||||
City string // 城市
|
||||
County string // 区县
|
||||
CreatedAt time.Time // 创建时间
|
||||
}
|
||||
|
||||
// DoctorWithdrawal 提现记录
|
||||
func (r *ExportService) DoctorWithdrawal(doctorWithdrawals []*model.DoctorWithdrawal) (string, error) {
|
||||
header := []utils.HeaderCellData{
|
||||
@@ -682,3 +693,69 @@ func (r *ExportService) UserDoctor(userDoctors []*model.UserDoctor) (string, err
|
||||
ossPath = utils.AddOssDomain("/" + ossPath)
|
||||
return ossPath, nil
|
||||
}
|
||||
|
||||
// UserDoctorBankCard 医生银行卡列表
|
||||
func (r *ExportService) UserDoctorBankCard(d []*model.DoctorBankCard) (string, error) {
|
||||
header := []utils.HeaderCellData{
|
||||
{Value: "医生姓名", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "医生手机号", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "银行名称", CellType: "string", NumberFmt: "", ColWidth: 22},
|
||||
{Value: "银行卡号", CellType: "string", NumberFmt: "", ColWidth: 25},
|
||||
{Value: "省份", CellType: "string", NumberFmt: "", ColWidth: 20},
|
||||
{Value: "城市", CellType: "string", NumberFmt: "", ColWidth: 22},
|
||||
{Value: "区县", CellType: "string", NumberFmt: "", ColWidth: 25},
|
||||
{Value: "创建时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
|
||||
}
|
||||
|
||||
var dataSlice []interface{}
|
||||
for _, v := range d {
|
||||
data := DoctorBankCardData{
|
||||
BankCardCode: v.BankCardCode,
|
||||
Province: v.Province,
|
||||
City: v.City,
|
||||
County: v.County,
|
||||
}
|
||||
|
||||
if v.UserDoctor != nil {
|
||||
// 医生姓名
|
||||
data.DoctorName = v.UserDoctor.UserName
|
||||
|
||||
if v.UserDoctor.User != nil {
|
||||
// 手机号
|
||||
data.DoctorMobile = v.UserDoctor.User.Mobile
|
||||
}
|
||||
}
|
||||
|
||||
if v.BasicBank != nil {
|
||||
data.BankName = v.BasicBank.BankName
|
||||
}
|
||||
|
||||
// 创建时间
|
||||
if v.CreatedAt != (model.LocalTime{}) {
|
||||
t := time.Time(v.CreatedAt)
|
||||
data.CreatedAt = t
|
||||
}
|
||||
|
||||
dataSlice = append(dataSlice, data)
|
||||
}
|
||||
|
||||
file, err := utils.Export(header, dataSlice)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
// 设置文件名字
|
||||
now := time.Now()
|
||||
dateTimeString := now.Format("20060102150405") // 当前时间字符串
|
||||
rand.Seed(time.Now().UnixNano()) // 设置随机数
|
||||
ossPath := "admin/export/output" + dateTimeString + fmt.Sprintf("%d", rand.Intn(9000)+1000) + ".xlsx"
|
||||
|
||||
// 上传oss
|
||||
_, err = aliyun.PutObjectByte(ossPath, file.Bytes())
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
ossPath = utils.AddOssDomain("/" + ossPath)
|
||||
return ossPath, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user