医生账户-导出
This commit is contained in:
@@ -3,6 +3,7 @@ package service
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/shopspring/decimal"
|
||||
"hospital-admin-api/api/dao"
|
||||
"hospital-admin-api/api/dto"
|
||||
"hospital-admin-api/api/model"
|
||||
@@ -1524,3 +1525,77 @@ func (r *UserDoctorService) GetUserDoctorById(doctorId int64) (g *dto.UserDoctor
|
||||
|
||||
return g, nil
|
||||
}
|
||||
|
||||
// GetDoctorCompletedWaitEntryAmount 获取医生已完成待入账金额
|
||||
func (r *UserDoctorService) GetDoctorCompletedWaitEntryAmount(doctorId int64) (g float64, err error) {
|
||||
// 已完成待入账金额
|
||||
var completedWaitEntryAmount = decimal.NewFromFloat(0)
|
||||
|
||||
// 获取医生全部已完成订单
|
||||
orderInquiryDao := dao.OrderInquiryDao{}
|
||||
|
||||
maps := make(map[string]interface{})
|
||||
maps["doctor_id"] = doctorId
|
||||
maps["inquiry_status"] = 5 // 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||
maps["inquiry_refund_status"] = 0 // 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常)
|
||||
maps["inquiry_pay_status"] = 2 // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||
maps["is_withdrawal"] = 0 // 是否提现(0:否 1:是 2:提现中)
|
||||
orderInquirys, err := orderInquiryDao.GetOrderInquiryList(maps)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
if len(orderInquirys) > 0 {
|
||||
for _, inquiry := range orderInquirys {
|
||||
// 等同于math.Floor((completedWaitEntryAmount+inquiry.AmountTotal)*0.75*100) / 100
|
||||
amountTotal := decimal.NewFromFloat(inquiry.AmountTotal)
|
||||
completedWaitEntryAmount = completedWaitEntryAmount.Add(amountTotal).Mul(decimal.NewFromFloat(0.75)).Mul(decimal.NewFromFloat(100)).Floor().Div(decimal.NewFromFloat(100))
|
||||
}
|
||||
}
|
||||
|
||||
result, _ := completedWaitEntryAmount.Float64()
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// GetDoctorEstimateIncome 获取医生今日预计收入
|
||||
func (r *UserDoctorService) GetDoctorEstimateIncome(doctorId int64) (g float64, err error) {
|
||||
// 今日预计收入
|
||||
var estimateIncome = decimal.NewFromFloat(0)
|
||||
|
||||
// 获取医生当日接诊订单金额
|
||||
today := time.Now()
|
||||
|
||||
// 获取今天的开始时间
|
||||
startOfDay := time.Date(today.Year(), today.Month(), today.Day(), 0, 0, 0, 0, today.Location())
|
||||
|
||||
// 获取今天的结束时间
|
||||
endOfDay := time.Date(today.Year(), today.Month(), today.Day(), 23, 59, 59, 999999999, today.Location())
|
||||
|
||||
// 格式化为数据库的 datetime 格式
|
||||
startTime := startOfDay.Format("2006-01-02 15:04:05")
|
||||
endTime := endOfDay.Format("2006-01-02 15:04:05")
|
||||
|
||||
orderInquiryDao := dao.OrderInquiryDao{}
|
||||
|
||||
maps := make(map[string]interface{})
|
||||
maps["doctor_id"] = doctorId
|
||||
maps["inquiry_refund_status"] = 0 // 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭)
|
||||
maps["inquiry_pay_status"] = 2 // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||
maps["is_withdrawal"] = 0 // 是否提现(0:否 1:是 2:提现中)
|
||||
maps["inquiry_status"] = []int{4, 5} // 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||
orderInquirys, err := orderInquiryDao.GetOrderInquiryTimeList(maps, startTime, endTime)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
if len(orderInquirys) > 0 {
|
||||
for _, inquiry := range orderInquirys {
|
||||
// 等同于math.Floor((estimateIncome+inquiry.AmountTotal)*0.75*100) / 100
|
||||
amountTotal := decimal.NewFromFloat(inquiry.AmountTotal)
|
||||
estimateIncome = estimateIncome.Add(amountTotal).Mul(decimal.NewFromFloat(0.75)).Mul(decimal.NewFromFloat(100)).Floor().Div(decimal.NewFromFloat(100))
|
||||
}
|
||||
}
|
||||
|
||||
result, _ := estimateIncome.Float64()
|
||||
return result, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user