新增 已完成待入账金额\今日预计收入
This commit is contained in:
@@ -4,6 +4,9 @@ import (
|
||||
"errors"
|
||||
"hospital-admin-api/api/dao"
|
||||
"hospital-admin-api/api/dto"
|
||||
"hospital-admin-api/api/model"
|
||||
"math"
|
||||
"time"
|
||||
)
|
||||
|
||||
// DoctorAccountService 医生账户
|
||||
@@ -32,6 +35,62 @@ func (r *DoctorAccountService) GetDoctorAccount(doctorId int64) (g *dto.DoctorAc
|
||||
return nil, errors.New(err.Error())
|
||||
}
|
||||
|
||||
// 已完成待入账金额
|
||||
var completedWaitEntryAmount float64
|
||||
|
||||
// 今日预计收入
|
||||
var estimateIncome float64
|
||||
|
||||
// 获取医生全部已完成订单
|
||||
orderInquiryDao := dao.OrderInquiryDao{}
|
||||
|
||||
maps := make(map[string]interface{})
|
||||
maps["doctor_id"] = userDoctor.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 nil, err
|
||||
}
|
||||
|
||||
if len(orderInquirys) > 0 {
|
||||
for _, inquiry := range orderInquirys {
|
||||
completedWaitEntryAmount = math.Floor((completedWaitEntryAmount+inquiry.AmountTotal)*0.75*100) / 100
|
||||
}
|
||||
}
|
||||
|
||||
// 获取医生当日接诊订单金额
|
||||
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")
|
||||
|
||||
maps = make(map[string]interface{})
|
||||
maps["doctor_id"] = userDoctor.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 nil, err
|
||||
}
|
||||
|
||||
if len(orderInquirys) > 0 {
|
||||
for _, inquiry := range orderInquirys {
|
||||
estimateIncome = math.Floor((estimateIncome+inquiry.AmountTotal)*0.75*100) / 100
|
||||
}
|
||||
}
|
||||
|
||||
// 处理返回值
|
||||
g = dto.GetDoctorAccountDto(doctorAccount)
|
||||
|
||||
@@ -41,5 +100,77 @@ func (r *DoctorAccountService) GetDoctorAccount(doctorId int64) (g *dto.DoctorAc
|
||||
// 加载医生手机号(掩码)
|
||||
g.LoadDoctorMobileMask(user)
|
||||
|
||||
g.CompletedWaitEntryAmount = completedWaitEntryAmount
|
||||
g.EstimateIncome = estimateIncome
|
||||
|
||||
return g, nil
|
||||
}
|
||||
|
||||
// GetDoctorAccountPage 获取医生账户列表-分页
|
||||
func (r *DoctorAccountService) GetDoctorAccountPage(doctorAccounts []*model.DoctorAccount) (g []*dto.DoctorAccountDto, err error) {
|
||||
// 处理返回值
|
||||
res := dto.GetDoctorAccountListDto(doctorAccounts)
|
||||
|
||||
// 已完成待入账金额
|
||||
var completedWaitEntryAmount float64
|
||||
|
||||
// 今日预计收入
|
||||
var estimateIncome float64
|
||||
|
||||
for _, v := range res {
|
||||
// 获取医生全部已完成订单
|
||||
orderInquiryDao := dao.OrderInquiryDao{}
|
||||
|
||||
maps := make(map[string]interface{})
|
||||
maps["doctor_id"] = v.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 nil, err
|
||||
}
|
||||
|
||||
if len(orderInquirys) > 0 {
|
||||
for _, inquiry := range orderInquirys {
|
||||
completedWaitEntryAmount = math.Floor((completedWaitEntryAmount+inquiry.AmountTotal)*0.75*100) / 100
|
||||
}
|
||||
}
|
||||
|
||||
// 获取医生当日接诊订单金额
|
||||
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")
|
||||
|
||||
maps = make(map[string]interface{})
|
||||
maps["doctor_id"] = v.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 nil, err
|
||||
}
|
||||
|
||||
if len(orderInquirys) > 0 {
|
||||
for _, inquiry := range orderInquirys {
|
||||
estimateIncome = math.Floor((estimateIncome+inquiry.AmountTotal)*0.75*100) / 100
|
||||
}
|
||||
}
|
||||
|
||||
v.CompletedWaitEntryAmount = completedWaitEntryAmount
|
||||
v.EstimateIncome = estimateIncome
|
||||
}
|
||||
|
||||
return res, err
|
||||
}
|
||||
|
||||
@@ -362,3 +362,45 @@ func (r *OrderInquiryService) GetOrderInquiryRecord(orderInquiryId int64) (g *dt
|
||||
|
||||
return g, nil
|
||||
}
|
||||
|
||||
// GetOrderInquiryRecord 问诊记录详情
|
||||
func (r *OrderInquiryService) GetDoctor(orderInquiryId int64) (g *dto.OrderInquiryDto, err error) {
|
||||
// 获取问诊订单数据
|
||||
orderInquiryDao := dao.OrderInquiryDao{}
|
||||
orderInquiry, err := orderInquiryDao.GetOrderInquiryPreloadById(orderInquiryId)
|
||||
if err != nil || orderInquiry == nil {
|
||||
return nil, errors.New(err.Error())
|
||||
}
|
||||
|
||||
// 获取问诊病例
|
||||
orderInquiryCaseDao := dao.OrderInquiryCaseDao{}
|
||||
orderInquiryCase, err := orderInquiryCaseDao.GetOrderInquiryCaseByOrderInquiryId(orderInquiryId)
|
||||
if orderInquiryCase == nil {
|
||||
return nil, errors.New("数据错误,无问诊病例")
|
||||
}
|
||||
|
||||
// 获取医生数据
|
||||
userDoctorService := UserDoctorService{}
|
||||
userDoctor, err := userDoctorService.GetUserDoctorById(orderInquiry.DoctorId)
|
||||
if err != nil {
|
||||
return nil, errors.New(err.Error())
|
||||
}
|
||||
|
||||
// 获取聊天记录
|
||||
messageImDao := dao.MessageImDao{}
|
||||
messageIms, err := messageImDao.GetMessageImByOrderInquiryId(orderInquiryId)
|
||||
|
||||
// 处理返回值
|
||||
g = dto.GetOrderInquiryRecordDto(orderInquiry)
|
||||
|
||||
// 加载医生数据
|
||||
g.UserDoctor = userDoctor
|
||||
|
||||
// 加载问诊病例
|
||||
g.LoadMaskOrderInquiryCase(orderInquiryCase)
|
||||
|
||||
// 加载聊天记录
|
||||
g.LoadMessageIm(messageIms)
|
||||
|
||||
return g, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user