新增 获取医生银行卡列表-分页
This commit is contained in:
parent
72d37f6a25
commit
fc738c4d32
@ -398,3 +398,45 @@ func (r *UserDoctor) GetUserDoctorList(c *gin.Context) {
|
|||||||
res := dto.GetUserDoctorListDto(userDoctor)
|
res := dto.GetUserDoctorListDto(userDoctor)
|
||||||
responses.OkWithData(res, c)
|
responses.OkWithData(res, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetUserDoctorBankCardPage 获取医生银行卡列表-分页
|
||||||
|
func (r *UserDoctor) GetUserDoctorBankCardPage(c *gin.Context) {
|
||||||
|
userDoctorRequest := requests.UserDoctorRequest{}
|
||||||
|
req := userDoctorRequest.GetUserDoctorBankCardPage
|
||||||
|
if err := c.ShouldBind(&req); err != nil {
|
||||||
|
responses.FailWithMessage(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 参数验证
|
||||||
|
if err := global.Validate.Struct(req); err != nil {
|
||||||
|
responses.FailWithMessage(utils.Translate(err), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.Page == 0 {
|
||||||
|
req.Page = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.PageSize == 0 {
|
||||||
|
req.PageSize = 20
|
||||||
|
}
|
||||||
|
|
||||||
|
doctorBankCardDao := dao.DoctorBankCardDao{}
|
||||||
|
doctorBankCard, total, err := doctorBankCardDao.GetDoctorBankCardPage(req, req.Page, req.PageSize)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
responses.FailWithMessage(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理返回值
|
||||||
|
res := dto.GetDoctorBankCardListDto(doctorBankCard)
|
||||||
|
|
||||||
|
result := make(map[string]interface{})
|
||||||
|
result["page"] = req.Page
|
||||||
|
result["page_size"] = req.PageSize
|
||||||
|
result["total"] = total
|
||||||
|
result["data"] = res
|
||||||
|
responses.OkWithData(result, c)
|
||||||
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package dao
|
|||||||
import (
|
import (
|
||||||
"gorm.io/gorm"
|
"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"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -88,3 +89,77 @@ func (r *DoctorBankCardDao) AddDoctorBankCardByMap(tx *gorm.DB, data map[string]
|
|||||||
}
|
}
|
||||||
return userDoctorInfo, nil
|
return userDoctorInfo, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetDoctorBankCardPage 获取医生列表-分页
|
||||||
|
func (r *DoctorBankCardDao) GetDoctorBankCardPage(req requests.GetUserDoctorBankCardPage, page, pageSize int) (m []*model.DoctorBankCard, total int64, err error) {
|
||||||
|
var totalRecords int64
|
||||||
|
|
||||||
|
// 构建查询条件
|
||||||
|
query := global.Db.Model(&model.DoctorBankCard{})
|
||||||
|
|
||||||
|
// 医生
|
||||||
|
query = query.Preload("UserDoctor", func(db *gorm.DB) *gorm.DB {
|
||||||
|
return db.Omit("open_id", "union_id", "wx_session_key")
|
||||||
|
})
|
||||||
|
|
||||||
|
// 用户
|
||||||
|
query = query.Preload("UserDoctor.User", func(db *gorm.DB) *gorm.DB {
|
||||||
|
return db.Omit("user_password", "salt")
|
||||||
|
})
|
||||||
|
|
||||||
|
// 银行
|
||||||
|
query = query.Preload("BasicBank", func(db *gorm.DB) *gorm.DB {
|
||||||
|
return db.Select("bank_id,bank_code,bank_name")
|
||||||
|
})
|
||||||
|
|
||||||
|
// 手机号
|
||||||
|
if req.Mobile != "" {
|
||||||
|
// 医生
|
||||||
|
doctorUserSubQuery := global.Db.Model(&model.User{}).
|
||||||
|
Select("user_id").
|
||||||
|
Where("mobile = ?", req.Mobile)
|
||||||
|
|
||||||
|
doctorSubQuery := global.Db.Model(&model.UserDoctor{}).
|
||||||
|
Select("doctor_id").
|
||||||
|
Where(gorm.Expr("user_id IN (?)", doctorUserSubQuery))
|
||||||
|
|
||||||
|
query = query.Where("doctor_id IN (?)", doctorSubQuery)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 用户名称
|
||||||
|
if req.UserName != "" {
|
||||||
|
subQuery := global.Db.Model(&model.User{}).
|
||||||
|
Select("doctor_id").
|
||||||
|
Where("user_name LIKE ?", "%"+req.UserName+"%")
|
||||||
|
|
||||||
|
query = query.Where(gorm.Expr("doctor_id IN (?)", subQuery))
|
||||||
|
}
|
||||||
|
|
||||||
|
// 银行卡号
|
||||||
|
if req.BankCardCode != "" {
|
||||||
|
query = query.Where("bank_card_code = ?", req.BankCardCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 银行名称
|
||||||
|
if req.BankName != "" {
|
||||||
|
subQuery := global.Db.Model(&model.BasicBank{}).
|
||||||
|
Select("bank_id").
|
||||||
|
Where("bank_name LIKE ?", "%"+req.BankName+"%")
|
||||||
|
|
||||||
|
query = query.Where(gorm.Expr("bank_id IN (?)", subQuery))
|
||||||
|
}
|
||||||
|
|
||||||
|
// 排序
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package dto
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"hospital-admin-api/api/model"
|
"hospital-admin-api/api/model"
|
||||||
|
"hospital-admin-api/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DoctorBankCardDto struct {
|
type DoctorBankCardDto struct {
|
||||||
@ -16,6 +17,11 @@ type DoctorBankCardDto struct {
|
|||||||
City string `json:"city"` // 城市
|
City string `json:"city"` // 城市
|
||||||
CountyId int `json:"county_id"` // 区县id
|
CountyId int `json:"county_id"` // 区县id
|
||||||
County string `json:"county"` // 区县
|
County string `json:"county"` // 区县
|
||||||
|
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||||
|
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
|
||||||
|
DoctorName string `json:"doctor_name"` // 医生姓名
|
||||||
|
BankName string `json:"bank_name"` // 银行名称
|
||||||
|
DoctorMobileMask string `json:"doctor_mobile_mask"` // 医生手机号(掩码)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetDoctorBankCardDto(m *model.DoctorBankCard) *DoctorBankCardDto {
|
func GetDoctorBankCardDto(m *model.DoctorBankCard) *DoctorBankCardDto {
|
||||||
@ -52,6 +58,21 @@ func GetDoctorBankCardListDto(m []*model.DoctorBankCard) []DoctorBankCardDto {
|
|||||||
County: v.County,
|
County: v.County,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 加载银行名称
|
||||||
|
if v.BasicBank != nil {
|
||||||
|
response.LoadBankName(v.BasicBank)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载医生名称
|
||||||
|
if v.UserDoctor != nil {
|
||||||
|
response.LoadDoctorName(v.UserDoctor)
|
||||||
|
|
||||||
|
// 加载医生手机号(掩码)
|
||||||
|
if v.UserDoctor.User != nil {
|
||||||
|
response.LoadDoctorMobileMask(v.UserDoctor.User)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 将转换后的结构体添加到新切片中
|
// 将转换后的结构体添加到新切片中
|
||||||
responses[i] = response
|
responses[i] = response
|
||||||
}
|
}
|
||||||
@ -59,3 +80,27 @@ func GetDoctorBankCardListDto(m []*model.DoctorBankCard) []DoctorBankCardDto {
|
|||||||
|
|
||||||
return responses
|
return responses
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LoadDoctorName 加载医生名称
|
||||||
|
func (r *DoctorBankCardDto) LoadDoctorName(m *model.UserDoctor) *DoctorBankCardDto {
|
||||||
|
if m != nil {
|
||||||
|
r.DoctorName = m.UserName
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoadBankName 加载银行名称
|
||||||
|
func (r *DoctorBankCardDto) LoadBankName(m *model.BasicBank) *DoctorBankCardDto {
|
||||||
|
if m != nil {
|
||||||
|
r.BankName = m.BankName
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoadDoctorMobileMask 加载医生手机号(掩码)
|
||||||
|
func (r *DoctorBankCardDto) LoadDoctorMobileMask(m *model.User) *DoctorBankCardDto {
|
||||||
|
if m != nil {
|
||||||
|
r.DoctorMobileMask = utils.MaskPhoneStr(m.Mobile)
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|||||||
@ -19,6 +19,8 @@ type DoctorBankCard struct {
|
|||||||
City string `gorm:"column:city;type:varchar(40);comment:城市" json:"city"`
|
City string `gorm:"column:city;type:varchar(40);comment:城市" json:"city"`
|
||||||
CountyId int `gorm:"column:county_id;type:int(11);comment:区县id" json:"county_id"`
|
CountyId int `gorm:"column:county_id;type:int(11);comment:区县id" json:"county_id"`
|
||||||
County string `gorm:"column:county;type:varchar(255);comment:区县" json:"county"`
|
County string `gorm:"column:county;type:varchar(255);comment:区县" json:"county"`
|
||||||
|
UserDoctor *UserDoctor `gorm:"foreignKey:DoctorId;references:doctor_id" json:"user_doctor"` // 医生
|
||||||
|
BasicBank *BasicBank `gorm:"foreignKey:BankId;references:bank_id" json:"basic_bank"` // 银行卡
|
||||||
Model
|
Model
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -9,6 +9,7 @@ type UserDoctorRequest struct {
|
|||||||
GetMultiPage // 多点-获取医生列表-分页
|
GetMultiPage // 多点-获取医生列表-分页
|
||||||
PutMulti // 多点-审核医生
|
PutMulti // 多点-审核医生
|
||||||
GetUserDoctorList // 获取医生列表
|
GetUserDoctorList // 获取医生列表
|
||||||
|
GetUserDoctorBankCardPage // 获取医生银行卡列表-分页
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetUserDoctorPage 获取医生列表-分页
|
// GetUserDoctorPage 获取医生列表-分页
|
||||||
@ -138,3 +139,13 @@ type GetUserDoctorList struct {
|
|||||||
UnInquiryType string `json:"un_inquiry_type" form:"un_inquiry_type" label:"非查询问诊类型"` // 逗号分隔(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药 5:检测)
|
UnInquiryType string `json:"un_inquiry_type" form:"un_inquiry_type" label:"非查询问诊类型"` // 逗号分隔(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药 5:检测)
|
||||||
InquiryMode int `json:"inquiry_mode" form:"inquiry_mode" label:"问诊方式"` // (1:图文 2:视频 3:语音 4:电话 5:会员)
|
InquiryMode int `json:"inquiry_mode" form:"inquiry_mode" label:"问诊方式"` // (1:图文 2:视频 3:语音 4:电话 5:会员)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetUserDoctorBankCardPage 获取医生银行卡列表-分页
|
||||||
|
type GetUserDoctorBankCardPage struct {
|
||||||
|
Page int `json:"page" form:"page" label:"页码"`
|
||||||
|
PageSize int `json:"page_size" form:"page_size" label:"每页个数"`
|
||||||
|
Mobile string `json:"mobile" form:"mobile" label:"手机号"`
|
||||||
|
UserName string `json:"user_name" form:"user_name" label:"用户名"`
|
||||||
|
BankCardCode string `json:"bank_card_code" form:"bank_card_code" label:"银行卡号"`
|
||||||
|
BankName string `json:"bank_name" form:"bank_name" label:"银行名称"`
|
||||||
|
}
|
||||||
|
|||||||
@ -362,6 +362,13 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
|||||||
// 多点-审核医生
|
// 多点-审核医生
|
||||||
doctorMultiGroup.PUT("/:doctor_id", api.UserDoctor.PutMulti)
|
doctorMultiGroup.PUT("/:doctor_id", api.UserDoctor.PutMulti)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 银行卡管理
|
||||||
|
bankGroup := doctorGroup.Group("/bank")
|
||||||
|
{
|
||||||
|
// 获取医生银行卡列表-分页
|
||||||
|
bankGroup.GET("", api.UserDoctor.GetUserDoctorBankCardPage)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 订单管理
|
// 订单管理
|
||||||
@ -529,13 +536,6 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
|||||||
// 确认打款
|
// 确认打款
|
||||||
withdrawalGroup.PUT("/payment/:withdrawal_id", api.DoctorWithdrawal.PutDoctorWithdrawalPayment)
|
withdrawalGroup.PUT("/payment/:withdrawal_id", api.DoctorWithdrawal.PutDoctorWithdrawalPayment)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 银行卡管理
|
|
||||||
bankGroup := financeGroup.Group("/bank")
|
|
||||||
{
|
|
||||||
// 获取银行卡列表-分页
|
|
||||||
bankGroup.GET("", api.OrderPrescription.GetOrderPrescriptionPage)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ca管理
|
// ca管理
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user