新增 提现详情-关联订单列表-分页
This commit is contained in:
parent
2e4363a7d4
commit
dda86b626d
@ -85,7 +85,7 @@ func (r *DoctorWithdrawal) GetDoctorWithdrawal(c *gin.Context) {
|
|||||||
// GetDoctorWithdrawalOrderPage 提现详情-关联订单列表-分页
|
// GetDoctorWithdrawalOrderPage 提现详情-关联订单列表-分页
|
||||||
func (r *DoctorWithdrawal) GetDoctorWithdrawalOrderPage(c *gin.Context) {
|
func (r *DoctorWithdrawal) GetDoctorWithdrawalOrderPage(c *gin.Context) {
|
||||||
doctorWithdrawalRequest := requests.DoctorWithdrawalRequest{}
|
doctorWithdrawalRequest := requests.DoctorWithdrawalRequest{}
|
||||||
req := doctorWithdrawalRequest.GetDoctorWithdrawalPage
|
req := doctorWithdrawalRequest.GetDoctorWithdrawalOrderPage
|
||||||
if err := c.ShouldBind(&req); err != nil {
|
if err := c.ShouldBind(&req); err != nil {
|
||||||
responses.FailWithMessage(err.Error(), c)
|
responses.FailWithMessage(err.Error(), c)
|
||||||
return
|
return
|
||||||
@ -105,15 +105,15 @@ func (r *DoctorWithdrawal) GetDoctorWithdrawalOrderPage(c *gin.Context) {
|
|||||||
req.PageSize = 20
|
req.PageSize = 20
|
||||||
}
|
}
|
||||||
|
|
||||||
doctorWithdrawalDao := dao.DoctorWithdrawalDao{}
|
doctorWithdrawalOrderDao := dao.DoctorWithdrawalOrderDao{}
|
||||||
doctorWithdrawal, total, err := doctorWithdrawalDao.GetDoctorWithdrawalPageSearch(req, req.Page, req.PageSize)
|
doctorWithdrawalOrder, total, err := doctorWithdrawalOrderDao.GetDoctorWithdrawalOrderPageSearch(req, req.Page, req.PageSize)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
responses.FailWithMessage(err.Error(), c)
|
responses.FailWithMessage(err.Error(), c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理返回值
|
// 处理返回值
|
||||||
res := dto.GetDoctorWithdrawalListDto(doctorWithdrawal)
|
res := dto.GetDoctorWithdrawalOrderListDto(doctorWithdrawalOrder)
|
||||||
|
|
||||||
result := make(map[string]interface{})
|
result := make(map[string]interface{})
|
||||||
result["page"] = req.Page
|
result["page"] = req.Page
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
package dao
|
package dao
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"gorm.io/gorm"
|
||||||
"hospital-admin-api/api/model"
|
"hospital-admin-api/api/model"
|
||||||
|
"hospital-admin-api/api/requests"
|
||||||
"hospital-admin-api/global"
|
"hospital-admin-api/global"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -9,7 +11,7 @@ type DoctorWithdrawalOrderDao struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetDoctorWithdrawalOrderById 获取医生提现关联订单数据-id
|
// GetDoctorWithdrawalOrderById 获取医生提现关联订单数据-id
|
||||||
func (r *DoctorWithdrawalBankDao) GetDoctorWithdrawalOrderById(withdrawalBankId int64) (m *model.DoctorWithdrawalBank, err error) {
|
func (r *DoctorWithdrawalOrderDao) GetDoctorWithdrawalOrderById(withdrawalBankId int64) (m *model.DoctorWithdrawalBank, err error) {
|
||||||
err = global.Db.First(&m, withdrawalBankId).Error
|
err = global.Db.First(&m, withdrawalBankId).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -18,10 +20,43 @@ func (r *DoctorWithdrawalBankDao) GetDoctorWithdrawalOrderById(withdrawalBankId
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetDoctorWithdrawalOrderByWithdrawalId 获取医生提现关联订单数据-提现id
|
// GetDoctorWithdrawalOrderByWithdrawalId 获取医生提现关联订单数据-提现id
|
||||||
func (r *DoctorWithdrawalBankDao) GetDoctorWithdrawalOrderByWithdrawalId(withdrawalId int64) (m *model.DoctorWithdrawalBank, err error) {
|
func (r *DoctorWithdrawalOrderDao) GetDoctorWithdrawalOrderByWithdrawalId(withdrawalId int64) (m *model.DoctorWithdrawalBank, err error) {
|
||||||
err = global.Db.Where("withdrawal_id = ?", withdrawalId).First(&m).Error
|
err = global.Db.Where("withdrawal_id = ?", withdrawalId).First(&m).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return m, nil
|
return m, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetDoctorWithdrawalOrderPageSearch 获取医生提现列表-分页
|
||||||
|
func (r *DoctorWithdrawalOrderDao) GetDoctorWithdrawalOrderPageSearch(req requests.GetDoctorWithdrawalOrderPage, page, pageSize int) (m []*model.DoctorWithdrawalOrder, total int64, err error) {
|
||||||
|
var totalRecords int64
|
||||||
|
|
||||||
|
// 构建查询条件
|
||||||
|
query := global.Db.Model(&model.DoctorWithdrawalOrder{})
|
||||||
|
|
||||||
|
// 医生
|
||||||
|
query = query.Preload("UserDoctor", func(db *gorm.DB) *gorm.DB {
|
||||||
|
return db.Omit("open_id", "union_id", "wx_session_key")
|
||||||
|
})
|
||||||
|
|
||||||
|
// 订单
|
||||||
|
query = query.Preload("OrderInquiry")
|
||||||
|
|
||||||
|
// 患者
|
||||||
|
query = query.Preload("OrderInquiry.User")
|
||||||
|
|
||||||
|
// 排序
|
||||||
|
query = query.Order("created_at desc")
|
||||||
|
|
||||||
|
// 查询总数量
|
||||||
|
if err := query.Count(&totalRecords).Error; err != nil {
|
||||||
|
return nil, 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = query.Scopes(model.Paginate(page, pageSize)).Find(&m).Error
|
||||||
|
if err != nil {
|
||||||
|
return nil, 0, err
|
||||||
|
}
|
||||||
|
return m, totalRecords, nil
|
||||||
|
}
|
||||||
|
|||||||
212
api/dto/DoctorWithdrawalOrder.go
Normal file
212
api/dto/DoctorWithdrawalOrder.go
Normal file
@ -0,0 +1,212 @@
|
|||||||
|
package dto
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"hospital-admin-api/api/dao"
|
||||||
|
"hospital-admin-api/api/model"
|
||||||
|
"hospital-admin-api/utils"
|
||||||
|
"math"
|
||||||
|
)
|
||||||
|
|
||||||
|
type DoctorWithdrawalOrderDto struct {
|
||||||
|
WithdrawalOrderId string `json:"withdrawal_order_id"` // 主键id
|
||||||
|
WithdrawalId string `json:"withdrawal_id"`
|
||||||
|
DoctorId string `json:"doctor_id"` // 医生id;NOT NULL
|
||||||
|
OrderInquiryId string `json:"order_inquiry_id"` // 订单-问诊id
|
||||||
|
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||||
|
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
|
||||||
|
OrderInquiry *OrderInquiryDto `json:"order_inquiry"` // 关联问诊订单
|
||||||
|
UserDoctor *UserDoctorDto `json:"user_doctor"` // 关联医生
|
||||||
|
DoctorName string `json:"doctor_name"` // 医生姓名
|
||||||
|
PatientNameMask string `json:"patient_name_mask"` // 患者姓名-就诊人(掩码)
|
||||||
|
PatientSex int `json:"patient_sex"` // 患者性别-就诊人(0:未知 1:男 2:女)
|
||||||
|
PatientAge int `json:"patient_age"` // 患者年龄-就诊人
|
||||||
|
PatientMobileMask string `json:"patient_mobile_mask"` // 患者电话(掩码)
|
||||||
|
DoctorAmount float64 `json:"doctor_amount"` // 医生收益
|
||||||
|
PayChannel int `json:"pay_channel"` // 支付渠道(1:小程序支付 2:微信扫码支付 3:模拟支付)
|
||||||
|
PayTime model.LocalTime `json:"pay_time"` // 支付时间
|
||||||
|
InquiryNo string `json:"inquiry_no"` // 系统订单编号
|
||||||
|
EscrowTradeNo string `json:"escrow_trade_no"` // 第三方支付流水号
|
||||||
|
InquiryStatus int `json:"inquiry_status"` // 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetDoctorWithdrawalOrderDto(m *model.DoctorWithdrawalOrder) *DoctorWithdrawalOrderDto {
|
||||||
|
return &DoctorWithdrawalOrderDto{
|
||||||
|
WithdrawalOrderId: fmt.Sprintf("%d", m.WithdrawalOrderId),
|
||||||
|
WithdrawalId: fmt.Sprintf("%d", m.WithdrawalId),
|
||||||
|
DoctorId: fmt.Sprintf("%d", m.DoctorId),
|
||||||
|
OrderInquiryId: fmt.Sprintf("%d", m.OrderInquiryId),
|
||||||
|
CreatedAt: m.CreatedAt,
|
||||||
|
UpdatedAt: m.UpdatedAt,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetDoctorWithdrawalOrderListDto(m []*model.DoctorWithdrawalOrder) []*DoctorWithdrawalOrderDto {
|
||||||
|
// 处理返回值
|
||||||
|
responses := make([]*DoctorWithdrawalOrderDto, len(m))
|
||||||
|
|
||||||
|
if len(m) > 0 {
|
||||||
|
for i, v := range m {
|
||||||
|
response := &DoctorWithdrawalOrderDto{
|
||||||
|
WithdrawalOrderId: fmt.Sprintf("%d", v.WithdrawalOrderId),
|
||||||
|
WithdrawalId: fmt.Sprintf("%d", v.WithdrawalId),
|
||||||
|
DoctorId: fmt.Sprintf("%d", v.DoctorId),
|
||||||
|
OrderInquiryId: fmt.Sprintf("%d", v.OrderInquiryId),
|
||||||
|
CreatedAt: v.CreatedAt,
|
||||||
|
UpdatedAt: v.UpdatedAt,
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载医生名称
|
||||||
|
if v.UserDoctor != nil {
|
||||||
|
response.LoadDoctorName(v.UserDoctor)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载患者姓名-就诊人(掩码)
|
||||||
|
if v.OrderInquiry != nil {
|
||||||
|
response.LoadPatientNameMask(v.OrderInquiry)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载患者性别-就诊人
|
||||||
|
if v.OrderInquiry != nil {
|
||||||
|
response.LoadPatientSex(v.OrderInquiry)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载患者年龄-就诊人
|
||||||
|
if v.OrderInquiry != nil {
|
||||||
|
response.LoadPatientAge(v.OrderInquiry)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载患者电话(掩码)
|
||||||
|
if v.OrderInquiry != nil {
|
||||||
|
response.LoadPatientMobileMask(v.OrderInquiry)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载支付渠道
|
||||||
|
if v.OrderInquiry != nil {
|
||||||
|
response.LoadPayChannel(v.OrderInquiry)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载支付时间
|
||||||
|
if v.OrderInquiry != nil {
|
||||||
|
response.LoadPayTime(v.OrderInquiry)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载系统订单编号
|
||||||
|
if v.OrderInquiry != nil {
|
||||||
|
response.LoadInquiryNo(v.OrderInquiry)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载第三方支付流水号
|
||||||
|
if v.OrderInquiry != nil {
|
||||||
|
response.LoadEscrowTradeNo(v.OrderInquiry)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载问诊订单状态
|
||||||
|
if v.OrderInquiry != nil {
|
||||||
|
response.LoadInquiryStatus(v.OrderInquiry)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载医生收益
|
||||||
|
if v.OrderInquiry != nil {
|
||||||
|
response.LoadDoctorAmount(v.OrderInquiry)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将转换后的结构体添加到新切片中
|
||||||
|
responses[i] = response
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return responses
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoadDoctorName 加载医生名称
|
||||||
|
func (r *DoctorWithdrawalOrderDto) LoadDoctorName(m *model.UserDoctor) *DoctorWithdrawalOrderDto {
|
||||||
|
if m != nil {
|
||||||
|
r.DoctorName = m.UserName
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoadPatientNameMask 加载患者姓名-就诊人(掩码)
|
||||||
|
func (r *DoctorWithdrawalOrderDto) LoadPatientNameMask(m *model.OrderInquiry) *DoctorWithdrawalOrderDto {
|
||||||
|
if m != nil {
|
||||||
|
r.PatientNameMask = m.PatientNameMask
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoadPatientSex 加载患者性别-就诊人
|
||||||
|
func (r *DoctorWithdrawalOrderDto) LoadPatientSex(m *model.OrderInquiry) *DoctorWithdrawalOrderDto {
|
||||||
|
if m != nil {
|
||||||
|
r.PatientSex = m.PatientSex
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoadPatientAge 加载患者年龄-就诊人
|
||||||
|
func (r *DoctorWithdrawalOrderDto) LoadPatientAge(m *model.OrderInquiry) *DoctorWithdrawalOrderDto {
|
||||||
|
if m != nil {
|
||||||
|
r.PatientAge = m.PatientAge
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoadPatientMobileMask 加载患者电话(掩码)
|
||||||
|
func (r *DoctorWithdrawalOrderDto) LoadPatientMobileMask(m *model.OrderInquiry) *DoctorWithdrawalOrderDto {
|
||||||
|
if m != nil {
|
||||||
|
userDao := dao.UserDao{}
|
||||||
|
user, err := userDao.GetUserById(m.UserId)
|
||||||
|
if err == nil && user != nil {
|
||||||
|
r.PatientMobileMask = utils.MaskPhoneStr(user.Mobile)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoadPayChannel 加载支付渠道
|
||||||
|
func (r *DoctorWithdrawalOrderDto) LoadPayChannel(m *model.OrderInquiry) *DoctorWithdrawalOrderDto {
|
||||||
|
if m != nil {
|
||||||
|
r.PayChannel = m.InquiryPayChannel
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoadPayTime 加载支付时间
|
||||||
|
func (r *DoctorWithdrawalOrderDto) LoadPayTime(m *model.OrderInquiry) *DoctorWithdrawalOrderDto {
|
||||||
|
if m != nil {
|
||||||
|
r.PayTime = m.PayTime
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoadInquiryNo 加载系统订单编号
|
||||||
|
func (r *DoctorWithdrawalOrderDto) LoadInquiryNo(m *model.OrderInquiry) *DoctorWithdrawalOrderDto {
|
||||||
|
if m != nil {
|
||||||
|
r.InquiryNo = m.InquiryNo
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoadEscrowTradeNo 加载第三方支付流水号
|
||||||
|
func (r *DoctorWithdrawalOrderDto) LoadEscrowTradeNo(m *model.OrderInquiry) *DoctorWithdrawalOrderDto {
|
||||||
|
if m != nil {
|
||||||
|
r.EscrowTradeNo = m.EscrowTradeNo
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoadInquiryStatus 加载问诊订单状态
|
||||||
|
func (r *DoctorWithdrawalOrderDto) LoadInquiryStatus(m *model.OrderInquiry) *DoctorWithdrawalOrderDto {
|
||||||
|
if m != nil {
|
||||||
|
r.InquiryStatus = m.InquiryStatus
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoadDoctorAmount 加载医生收益
|
||||||
|
func (r *DoctorWithdrawalOrderDto) LoadDoctorAmount(m *model.OrderInquiry) *DoctorWithdrawalOrderDto {
|
||||||
|
if m != nil {
|
||||||
|
r.DoctorAmount = math.Floor(m.AmountTotal*0.75*100) / 100
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
@ -12,6 +12,8 @@ type DoctorWithdrawalOrder struct {
|
|||||||
WithdrawalId int64 `gorm:"column:withdrawal_id;type:bigint(19);comment:提现表id;NOT NULL" json:"withdrawal_id"`
|
WithdrawalId int64 `gorm:"column:withdrawal_id;type:bigint(19);comment:提现表id;NOT NULL" json:"withdrawal_id"`
|
||||||
DoctorId int64 `gorm:"column:doctor_id;type:bigint(19);comment:医生id;NOT NULL" json:"doctor_id"`
|
DoctorId int64 `gorm:"column:doctor_id;type:bigint(19);comment:医生id;NOT NULL" json:"doctor_id"`
|
||||||
OrderInquiryId int64 `gorm:"column:order_inquiry_id;type:bigint(19);comment:订单-问诊id;NOT NULL" json:"order_inquiry_id"`
|
OrderInquiryId int64 `gorm:"column:order_inquiry_id;type:bigint(19);comment:订单-问诊id;NOT NULL" json:"order_inquiry_id"`
|
||||||
|
OrderInquiry *OrderInquiry `gorm:"foreignKey:OrderInquiryId;references:order_inquiry_id" json:"order_inquiry"` // 问诊
|
||||||
|
UserDoctor *UserDoctor `gorm:"foreignKey:DoctorId;references:doctor_id" json:"user_doctor"` // 医生
|
||||||
Model
|
Model
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package requests
|
|||||||
|
|
||||||
type DoctorWithdrawalRequest struct {
|
type DoctorWithdrawalRequest struct {
|
||||||
GetDoctorWithdrawalPage // 获取医生提现列表-分页
|
GetDoctorWithdrawalPage // 获取医生提现列表-分页
|
||||||
|
GetDoctorWithdrawalOrderPage // 提现详情-关联订单列表-分页
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDoctorWithdrawalPage 获取医生提现列表-分页
|
// GetDoctorWithdrawalPage 获取医生提现列表-分页
|
||||||
@ -15,3 +16,9 @@ type GetDoctorWithdrawalPage struct {
|
|||||||
ExamineStatus *int `json:"examine_status" form:"examine_status" label:"审核状态"` // (1:审核中 2:审核通过 3:审核未通过)
|
ExamineStatus *int `json:"examine_status" form:"examine_status" label:"审核状态"` // (1:审核中 2:审核通过 3:审核未通过)
|
||||||
PaymentStatus *int `json:"payment_status" form:"payment_status" label:"打款状态"` // 财务打款状态(0:否 1:是)
|
PaymentStatus *int `json:"payment_status" form:"payment_status" label:"打款状态"` // 财务打款状态(0:否 1:是)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetDoctorWithdrawalOrderPage 提现详情-关联订单列表-分页
|
||||||
|
type GetDoctorWithdrawalOrderPage struct {
|
||||||
|
Page int `json:"page" form:"page" label:"页码"`
|
||||||
|
PageSize int `json:"page_size" form:"page_size" label:"每页个数"`
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user