提现记录-关联订单-导出
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/api/requests"
|
||||
"hospital-admin-api/global"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type DoctorWithdrawalOrderDao struct {
|
||||
@@ -28,7 +30,7 @@ func (r *DoctorWithdrawalOrderDao) GetDoctorWithdrawalOrderByWithdrawalId(withdr
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetDoctorWithdrawalOrderPageSearch 获取医生提现列表-分页
|
||||
// GetDoctorWithdrawalOrderPageSearch 获取医生提现关联订单列表-分页
|
||||
func (r *DoctorWithdrawalOrderDao) GetDoctorWithdrawalOrderPageSearch(req requests.GetDoctorWithdrawalOrderPage, page, pageSize int) (m []*model.DoctorWithdrawalOrder, total int64, err error) {
|
||||
var totalRecords int64
|
||||
|
||||
@@ -64,3 +66,43 @@ func (r *DoctorWithdrawalOrderDao) GetDoctorWithdrawalOrderPageSearch(req reques
|
||||
}
|
||||
return m, totalRecords, nil
|
||||
}
|
||||
|
||||
// GetDoctorWithdrawalOrderExportListSearch 获取医生提现关联订单列表-导出
|
||||
func (r *DoctorWithdrawalOrderDao) GetDoctorWithdrawalOrderExportListSearch(req requests.DoctorWithdrawalOrderExportList) (m []*model.DoctorWithdrawalOrder, err error) {
|
||||
// 构建查询条件
|
||||
query := global.Db.Model(&model.DoctorWithdrawalOrder{})
|
||||
|
||||
if req.WithdrawalId != "" {
|
||||
query = query.Where("withdrawal_id = ?", req.WithdrawalId)
|
||||
}
|
||||
|
||||
// 医生
|
||||
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 req.Type == 2 {
|
||||
if req.Id == "" {
|
||||
return nil, errors.New("未提供需导出数据编号")
|
||||
}
|
||||
|
||||
id := strings.Split(req.Id, ",")
|
||||
query = query.Where("withdrawal_order_id IN (?)", id)
|
||||
}
|
||||
|
||||
err = query.Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user