医生账户-导出

This commit is contained in:
2023-11-14 14:43:39 +08:00
parent 1237e02514
commit f7f1182d14
10 changed files with 285 additions and 81 deletions
+80
View File
@@ -111,6 +111,7 @@ type UserDoctorData struct {
BankCardAddress string // 开户银行地址
}
// DoctorBankCardData 医生银行卡列表
type DoctorBankCardData struct {
DoctorName string // 医生姓名
DoctorMobile string // 医生手机号
@@ -122,6 +123,19 @@ type DoctorBankCardData struct {
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 // 今日预计收入
}
// DoctorWithdrawal 提现记录
func (r *ExportService) DoctorWithdrawal(doctorWithdrawals []*model.DoctorWithdrawal) (string, error) {
header := []utils.HeaderCellData{
@@ -759,3 +773,69 @@ func (r *ExportService) UserDoctorBankCard(d []*model.DoctorBankCard) (string, e
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: v.TotalAmount,
BalanceAccount: v.BalanceAccount,
AppliedWithdrawalAmount: v.AppliedWithdrawalAmount,
ActualWithdrawalAmount: v.ActualWithdrawalAmount,
IncomeTax: v.IncomeTax,
}
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.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
}