问诊订单-导出
This commit is contained in:
parent
f972ee1f46
commit
db0c4d05dd
@ -287,3 +287,38 @@ func (r *Export) PatientFamily(c *gin.Context) {
|
|||||||
|
|
||||||
responses.OkWithData(ossAddress, c)
|
responses.OkWithData(ossAddress, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// OrderInquiry 问诊订单
|
||||||
|
func (r *Export) OrderInquiry(c *gin.Context) {
|
||||||
|
orderInquiryRequest := requests.OrderInquiryRequest{}
|
||||||
|
req := orderInquiryRequest.OrderInquiryExportList
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取数据
|
||||||
|
orderInquiryDao := dao.OrderInquiryDao{}
|
||||||
|
orderInquirys, err := orderInquiryDao.GetOrderInquiryExportListSearch(req)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
responses.FailWithMessage(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 业务处理
|
||||||
|
exportService := service.ExportService{}
|
||||||
|
ossAddress, err := exportService.OrderInquiry(orderInquirys)
|
||||||
|
if err != nil {
|
||||||
|
responses.FailWithMessage(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
responses.OkWithData(ossAddress, c)
|
||||||
|
}
|
||||||
|
|||||||
@ -16,28 +16,29 @@ type OrderInquiry struct{}
|
|||||||
|
|
||||||
// GetOrderInquiryPage 获取问诊订单列表-分页
|
// GetOrderInquiryPage 获取问诊订单列表-分页
|
||||||
func (r *OrderInquiry) GetOrderInquiryPage(c *gin.Context) {
|
func (r *OrderInquiry) GetOrderInquiryPage(c *gin.Context) {
|
||||||
req := requests.OrderInquiryRequest{}
|
orderInquiryRequest := requests.OrderInquiryRequest{}
|
||||||
if err := c.ShouldBind(&req.GetOrderInquiryPage); err != nil {
|
req := orderInquiryRequest.GetOrderInquiryPage
|
||||||
|
if err := c.ShouldBind(&req); err != nil {
|
||||||
responses.FailWithMessage(err.Error(), c)
|
responses.FailWithMessage(err.Error(), c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 参数验证
|
// 参数验证
|
||||||
if err := global.Validate.Struct(req.GetOrderInquiryPage); err != nil {
|
if err := global.Validate.Struct(req); err != nil {
|
||||||
responses.FailWithMessage(utils.Translate(err), c)
|
responses.FailWithMessage(utils.Translate(err), c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.GetOrderInquiryPage.Page == 0 {
|
if req.Page == 0 {
|
||||||
req.GetOrderInquiryPage.Page = 1
|
req.Page = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.GetOrderInquiryPage.PageSize == 0 {
|
if req.PageSize == 0 {
|
||||||
req.GetOrderInquiryPage.PageSize = 20
|
req.PageSize = 20
|
||||||
}
|
}
|
||||||
|
|
||||||
orderInquiryDao := dao.OrderInquiryDao{}
|
orderInquiryDao := dao.OrderInquiryDao{}
|
||||||
orderInquiry, total, err := orderInquiryDao.GetOrderInquiryPageSearch(req.GetOrderInquiryPage, req.GetOrderInquiryPage.Page, req.GetOrderInquiryPage.PageSize)
|
orderInquiry, total, err := orderInquiryDao.GetOrderInquiryPageSearch(req, req.Page, req.PageSize)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
responses.FailWithMessage(err.Error(), c)
|
responses.FailWithMessage(err.Error(), c)
|
||||||
return
|
return
|
||||||
@ -51,8 +52,8 @@ func (r *OrderInquiry) GetOrderInquiryPage(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
result := make(map[string]interface{})
|
result := make(map[string]interface{})
|
||||||
result["page"] = req.GetOrderInquiryPage.Page
|
result["page"] = req.Page
|
||||||
result["page_size"] = req.GetOrderInquiryPage.PageSize
|
result["page_size"] = req.PageSize
|
||||||
result["total"] = total
|
result["total"] = total
|
||||||
result["data"] = GetOrderInquiryPageResponses
|
result["data"] = GetOrderInquiryPageResponses
|
||||||
responses.OkWithData(result, c)
|
responses.OkWithData(result, c)
|
||||||
|
|||||||
@ -807,3 +807,209 @@ func (r *OrderInquiryDao) GetOrderInquiryForAccountExportListSearch(req requests
|
|||||||
}
|
}
|
||||||
return m, nil
|
return m, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetOrderInquiryExportListSearch 获取问诊订单列表-导出
|
||||||
|
func (r *OrderInquiryDao) GetOrderInquiryExportListSearch(req requests.OrderInquiryExportList) (m []*model.OrderInquiry, err error) {
|
||||||
|
// 构建查询条件
|
||||||
|
query := global.Db.Model(&model.OrderInquiry{})
|
||||||
|
|
||||||
|
// 医生
|
||||||
|
query = query.Preload("UserDoctor", func(db *gorm.DB) *gorm.DB {
|
||||||
|
return db.Omit("open_id", "union_id", "wx_session_key")
|
||||||
|
})
|
||||||
|
|
||||||
|
// 用户
|
||||||
|
query = query.Preload("User", func(db *gorm.DB) *gorm.DB {
|
||||||
|
return db.Select("user_id", "user_name", "mobile")
|
||||||
|
})
|
||||||
|
|
||||||
|
// 当前搜索数据
|
||||||
|
if req.Type == 1 {
|
||||||
|
// 订单类型
|
||||||
|
if req.InquiryType != nil {
|
||||||
|
query = query.Where("inquiry_type = ?", req.InquiryType)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 医生姓名
|
||||||
|
if req.DoctorName != "" {
|
||||||
|
subQuery := global.Db.Model(&model.UserDoctor{}).
|
||||||
|
Select("doctor_id").
|
||||||
|
Where("user_name LIKE ?", "%"+req.DoctorName+"%")
|
||||||
|
|
||||||
|
query = query.Where(gorm.Expr("doctor_id IN (?)", subQuery))
|
||||||
|
}
|
||||||
|
|
||||||
|
// 订单问诊方式
|
||||||
|
if req.InquiryMode != nil {
|
||||||
|
query = query.Where("inquiry_mode = ?", req.InquiryMode)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 问诊订单状态
|
||||||
|
if req.InquiryStatus != nil {
|
||||||
|
query = query.Where("inquiry_status = ?", req.InquiryStatus)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 问诊订单退款状态
|
||||||
|
if req.InquiryRefundStatus != nil {
|
||||||
|
query = query.Where("inquiry_refund_status = ?", req.InquiryRefundStatus)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 支付渠道
|
||||||
|
if req.InquiryPayChannel != nil {
|
||||||
|
query = query.Where("inquiry_pay_channel = ?", req.InquiryPayChannel)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 支付状态
|
||||||
|
if req.InquiryPayStatus != nil {
|
||||||
|
query = query.Where("inquiry_pay_status = ?", req.InquiryPayStatus)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 系统订单编号
|
||||||
|
if req.InquiryNo != "" {
|
||||||
|
query = query.Where("inquiry_no = ?", req.InquiryNo)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 第三方支付流水号
|
||||||
|
if req.EscrowTradeNo != "" {
|
||||||
|
query = query.Where("escrow_trade_no = ?", req.EscrowTradeNo)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 支付时间
|
||||||
|
if req.PayTime != "" {
|
||||||
|
payTime := strings.Split(req.PayTime, "&")
|
||||||
|
if len(payTime) == 2 {
|
||||||
|
startTime, _ := time.Parse("2006-01-02", payTime[0])
|
||||||
|
endTime, _ := time.Parse("2006-01-02", payTime[1])
|
||||||
|
|
||||||
|
if startTime == endTime {
|
||||||
|
endTime = endTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second)
|
||||||
|
}
|
||||||
|
|
||||||
|
query = query.Where("pay_time BETWEEN ? AND ?", startTime, endTime)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 接诊时间
|
||||||
|
if req.ReceptionTime != "" {
|
||||||
|
receptionTime := strings.Split(req.ReceptionTime, "&")
|
||||||
|
if len(receptionTime) == 2 {
|
||||||
|
startTime, _ := time.Parse("2006-01-02", receptionTime[0])
|
||||||
|
endTime, _ := time.Parse("2006-01-02", receptionTime[1])
|
||||||
|
|
||||||
|
if startTime == endTime {
|
||||||
|
endTime = endTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second)
|
||||||
|
}
|
||||||
|
|
||||||
|
query = query.Where("reception_time BETWEEN ? AND ?", startTime, endTime)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 订单完成时间
|
||||||
|
if req.CompleteTime != "" {
|
||||||
|
completeTime := strings.Split(req.CompleteTime, "&")
|
||||||
|
if len(completeTime) == 2 {
|
||||||
|
startTime, _ := time.Parse("2006-01-02", completeTime[0])
|
||||||
|
endTime, _ := time.Parse("2006-01-02", completeTime[1])
|
||||||
|
|
||||||
|
if startTime == endTime {
|
||||||
|
endTime = endTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second)
|
||||||
|
}
|
||||||
|
|
||||||
|
query = query.Where("complete_time BETWEEN ? AND ?", startTime, endTime)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 订单结束时间
|
||||||
|
if req.FinishTime != "" {
|
||||||
|
finishTime := strings.Split(req.FinishTime, "&")
|
||||||
|
if len(finishTime) == 2 {
|
||||||
|
startTime, _ := time.Parse("2006-01-02", finishTime[0])
|
||||||
|
endTime, _ := time.Parse("2006-01-02", finishTime[1])
|
||||||
|
|
||||||
|
if startTime == endTime {
|
||||||
|
endTime = endTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second)
|
||||||
|
}
|
||||||
|
|
||||||
|
query = query.Where("finish_time BETWEEN ? AND ?", startTime, endTime)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 是否提现
|
||||||
|
if req.IsWithdrawal != nil {
|
||||||
|
query = query.Where("is_withdrawal = ?", req.IsWithdrawal)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 订单取消时间
|
||||||
|
if req.CancelTime != "" {
|
||||||
|
cancelTime := strings.Split(req.CancelTime, "&")
|
||||||
|
if len(cancelTime) == 2 {
|
||||||
|
startTime, _ := time.Parse("2006-01-02", cancelTime[0])
|
||||||
|
endTime, _ := time.Parse("2006-01-02", cancelTime[1])
|
||||||
|
|
||||||
|
if startTime == endTime {
|
||||||
|
endTime = endTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second)
|
||||||
|
}
|
||||||
|
|
||||||
|
query = query.Where("cancel_time BETWEEN ? AND ?", startTime, endTime)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建时间
|
||||||
|
if req.CreatedAt != "" {
|
||||||
|
createdAt := strings.Split(req.CreatedAt, "&")
|
||||||
|
if len(createdAt) == 2 {
|
||||||
|
startTime, _ := time.Parse("2006-01-02", createdAt[0])
|
||||||
|
endTime, _ := time.Parse("2006-01-02", createdAt[1])
|
||||||
|
|
||||||
|
if startTime == endTime {
|
||||||
|
endTime = endTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second)
|
||||||
|
}
|
||||||
|
|
||||||
|
query = query.Where("created_at BETWEEN ? AND ?", startTime, endTime)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 患者姓名-就诊人
|
||||||
|
if req.PatientName != "" {
|
||||||
|
query = query.Where("patient_name LIKE ?", "%"+req.PatientName+"%")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 手机号-医生/患者
|
||||||
|
if req.Mobile != "" {
|
||||||
|
// 患者
|
||||||
|
patientSubQuery := global.Db.Model(&model.User{}).
|
||||||
|
Select("user_id").
|
||||||
|
Where("mobile = ?", 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("user_id IN (?)", patientSubQuery).Or("doctor_id IN (?)", doctorSubQuery)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 当前选中数据
|
||||||
|
if req.Type == 2 {
|
||||||
|
if req.Id == "" {
|
||||||
|
return nil, errors.New("未提供需导出数据编号")
|
||||||
|
}
|
||||||
|
|
||||||
|
id := strings.Split(req.Id, ",")
|
||||||
|
query = query.Where("order_inquiry_id IN (?)", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 排序
|
||||||
|
query = query.Order("created_at desc")
|
||||||
|
|
||||||
|
err = query.Find(&m).Error
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
|
|||||||
@ -7,6 +7,7 @@ type OrderInquiryRequest struct {
|
|||||||
GetOrderInquiryImPage // 获取问诊订单im内容列表-分页
|
GetOrderInquiryImPage // 获取问诊订单im内容列表-分页
|
||||||
GetOrderInquiryForAccountPage // 获取账户关联问诊订单列表-分页
|
GetOrderInquiryForAccountPage // 获取账户关联问诊订单列表-分页
|
||||||
OrderInquiryForAccountExportList // 医生账户-关联订单-导出
|
OrderInquiryForAccountExportList // 医生账户-关联订单-导出
|
||||||
|
OrderInquiryExportList // 问诊订单列表-导出
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetOrderInquiryPage 获取问诊订单列表-分页
|
// GetOrderInquiryPage 获取问诊订单列表-分页
|
||||||
@ -106,3 +107,27 @@ type OrderInquiryForAccountExportList struct {
|
|||||||
CancelTime string `json:"cancel_time" form:"cancel_time" label:"订单取消时间"` // 时间区间,数组形式,下标0为开始时间,下标1为结束时间
|
CancelTime string `json:"cancel_time" form:"cancel_time" label:"订单取消时间"` // 时间区间,数组形式,下标0为开始时间,下标1为结束时间
|
||||||
CreatedAt string `json:"created_at" form:"created_at" label:"订单创建时间"` // 时间区间,数组形式,下标0为开始时间,下标1为结束时间
|
CreatedAt string `json:"created_at" form:"created_at" label:"订单创建时间"` // 时间区间,数组形式,下标0为开始时间,下标1为结束时间
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// OrderInquiryExportList 问诊订单列表-导出
|
||||||
|
type OrderInquiryExportList struct {
|
||||||
|
Type int `json:"type" form:"type" label:"类型" validate:"required,oneof=1 2 3"` // 1:当前搜索数据 2:当前选择数据 3:全部数据
|
||||||
|
Id string `json:"id" form:"id" label:"id"` // 选择数据的id,逗号分隔,当type为2时必填
|
||||||
|
DoctorName string `json:"doctor_name" form:"doctor_name" label:"医生姓名"`
|
||||||
|
InquiryType *int `json:"inquiry_type" form:"inquiry_type" label:"订单类型"` // (1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药 5:检测)
|
||||||
|
InquiryMode *int `json:"inquiry_mode" form:"inquiry_mode" label:"订单问诊方式"` // (1:图文 2:视频 3:语音 4:电话 5:会员)
|
||||||
|
InquiryStatus *int `json:"inquiry_status" form:"inquiry_status" label:"问诊订单状态"` // 1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消
|
||||||
|
InquiryRefundStatus *int `json:"inquiry_refund_status" form:"inquiry_refund_status" label:"问诊订单退款状态"` // (0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常)
|
||||||
|
InquiryPayChannel *int `json:"inquiry_pay_channel" form:"inquiry_pay_channel" label:"支付渠道"` // (1:小程序支付 2:微信扫码支付 3:模拟支付)
|
||||||
|
InquiryPayStatus *int `json:"inquiry_pay_status" form:"inquiry_pay_status" label:"支付状态"` // (1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||||
|
InquiryNo string `json:"inquiry_no" form:"inquiry_no" label:"系统订单编号"`
|
||||||
|
EscrowTradeNo string `json:"escrow_trade_no" form:"escrow_trade_no" label:"第三方支付流水号"`
|
||||||
|
PayTime string `json:"pay_time" form:"pay_time" label:"支付时间"` // 时间区间,数组形式,下标0为开始时间,下标1为结束时间
|
||||||
|
ReceptionTime string `json:"reception_time" form:"reception_time" label:"接诊时间"` // 时间区间,数组形式,下标0为开始时间,下标1为结束时间
|
||||||
|
CompleteTime string `json:"complete_time" form:"complete_time" label:"订单完成时间"` // 时间区间,数组形式,下标0为开始时间,下标1为结束时间
|
||||||
|
FinishTime string `json:"finish_time" form:"finish_time" label:"订单结束时间"` // 时间区间,数组形式,下标0为开始时间,下标1为结束时间
|
||||||
|
IsWithdrawal *int `json:"is_withdrawal" form:"is_withdrawal" label:"是否提现"` // 0:否 1:是 2:提现中
|
||||||
|
CancelTime string `json:"cancel_time" form:"cancel_time" label:"订单取消时间"` // 时间区间,数组形式,下标0为开始时间,下标1为结束时间
|
||||||
|
CreatedAt string `json:"created_at" form:"created_at" label:"订单创建时间"` // 时间区间,数组形式,下标0为开始时间,下标1为结束时间
|
||||||
|
PatientName string `json:"patient_name" form:"patient_name" label:"患者姓名-就诊人"`
|
||||||
|
Mobile string `json:"mobile" form:"mobile" label:"手机号-医生/患者"`
|
||||||
|
}
|
||||||
|
|||||||
@ -635,7 +635,7 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
|||||||
orderGroup := exportGroup.Group("/order")
|
orderGroup := exportGroup.Group("/order")
|
||||||
{
|
{
|
||||||
// 问诊订单
|
// 问诊订单
|
||||||
orderGroup.POST("/inquiry", api.UserCaCert.RenewUserCloudCert)
|
orderGroup.POST("/inquiry", api.Export.OrderInquiry)
|
||||||
|
|
||||||
// 药品订单
|
// 药品订单
|
||||||
orderGroup.POST("/product", api.UserCaCert.RenewUserCloudCert)
|
orderGroup.POST("/product", api.UserCaCert.RenewUserCloudCert)
|
||||||
|
|||||||
@ -206,6 +206,42 @@ type PatientFamilyData struct {
|
|||||||
CreatedAt time.Time `json:"created_at"` // 创建时间
|
CreatedAt time.Time `json:"created_at"` // 创建时间
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// OrderInquiry 问诊订单
|
||||||
|
type OrderInquiry struct {
|
||||||
|
InquiryNo string // 系统订单编号
|
||||||
|
DoctorName string // 医生姓名
|
||||||
|
UserName string // 用户姓名(患者)
|
||||||
|
PatientName string // 患者姓名-就诊人
|
||||||
|
PatientSex string // 患者性别-就诊人(0:未知 1:男 2:女)
|
||||||
|
PatientAge string // 患者年龄-就诊人
|
||||||
|
PatientMobile string // 患者电话
|
||||||
|
InquiryType string // 订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药 5:检测)
|
||||||
|
InquiryMode string // 订单问诊方式(1:图文 2:视频 3:语音 4:电话 5:会员)
|
||||||
|
InquiryStatus string // 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||||
|
IsDelete string // 删除状态(0:否 1:是)
|
||||||
|
InquiryRefundStatus string // 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常)
|
||||||
|
InquiryPayChannel string // 支付渠道(1:小程序支付 2:微信扫码支付 3:模拟支付)
|
||||||
|
InquiryPayStatus string // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||||
|
EscrowTradeNo string // 第三方支付流水号
|
||||||
|
AmountTotal float64 // 订单金额
|
||||||
|
CouponAmountTotal float64 // 优惠卷总金额
|
||||||
|
PaymentAmountTotal float64 // 实际付款金额
|
||||||
|
DoctorAmount float64 // 医生收益
|
||||||
|
PayTime time.Time // 支付时间
|
||||||
|
ReceptionTime time.Time // 接诊时间(已接诊)
|
||||||
|
CompleteTime time.Time // 订单完成时间(问诊完成时间)
|
||||||
|
FinishTime time.Time // 订单结束时间
|
||||||
|
StatisticsStatus string // 订单统计状态(0:未统计 1:已统计 2:统计失败)
|
||||||
|
StatisticsTime time.Time // 订单统计时间
|
||||||
|
IsWithdrawal string // 是否提现(0:否 1:是 2:提现中)
|
||||||
|
WithdrawalTime time.Time // 提现时间
|
||||||
|
CancelTime time.Time // 订单取消时间
|
||||||
|
CancelReason string // 取消订单原因(1:医生未接诊 2:主动取消 3:无可分配医生 4:客服取消 5:支付超时)
|
||||||
|
CancelRemarks string // 取消订单备注(自动添加)
|
||||||
|
EntryStatus string // 入账状态(0:未入账 1:已入账 2:入账中 3:入账失败)
|
||||||
|
CreatedAt time.Time // 创建时间
|
||||||
|
}
|
||||||
|
|
||||||
// DoctorWithdrawal 提现记录
|
// DoctorWithdrawal 提现记录
|
||||||
func (r *ExportService) DoctorWithdrawal(doctorWithdrawals []*model.DoctorWithdrawal) (string, error) {
|
func (r *ExportService) DoctorWithdrawal(doctorWithdrawals []*model.DoctorWithdrawal) (string, error) {
|
||||||
header := []utils.HeaderCellData{
|
header := []utils.HeaderCellData{
|
||||||
@ -961,6 +997,17 @@ func (r *ExportService) OrderInquiryForAccount(d []*model.OrderInquiry) (string,
|
|||||||
CouponAmountTotal: v.CouponAmountTotal,
|
CouponAmountTotal: v.CouponAmountTotal,
|
||||||
PaymentAmountTotal: v.PaymentAmountTotal,
|
PaymentAmountTotal: v.PaymentAmountTotal,
|
||||||
CancelRemarks: v.CancelRemarks,
|
CancelRemarks: v.CancelRemarks,
|
||||||
|
PatientSex: utils.SexToString(v.PatientSex),
|
||||||
|
InquiryType: utils.InquiryTypeToString(v.InquiryType),
|
||||||
|
InquiryMode: utils.InquiryModeToString(v.InquiryMode),
|
||||||
|
InquiryStatus: utils.InquiryStatusToString(v.InquiryStatus),
|
||||||
|
IsDelete: utils.IsDeleteToString(v.IsDelete),
|
||||||
|
InquiryRefundStatus: utils.RefundStatusToString(v.InquiryRefundStatus),
|
||||||
|
InquiryPayChannel: utils.PayChannelToString(v.InquiryPayChannel),
|
||||||
|
InquiryPayStatus: utils.PayStatusToString(v.InquiryPayStatus),
|
||||||
|
StatisticsStatus: utils.StatisticsStatusToString(v.StatisticsStatus),
|
||||||
|
IsWithdrawal: utils.IsWithdrawalToString(v.IsWithdrawal),
|
||||||
|
CancelReason: utils.CancelReasonToString(v.CancelReason),
|
||||||
}
|
}
|
||||||
|
|
||||||
if v.UserDoctor != nil {
|
if v.UserDoctor != nil {
|
||||||
@ -976,16 +1023,6 @@ func (r *ExportService) OrderInquiryForAccount(d []*model.OrderInquiry) (string,
|
|||||||
data.PatientMobile = v.User.Mobile
|
data.PatientMobile = v.User.Mobile
|
||||||
}
|
}
|
||||||
|
|
||||||
// 性别
|
|
||||||
data.PatientSex = utils.SexToString(v.PatientSex)
|
|
||||||
data.InquiryType = utils.InquiryTypeToString(v.InquiryType)
|
|
||||||
data.InquiryMode = utils.InquiryModeToString(v.InquiryMode)
|
|
||||||
data.InquiryStatus = utils.InquiryStatusToString(v.InquiryStatus)
|
|
||||||
data.IsDelete = utils.IsDeleteToString(v.IsDelete)
|
|
||||||
data.InquiryRefundStatus = utils.RefundStatusToString(v.InquiryRefundStatus)
|
|
||||||
data.InquiryPayChannel = utils.PayChannelToString(v.InquiryPayChannel)
|
|
||||||
data.InquiryPayStatus = utils.PayStatusToString(v.InquiryPayStatus)
|
|
||||||
|
|
||||||
if v.PayTime != (model.LocalTime{}) {
|
if v.PayTime != (model.LocalTime{}) {
|
||||||
t := time.Time(v.PayTime)
|
t := time.Time(v.PayTime)
|
||||||
data.PayTime = t
|
data.PayTime = t
|
||||||
@ -1026,10 +1063,6 @@ func (r *ExportService) OrderInquiryForAccount(d []*model.OrderInquiry) (string,
|
|||||||
data.CreatedAt = t
|
data.CreatedAt = t
|
||||||
}
|
}
|
||||||
|
|
||||||
data.StatisticsStatus = utils.StatisticsStatusToString(v.StatisticsStatus)
|
|
||||||
data.IsWithdrawal = utils.IsWithdrawalToString(v.IsWithdrawal)
|
|
||||||
data.CancelReason = utils.CancelReasonToString(v.CancelReason)
|
|
||||||
|
|
||||||
// 处理入账状态(0:未入账 1:已入账 2:入账中 3:入账失败 4:入账取消)
|
// 处理入账状态(0:未入账 1:已入账 2:入账中 3:入账失败 4:入账取消)
|
||||||
entryStatus := orderInquiryService.GetOrderInquiryEntryStatus(v.InquiryStatus, v.StatisticsStatus)
|
entryStatus := orderInquiryService.GetOrderInquiryEntryStatus(v.InquiryStatus, v.StatisticsStatus)
|
||||||
data.EntryStatus = utils.EntryStatusToString(entryStatus)
|
data.EntryStatus = utils.EntryStatusToString(entryStatus)
|
||||||
@ -1198,3 +1231,151 @@ func (r *ExportService) PatientFamily(d []*model.PatientFamily) (string, error)
|
|||||||
ossPath = utils.AddOssDomain("/" + ossPath)
|
ossPath = utils.AddOssDomain("/" + ossPath)
|
||||||
return ossPath, nil
|
return ossPath, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// OrderInquiry 问诊订单
|
||||||
|
func (r *ExportService) OrderInquiry(d []*model.OrderInquiry) (string, error) {
|
||||||
|
header := []utils.HeaderCellData{
|
||||||
|
{Value: "系统订单编号", CellType: "string", NumberFmt: "", ColWidth: 25},
|
||||||
|
{Value: "医生姓名", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||||
|
{Value: "用户姓名", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||||
|
{Value: "患者姓名-就诊人", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||||
|
{Value: "患者性别-就诊人", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||||
|
{Value: "患者年龄-就诊人", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||||
|
{Value: "患者电话", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||||
|
{Value: "订单类型", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||||
|
{Value: "订单问诊方式", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||||
|
{Value: "问诊订单状态", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||||
|
{Value: "删除状态", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||||
|
{Value: "问诊订单退款状态", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||||
|
{Value: "支付渠道", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||||
|
{Value: "支付状态", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||||
|
{Value: "第三方支付流水号", CellType: "string", NumberFmt: "", ColWidth: 25},
|
||||||
|
{Value: "订单金额", CellType: "float64", NumberFmt: "0.0000", ColWidth: 18},
|
||||||
|
{Value: "优惠卷总金额", CellType: "float64", NumberFmt: "0.0000", ColWidth: 18},
|
||||||
|
{Value: "实际付款金额", CellType: "float64", NumberFmt: "0.0000", ColWidth: 18},
|
||||||
|
{Value: "医生收益", CellType: "float64", NumberFmt: "0.0000", ColWidth: 18},
|
||||||
|
{Value: "支付时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
|
||||||
|
{Value: "接诊时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
|
||||||
|
{Value: "订单完成时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
|
||||||
|
{Value: "订单结束时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
|
||||||
|
{Value: "订单统计状态", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||||
|
{Value: "订单统计时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
|
||||||
|
{Value: "是否提现", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||||
|
{Value: "提现时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
|
||||||
|
{Value: "订单取消时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
|
||||||
|
{Value: "取消订单原因", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||||
|
{Value: "取消订单备注", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||||
|
{Value: "入账状态", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||||
|
{Value: "创建时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
|
||||||
|
}
|
||||||
|
|
||||||
|
orderInquiryService := OrderInquiryService{}
|
||||||
|
|
||||||
|
var dataSlice []interface{}
|
||||||
|
for _, v := range d {
|
||||||
|
data := OrderInquiryForAccount{
|
||||||
|
InquiryNo: v.InquiryNo,
|
||||||
|
DoctorName: v.PatientName,
|
||||||
|
PatientName: v.PatientName,
|
||||||
|
PatientAge: fmt.Sprintf("%d", v.PatientAge),
|
||||||
|
EscrowTradeNo: v.EscrowTradeNo,
|
||||||
|
AmountTotal: v.AmountTotal,
|
||||||
|
CouponAmountTotal: v.CouponAmountTotal,
|
||||||
|
PaymentAmountTotal: v.PaymentAmountTotal,
|
||||||
|
CancelRemarks: v.CancelRemarks,
|
||||||
|
PatientSex: utils.SexToString(v.PatientSex),
|
||||||
|
InquiryType: utils.InquiryTypeToString(v.InquiryType),
|
||||||
|
InquiryMode: utils.InquiryModeToString(v.InquiryMode),
|
||||||
|
InquiryStatus: utils.InquiryStatusToString(v.InquiryStatus),
|
||||||
|
IsDelete: utils.IsDeleteToString(v.IsDelete),
|
||||||
|
InquiryRefundStatus: utils.RefundStatusToString(v.InquiryRefundStatus),
|
||||||
|
InquiryPayChannel: utils.PayChannelToString(v.InquiryPayChannel),
|
||||||
|
InquiryPayStatus: utils.PayStatusToString(v.InquiryPayStatus),
|
||||||
|
StatisticsStatus: utils.StatisticsStatusToString(v.StatisticsStatus),
|
||||||
|
IsWithdrawal: utils.IsWithdrawalToString(v.IsWithdrawal),
|
||||||
|
CancelReason: utils.CancelReasonToString(v.CancelReason),
|
||||||
|
}
|
||||||
|
|
||||||
|
if v.UserDoctor != nil {
|
||||||
|
// 医生姓名
|
||||||
|
data.DoctorName = v.UserDoctor.UserName
|
||||||
|
}
|
||||||
|
|
||||||
|
if v.User != nil {
|
||||||
|
// 用户姓名(患者)
|
||||||
|
data.UserName = v.User.UserName
|
||||||
|
|
||||||
|
// 患者电话
|
||||||
|
data.PatientMobile = v.User.Mobile
|
||||||
|
}
|
||||||
|
|
||||||
|
if v.PayTime != (model.LocalTime{}) {
|
||||||
|
t := time.Time(v.PayTime)
|
||||||
|
data.PayTime = t
|
||||||
|
}
|
||||||
|
|
||||||
|
if v.ReceptionTime != (model.LocalTime{}) {
|
||||||
|
t := time.Time(v.ReceptionTime)
|
||||||
|
data.ReceptionTime = t
|
||||||
|
}
|
||||||
|
|
||||||
|
if v.CompleteTime != (model.LocalTime{}) {
|
||||||
|
t := time.Time(v.CompleteTime)
|
||||||
|
data.CompleteTime = t
|
||||||
|
}
|
||||||
|
|
||||||
|
if v.FinishTime != (model.LocalTime{}) {
|
||||||
|
t := time.Time(v.FinishTime)
|
||||||
|
data.FinishTime = t
|
||||||
|
}
|
||||||
|
|
||||||
|
if v.StatisticsTime != (model.LocalTime{}) {
|
||||||
|
t := time.Time(v.StatisticsTime)
|
||||||
|
data.StatisticsTime = t
|
||||||
|
}
|
||||||
|
|
||||||
|
if v.WithdrawalTime != (model.LocalTime{}) {
|
||||||
|
t := time.Time(v.WithdrawalTime)
|
||||||
|
data.WithdrawalTime = t
|
||||||
|
}
|
||||||
|
|
||||||
|
if v.CancelTime != (model.LocalTime{}) {
|
||||||
|
t := time.Time(v.CancelTime)
|
||||||
|
data.CancelTime = t
|
||||||
|
}
|
||||||
|
|
||||||
|
if v.CreatedAt != (model.LocalTime{}) {
|
||||||
|
t := time.Time(v.CreatedAt)
|
||||||
|
data.CreatedAt = t
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理入账状态(0:未入账 1:已入账 2:入账中 3:入账失败 4:入账取消)
|
||||||
|
entryStatus := orderInquiryService.GetOrderInquiryEntryStatus(v.InquiryStatus, v.StatisticsStatus)
|
||||||
|
data.EntryStatus = utils.EntryStatusToString(entryStatus)
|
||||||
|
|
||||||
|
// 处理医生收益
|
||||||
|
data.DoctorAmount = orderInquiryService.GetOrderInquiryDoctorAmount(v.InquiryStatus, v.AmountTotal)
|
||||||
|
|
||||||
|
dataSlice = append(dataSlice, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
file, err := utils.Export(header, dataSlice)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置文件名字
|
||||||
|
now := time.Now()
|
||||||
|
dateTimeString := now.Format("20060102150405") // 当前时间字符串
|
||||||
|
rand.Seed(time.Now().UnixNano()) // 设置随机数
|
||||||
|
ossPath := "admin/export/output" + dateTimeString + fmt.Sprintf("%d", rand.Intn(9000)+1000) + ".xlsx"
|
||||||
|
|
||||||
|
// 上传oss
|
||||||
|
_, err = aliyun.PutObjectByte(ossPath, file.Bytes())
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
ossPath = utils.AddOssDomain("/" + ossPath)
|
||||||
|
return ossPath, nil
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user