新增 已完成待入账金额\今日预计收入
This commit is contained in:
parent
873b3b1676
commit
8cf0a1e8ab
@ -3,7 +3,6 @@ package controller
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"hospital-admin-api/api/dao"
|
||||
"hospital-admin-api/api/dto"
|
||||
"hospital-admin-api/api/requests"
|
||||
"hospital-admin-api/api/responses"
|
||||
"hospital-admin-api/api/service"
|
||||
@ -45,8 +44,13 @@ func (r *DoctorAccount) GetDoctorAccountPage(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// 处理返回值
|
||||
res := dto.GetDoctorAccountListDto(doctorAccount)
|
||||
// 业务处理
|
||||
doctorAccountService := service.DoctorAccountService{}
|
||||
res, err := doctorAccountService.GetDoctorAccountPage(doctorAccount)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
result := make(map[string]interface{})
|
||||
result["page"] = req.Page
|
||||
|
||||
@ -474,3 +474,12 @@ func (r *OrderInquiryDao) GetOrderInquiryRecordPageSearch(req requests.GetOrderI
|
||||
}
|
||||
return m, totalRecords, nil
|
||||
}
|
||||
|
||||
// GetOrderInquiryTimeList 获取问诊订单列表-时间区间
|
||||
func (r *OrderInquiryDao) GetOrderInquiryTimeList(maps interface{}, startTime, endTime string) (m []*model.OrderInquiry, err error) {
|
||||
err = global.Db.Where(maps).Where("reception_time BETWEEN ? AND ?", startTime, endTime).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
@ -7,17 +7,19 @@ import (
|
||||
)
|
||||
|
||||
type DoctorAccountDto struct {
|
||||
AccountId string `json:"account_id"` // 账户id
|
||||
DoctorId string `json:"doctor_id"` // 医生id
|
||||
TotalAmount float64 `json:"total_amount"` // 总金额(已结束订单的总金额)
|
||||
BalanceAccount float64 `json:"balance_account"` // 账户余额
|
||||
AppliedWithdrawalAmount float64 `json:"applied_withdrawal_amount"` // 提现金额
|
||||
ActualWithdrawalAmount float64 `json:"actual_withdrawal_amount"` // 实际提现金额
|
||||
IncomeTax float64 `json:"income_tax"`
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
|
||||
DoctorName string `json:"doctor_name"` // 医生姓名
|
||||
DoctorMobileMask string `json:"doctor_mobile_mask"` // 医生手机号(掩码)
|
||||
AccountId string `json:"account_id"` // 账户id
|
||||
DoctorId string `json:"doctor_id"` // 医生id
|
||||
TotalAmount float64 `json:"total_amount"` // 总金额(已结束订单的总金额)
|
||||
BalanceAccount float64 `json:"balance_account"` // 账户余额
|
||||
AppliedWithdrawalAmount float64 `json:"applied_withdrawal_amount"` // 提现金额
|
||||
ActualWithdrawalAmount float64 `json:"actual_withdrawal_amount"` // 实际提现金额
|
||||
IncomeTax float64 `json:"income_tax"`
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
|
||||
DoctorName string `json:"doctor_name"` // 医生姓名
|
||||
DoctorMobileMask string `json:"doctor_mobile_mask"` // 医生手机号(掩码)
|
||||
CompletedWaitEntryAmount float64 `json:"completed_wait_entry_amount"` // 已完成待入账金额
|
||||
EstimateIncome float64 `json:"estimate_income"` // 今日预计收入
|
||||
}
|
||||
|
||||
func GetDoctorAccountDto(m *model.DoctorAccount) *DoctorAccountDto {
|
||||
@ -34,13 +36,13 @@ func GetDoctorAccountDto(m *model.DoctorAccount) *DoctorAccountDto {
|
||||
}
|
||||
}
|
||||
|
||||
func GetDoctorAccountListDto(m []*model.DoctorAccount) []DoctorAccountDto {
|
||||
func GetDoctorAccountListDto(m []*model.DoctorAccount) []*DoctorAccountDto {
|
||||
// 处理返回值
|
||||
responses := make([]DoctorAccountDto, len(m))
|
||||
responses := make([]*DoctorAccountDto, len(m))
|
||||
|
||||
if len(m) > 0 {
|
||||
for i, v := range m {
|
||||
response := DoctorAccountDto{
|
||||
response := &DoctorAccountDto{
|
||||
AccountId: fmt.Sprintf("%d", v.AccountId),
|
||||
DoctorId: fmt.Sprintf("%d", v.DoctorId),
|
||||
TotalAmount: v.TotalAmount,
|
||||
@ -62,6 +64,8 @@ func GetDoctorAccountListDto(m []*model.DoctorAccount) []DoctorAccountDto {
|
||||
}
|
||||
}
|
||||
|
||||
// 加载医生已完成待入账金额
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
responses[i] = response
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user