新增 获取问诊订单列表-分页,修正取消问诊订单
This commit is contained in:
parent
64ffc02ba2
commit
dc0217d191
@ -2,8 +2,13 @@ package controller
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"hospital-admin-api/api/dao"
|
||||||
|
"hospital-admin-api/api/requests"
|
||||||
"hospital-admin-api/api/responses"
|
"hospital-admin-api/api/responses"
|
||||||
|
"hospital-admin-api/api/responses/orderInquiryResponse"
|
||||||
"hospital-admin-api/api/service"
|
"hospital-admin-api/api/service"
|
||||||
|
"hospital-admin-api/global"
|
||||||
|
"hospital-admin-api/utils"
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -11,7 +16,47 @@ type OrderInquiry struct{}
|
|||||||
|
|
||||||
// GetOrderInquiryPage 获取问诊订单列表-分页
|
// GetOrderInquiryPage 获取问诊订单列表-分页
|
||||||
func (r *OrderInquiry) GetOrderInquiryPage(c *gin.Context) {
|
func (r *OrderInquiry) GetOrderInquiryPage(c *gin.Context) {
|
||||||
responses.Ok(c)
|
req := requests.OrderInquiryRequest{}
|
||||||
|
if err := c.ShouldBind(&req.GetOrderInquiryPage); err != nil {
|
||||||
|
responses.FailWithMessage(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 参数验证
|
||||||
|
if err := global.Validate.Struct(req.GetOrderInquiryPage); err != nil {
|
||||||
|
responses.FailWithMessage(utils.Translate(err), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.GetOrderInquiryPage.Page == 0 {
|
||||||
|
req.GetOrderInquiryPage.Page = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.GetOrderInquiryPage.PageSize == 0 {
|
||||||
|
req.GetOrderInquiryPage.PageSize = 20
|
||||||
|
}
|
||||||
|
|
||||||
|
orderInquiryDao := dao.OrderInquiryDao{}
|
||||||
|
orderInquiry, total, err := orderInquiryDao.GetOrderInquiryPageSearch(req.GetOrderInquiryPage, req.GetOrderInquiryPage.Page, req.GetOrderInquiryPage.PageSize)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
responses.FailWithMessage(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理返回值
|
||||||
|
GetOrderInquiryPageResponses := orderInquiryResponse.GetOrderInquiryPageResponse(orderInquiry)
|
||||||
|
if err != nil {
|
||||||
|
responses.FailWithMessage(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result := make(map[string]interface{})
|
||||||
|
result["page"] = req.GetOrderInquiryPage.Page
|
||||||
|
result["page_size"] = req.GetOrderInquiryPage.PageSize
|
||||||
|
result["total"] = total
|
||||||
|
result["data"] = GetOrderInquiryPageResponses
|
||||||
|
responses.OkWithData(result, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetOrderInquiry 问诊订单详情
|
// GetOrderInquiry 问诊订单详情
|
||||||
|
|||||||
@ -4,7 +4,10 @@ import (
|
|||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"gorm.io/gorm/clause"
|
"gorm.io/gorm/clause"
|
||||||
"hospital-admin-api/api/model"
|
"hospital-admin-api/api/model"
|
||||||
|
"hospital-admin-api/api/requests"
|
||||||
"hospital-admin-api/global"
|
"hospital-admin-api/global"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type OrderInquiryDao struct {
|
type OrderInquiryDao struct {
|
||||||
@ -71,3 +74,139 @@ func (r *OrderInquiryDao) AddOrderInquiry(tx *gorm.DB, model *model.OrderInquiry
|
|||||||
}
|
}
|
||||||
return model, nil
|
return model, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetOrderInquiryPageSearch 获取问诊订单列表-分页
|
||||||
|
func (r *OrderInquiryDao) GetOrderInquiryPageSearch(req requests.GetOrderInquiryPage, page, pageSize int) (m []*model.OrderInquiry, total int64, err error) {
|
||||||
|
var totalRecords int64
|
||||||
|
|
||||||
|
// 构建查询条件
|
||||||
|
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")
|
||||||
|
})
|
||||||
|
|
||||||
|
// 医生姓名
|
||||||
|
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.InquiryType != nil {
|
||||||
|
query = query.Where("inquiry_type = ?", req.InquiryType)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 订单问诊方式
|
||||||
|
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])
|
||||||
|
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])
|
||||||
|
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])
|
||||||
|
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])
|
||||||
|
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])
|
||||||
|
query = query.Where("cancel_time BETWEEN ? AND ?", startTime, endTime)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 患者姓名-就诊人
|
||||||
|
if req.PatientName != "" {
|
||||||
|
query = query.Where("patient_name LIKE ?", "%"+req.PatientName+"%")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 排序
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|||||||
@ -57,6 +57,10 @@ func (t *LocalTime) String() string {
|
|||||||
return fmt.Sprintf("hhh:%s", time.Time(*t).String())
|
return fmt.Sprintf("hhh:%s", time.Time(*t).String())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *LocalTime) IsEmpty() bool {
|
||||||
|
return time.Time(*t).IsZero()
|
||||||
|
}
|
||||||
|
|
||||||
func (m *Model) BeforeUpdate(tx *gorm.DB) (err error) {
|
func (m *Model) BeforeUpdate(tx *gorm.DB) (err error) {
|
||||||
m.UpdatedAt = LocalTime(time.Now())
|
m.UpdatedAt = LocalTime(time.Now())
|
||||||
tx.Statement.SetColumn("UpdatedAt", m.UpdatedAt)
|
tx.Statement.SetColumn("UpdatedAt", m.UpdatedAt)
|
||||||
|
|||||||
@ -8,38 +8,39 @@ import (
|
|||||||
|
|
||||||
// OrderInquiry 订单-问诊表
|
// OrderInquiry 订单-问诊表
|
||||||
type OrderInquiry struct {
|
type OrderInquiry struct {
|
||||||
OrderInquiryId int64 `gorm:"column:order_inquiry_id;type:bigint(19);primary_key;comment:主键id" json:"order_inquiry_id"`
|
OrderInquiryId int64 `gorm:"column:order_inquiry_id;type:bigint(19);primary_key;comment:主键id" json:"order_inquiry_id"`
|
||||||
UserId int64 `gorm:"column:user_id;type:bigint(19);comment:用户id-患者;NOT NULL" json:"user_id"`
|
UserId int64 `gorm:"column:user_id;type:bigint(19);comment:用户id-患者;NOT NULL" json:"user_id"`
|
||||||
PatientId int64 `gorm:"column:patient_id;type:bigint(19);comment:患者id;NOT NULL" json:"patient_id"`
|
PatientId int64 `gorm:"column:patient_id;type:bigint(19);comment:患者id;NOT NULL" json:"patient_id"`
|
||||||
DoctorId int64 `gorm:"column:doctor_id;type:bigint(19);comment:医生id(未分配时为null)" json:"doctor_id"`
|
DoctorId int64 `gorm:"column:doctor_id;type:bigint(19);comment:医生id(未分配时为null)" json:"doctor_id"`
|
||||||
FamilyId int64 `gorm:"column:family_id;type:bigint(19);comment:家庭成员id(就诊用户);NOT NULL" json:"family_id"`
|
FamilyId int64 `gorm:"column:family_id;type:bigint(19);comment:家庭成员id(就诊用户);NOT NULL" json:"family_id"`
|
||||||
InquiryType int `gorm:"column:inquiry_type;type:tinyint(1);comment:订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药 5:检测);NOT NULL" json:"inquiry_type"`
|
InquiryType int `gorm:"column:inquiry_type;type:tinyint(1);comment:订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药 5:检测);NOT NULL" json:"inquiry_type"`
|
||||||
InquiryMode int `gorm:"column:inquiry_mode;type:tinyint(1);comment:订单问诊方式(1:图文 2:视频 3:语音 4:电话 5:会员);NOT NULL" json:"inquiry_mode"`
|
InquiryMode int `gorm:"column:inquiry_mode;type:tinyint(1);comment:订单问诊方式(1:图文 2:视频 3:语音 4:电话 5:会员);NOT NULL" json:"inquiry_mode"`
|
||||||
InquiryStatus int `gorm:"column:inquiry_status;type:tinyint(1);default:1;comment:问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消);NOT NULL" json:"inquiry_status"`
|
InquiryStatus int `gorm:"column:inquiry_status;type:tinyint(1);default:1;comment:问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消);NOT NULL" json:"inquiry_status"`
|
||||||
IsDelete int `gorm:"column:is_delete;type:tinyint(1);default:0;comment:删除状态(0:否 1:是)" json:"is_delete"`
|
IsDelete int `gorm:"column:is_delete;type:tinyint(1);default:0;comment:删除状态(0:否 1:是)" json:"is_delete"`
|
||||||
InquiryRefundStatus int `gorm:"column:inquiry_refund_status;type:tinyint(1);default:0;comment:问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常)" json:"inquiry_refund_status"`
|
InquiryRefundStatus int `gorm:"column:inquiry_refund_status;type:tinyint(1);default:0;comment:问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常)" json:"inquiry_refund_status"`
|
||||||
InquiryPayChannel int `gorm:"column:inquiry_pay_channel;type:tinyint(1);comment:支付渠道(1:小程序支付 2:微信扫码支付 3:模拟支付)" json:"inquiry_pay_channel"`
|
InquiryPayChannel int `gorm:"column:inquiry_pay_channel;type:tinyint(1);comment:支付渠道(1:小程序支付 2:微信扫码支付 3:模拟支付)" json:"inquiry_pay_channel"`
|
||||||
InquiryPayStatus int `gorm:"column:inquiry_pay_status;type:tinyint(1);default:1;comment:支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款);NOT NULL" json:"inquiry_pay_status"`
|
InquiryPayStatus int `gorm:"column:inquiry_pay_status;type:tinyint(1);default:1;comment:支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款);NOT NULL" json:"inquiry_pay_status"`
|
||||||
InquiryNo string `gorm:"column:inquiry_no;type:varchar(30);comment:系统订单编号;NOT NULL" json:"inquiry_no"`
|
InquiryNo string `gorm:"column:inquiry_no;type:varchar(30);comment:系统订单编号;NOT NULL" json:"inquiry_no"`
|
||||||
EscrowTradeNo string `gorm:"column:escrow_trade_no;type:varchar(100);comment:第三方支付流水号" json:"escrow_trade_no"`
|
EscrowTradeNo string `gorm:"column:escrow_trade_no;type:varchar(100);comment:第三方支付流水号" json:"escrow_trade_no"`
|
||||||
AmountTotal float64 `gorm:"column:amount_total;type:decimal(10,2);default:0.00;comment:订单金额" json:"amount_total"`
|
AmountTotal float64 `gorm:"column:amount_total;type:decimal(10,2);default:0.00;comment:订单金额" json:"amount_total"`
|
||||||
CouponAmountTotal float64 `gorm:"column:coupon_amount_total;type:decimal(10,2);comment:优惠卷总金额" json:"coupon_amount_total"`
|
CouponAmountTotal float64 `gorm:"column:coupon_amount_total;type:decimal(10,2);comment:优惠卷总金额" json:"coupon_amount_total"`
|
||||||
PaymentAmountTotal float64 `gorm:"column:payment_amount_total;type:decimal(10,2);default:0.00;comment:实际付款金额" json:"payment_amount_total"`
|
PaymentAmountTotal float64 `gorm:"column:payment_amount_total;type:decimal(10,2);default:0.00;comment:实际付款金额" json:"payment_amount_total"`
|
||||||
PayTime time.Time `gorm:"column:pay_time;type:datetime;comment:支付时间" json:"pay_time"`
|
PayTime LocalTime `gorm:"column:pay_time;type:datetime;comment:支付时间" json:"pay_time"`
|
||||||
ReceptionTime time.Time `gorm:"column:reception_time;type:datetime;comment:接诊时间(已接诊)" json:"reception_time"`
|
ReceptionTime LocalTime `gorm:"column:reception_time;type:datetime;comment:接诊时间(已接诊)" json:"reception_time"`
|
||||||
CompleteTime time.Time `gorm:"column:complete_time;type:datetime;comment:订单完成时间(问诊完成时间)" json:"complete_time"`
|
CompleteTime LocalTime `gorm:"column:complete_time;type:datetime;comment:订单完成时间(问诊完成时间)" json:"complete_time"`
|
||||||
FinishTime time.Time `gorm:"column:finish_time;type:datetime;comment:订单结束时间" json:"finish_time"`
|
FinishTime LocalTime `gorm:"column:finish_time;type:datetime;comment:订单结束时间" json:"finish_time"`
|
||||||
StatisticsStatus int `gorm:"column:statistics_status;type:tinyint(1);default:0;comment:订单统计状态(0:未统计 1:已统计 2:统计失败)" json:"statistics_status"`
|
StatisticsStatus int `gorm:"column:statistics_status;type:tinyint(1);default:0;comment:订单统计状态(0:未统计 1:已统计 2:统计失败)" json:"statistics_status"`
|
||||||
StatisticsTime time.Time `gorm:"column:statistics_time;type:datetime;comment:订单统计时间" json:"statistics_time"`
|
StatisticsTime LocalTime `gorm:"column:statistics_time;type:datetime;comment:订单统计时间" json:"statistics_time"`
|
||||||
IsWithdrawal int `gorm:"column:is_withdrawal;type:tinyint(1);default:0;comment:是否提现(0:否 1:是 2:提现中)" json:"is_withdrawal"`
|
IsWithdrawal int `gorm:"column:is_withdrawal;type:tinyint(1);default:0;comment:是否提现(0:否 1:是 2:提现中)" json:"is_withdrawal"`
|
||||||
WithdrawalTime time.Time `gorm:"column:withdrawal_time;type:datetime;comment:提现时间" json:"withdrawal_time"`
|
WithdrawalTime LocalTime `gorm:"column:withdrawal_time;type:datetime;comment:提现时间" json:"withdrawal_time"`
|
||||||
CancelTime time.Time `gorm:"column:cancel_time;type:datetime;comment:订单取消时间" json:"cancel_time"`
|
CancelTime LocalTime `gorm:"column:cancel_time;type:datetime;comment:订单取消时间" json:"cancel_time"`
|
||||||
CancelReason int `gorm:"column:cancel_reason;type:tinyint(1);comment:取消订单原因(1:医生未接诊 2:主动取消 3:无可分配医生 4:客服取消 5:支付超时)" json:"cancel_reason"`
|
CancelReason int `gorm:"column:cancel_reason;type:tinyint(1);comment:取消订单原因(1:医生未接诊 2:主动取消 3:无可分配医生 4:客服取消 5:支付超时)" json:"cancel_reason"`
|
||||||
CancelRemarks string `gorm:"column:cancel_remarks;type:varchar(255);comment:取消订单备注(自动添加)" json:"cancel_remarks"`
|
CancelRemarks string `gorm:"column:cancel_remarks;type:varchar(255);comment:取消订单备注(自动添加)" json:"cancel_remarks"`
|
||||||
PatientName string `gorm:"column:patient_name;type:varchar(255);comment:患者姓名-就诊人" json:"patient_name"`
|
PatientName string `gorm:"column:patient_name;type:varchar(255);comment:患者姓名-就诊人" json:"patient_name"`
|
||||||
PatientNameMask string `gorm:"column:patient_name_mask;type:varchar(255);comment:患者姓名-就诊人(掩码)" json:"patient_name_mask"`
|
PatientNameMask string `gorm:"column:patient_name_mask;type:varchar(255);comment:患者姓名-就诊人(掩码)" json:"patient_name_mask"`
|
||||||
PatientSex int `gorm:"column:patient_sex;type:tinyint(1);default:0;comment:患者性别-就诊人(0:未知 1:男 2:女)" json:"patient_sex"`
|
PatientSex int `gorm:"column:patient_sex;type:tinyint(1);default:0;comment:患者性别-就诊人(0:未知 1:男 2:女)" json:"patient_sex"`
|
||||||
PatientAge int `gorm:"column:patient_age;type:int(1);comment:患者年龄-就诊人" json:"patient_age"`
|
PatientAge int `gorm:"column:patient_age;type:int(1);comment:患者年龄-就诊人" json:"patient_age"`
|
||||||
|
UserDoctor *UserDoctor `gorm:"foreignKey:DoctorId;references:doctor_id" json:"user_doctor"` // 医生
|
||||||
Model
|
Model
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
27
api/requests/orderInquiry.go
Normal file
27
api/requests/orderInquiry.go
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package requests
|
||||||
|
|
||||||
|
type OrderInquiryRequest struct {
|
||||||
|
GetOrderInquiryPage // 获取问诊订单列表-分页
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetOrderInquiryPage 获取问诊订单列表-分页
|
||||||
|
type GetOrderInquiryPage struct {
|
||||||
|
Page int `json:"page" form:"page" label:"页码"`
|
||||||
|
PageSize int `json:"page_size" form:"page_size" label:"每页个数"`
|
||||||
|
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为结束时间
|
||||||
|
PatientName string `json:"patient_name" form:"patient_name" label:"患者姓名-就诊人"`
|
||||||
|
}
|
||||||
102
api/responses/orderInquiryResponse/orderInquiry.go
Normal file
102
api/responses/orderInquiryResponse/orderInquiry.go
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
package orderInquiryResponse
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"hospital-admin-api/api/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
// getOrderInquiryPage 获取医生列表-分页
|
||||||
|
type getOrderInquiryPage struct {
|
||||||
|
OrderInquiryId string `json:"order_inquiry_id"` // 主键id
|
||||||
|
UserId string `json:"user_id"` // 用户id-患者
|
||||||
|
PatientId string `json:"patient_id"` // 患者id
|
||||||
|
DoctorId string `json:"doctor_id"` // 医生id(未分配时为null)
|
||||||
|
FamilyId string `json:"family_id"` // 家庭成员id(就诊用户)
|
||||||
|
InquiryType int `json:"inquiry_type"` // 订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药 5:检测)
|
||||||
|
InquiryMode int `json:"inquiry_mode"` // 订单问诊方式(1:图文 2:视频 3:语音 4:电话 5:会员)
|
||||||
|
InquiryStatus int `json:"inquiry_status"` // 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||||
|
IsDelete int `json:"is_delete"` // 删除状态(0:否 1:是)
|
||||||
|
InquiryRefundStatus int `json:"inquiry_refund_status"` // 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常)
|
||||||
|
InquiryPayChannel int `json:"inquiry_pay_channel"` // 支付渠道(1:小程序支付 2:微信扫码支付 3:模拟支付)
|
||||||
|
InquiryPayStatus int `json:"inquiry_pay_status"` // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||||
|
InquiryNo string `json:"inquiry_no"` // 系统订单编号
|
||||||
|
EscrowTradeNo string `json:"escrow_trade_no"` // 第三方支付流水号
|
||||||
|
AmountTotal float64 `json:"amount_total"` // 订单金额
|
||||||
|
CouponAmountTotal float64 `json:"coupon_amount_total"` // 优惠卷总金额
|
||||||
|
PaymentAmountTotal float64 `json:"payment_amount_total"` // 实际付款金额
|
||||||
|
PayTime model.LocalTime `json:"pay_time"` // 支付时间
|
||||||
|
ReceptionTime model.LocalTime `json:"reception_time"` // 接诊时间(已接诊)
|
||||||
|
CompleteTime model.LocalTime `json:"complete_time"` // 订单完成时间(问诊完成时间)
|
||||||
|
FinishTime model.LocalTime `json:"finish_time"` // 订单结束时间
|
||||||
|
StatisticsStatus int `json:"statistics_status"` // 订单统计状态(0:未统计 1:已统计 2:统计失败)
|
||||||
|
StatisticsTime model.LocalTime `json:"statistics_time"` // 订单统计时间
|
||||||
|
IsWithdrawal int `json:"is_withdrawal"` // 是否提现(0:否 1:是 2:提现中)
|
||||||
|
WithdrawalTime model.LocalTime `json:"withdrawal_time"` // 提现时间
|
||||||
|
CancelTime model.LocalTime `json:"cancel_time"` // 订单取消时间
|
||||||
|
CancelReason int `json:"cancel_reason"` // 取消订单原因(1:医生未接诊 2:主动取消 3:无可分配医生 4:客服取消 5:支付超时)
|
||||||
|
CancelRemarks string `json:"cancel_remarks"` // 取消订单备注(自动添加)
|
||||||
|
PatientName string `json:"patient_name"` // 患者姓名-就诊人
|
||||||
|
PatientNameMask string `json:"patient_name_mask"` // 患者姓名-就诊人(掩码)
|
||||||
|
PatientSex int `json:"patient_sex"` // 患者性别-就诊人(0:未知 1:男 2:女)
|
||||||
|
PatientAge int `json:"patient_age"` // 患者年龄-就诊人
|
||||||
|
DoctorName string `json:"doctor_name"` // 医生姓名
|
||||||
|
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||||
|
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetOrderInquiryPageResponse 获取用户列表-分页
|
||||||
|
func GetOrderInquiryPageResponse(orderInquiry []*model.OrderInquiry) []getOrderInquiryPage {
|
||||||
|
// 处理返回值
|
||||||
|
getOrderInquiryPages := make([]getOrderInquiryPage, len(orderInquiry))
|
||||||
|
|
||||||
|
if len(orderInquiry) > 0 {
|
||||||
|
for i, v := range orderInquiry {
|
||||||
|
// 将原始结构体转换为新结构体
|
||||||
|
res := getOrderInquiryPage{
|
||||||
|
OrderInquiryId: fmt.Sprintf("%d", v.OrderInquiryId),
|
||||||
|
UserId: fmt.Sprintf("%d", v.UserId),
|
||||||
|
PatientId: fmt.Sprintf("%d", v.PatientId),
|
||||||
|
DoctorId: fmt.Sprintf("%d", v.DoctorId),
|
||||||
|
FamilyId: fmt.Sprintf("%d", v.FamilyId),
|
||||||
|
InquiryType: v.InquiryType,
|
||||||
|
InquiryMode: v.InquiryMode,
|
||||||
|
InquiryStatus: v.InquiryStatus,
|
||||||
|
IsDelete: v.IsDelete,
|
||||||
|
InquiryRefundStatus: v.InquiryRefundStatus,
|
||||||
|
InquiryPayChannel: v.InquiryPayChannel,
|
||||||
|
InquiryPayStatus: v.InquiryPayStatus,
|
||||||
|
InquiryNo: v.InquiryNo,
|
||||||
|
EscrowTradeNo: v.EscrowTradeNo,
|
||||||
|
AmountTotal: v.AmountTotal,
|
||||||
|
CouponAmountTotal: v.CouponAmountTotal,
|
||||||
|
PaymentAmountTotal: v.PaymentAmountTotal,
|
||||||
|
PayTime: v.PayTime,
|
||||||
|
ReceptionTime: v.ReceptionTime,
|
||||||
|
CompleteTime: v.CompleteTime,
|
||||||
|
FinishTime: v.FinishTime,
|
||||||
|
StatisticsStatus: v.StatisticsStatus,
|
||||||
|
StatisticsTime: v.StatisticsTime,
|
||||||
|
IsWithdrawal: v.IsWithdrawal,
|
||||||
|
WithdrawalTime: v.WithdrawalTime,
|
||||||
|
CancelTime: v.CancelTime,
|
||||||
|
CancelReason: v.CancelReason,
|
||||||
|
CancelRemarks: v.CancelRemarks,
|
||||||
|
PatientName: v.PatientName,
|
||||||
|
PatientNameMask: v.PatientNameMask,
|
||||||
|
PatientSex: v.PatientSex,
|
||||||
|
PatientAge: v.PatientAge,
|
||||||
|
CreatedAt: v.CreatedAt,
|
||||||
|
UpdatedAt: v.UpdatedAt,
|
||||||
|
}
|
||||||
|
|
||||||
|
if v.UserDoctor != nil {
|
||||||
|
res.DoctorName = v.UserDoctor.UserName
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将转换后的结构体添加到新切片中
|
||||||
|
getOrderInquiryPages[i] = res
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return getOrderInquiryPages
|
||||||
|
}
|
||||||
@ -2,6 +2,7 @@ package service
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"hospital-admin-api/api/dao"
|
"hospital-admin-api/api/dao"
|
||||||
"hospital-admin-api/api/model"
|
"hospital-admin-api/api/model"
|
||||||
@ -68,10 +69,19 @@ func (r *OrderInquiryService) CancelOrderInquiry(orderInquiryId int64) (bool, er
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 订单完成时间预留5分钟进行操作
|
// 订单完成时间预留5分钟进行操作
|
||||||
if !orderInquiry.CompleteTime.IsZero() {
|
if !orderInquiry.CompleteTime.IsEmpty() {
|
||||||
// 计算三天后的时间
|
// 计算三天后的时间
|
||||||
threeDaysLater := orderInquiry.CompleteTime.Add(3 * 24 * time.Hour)
|
threeDaysLater := time.Time(orderInquiry.CompleteTime).Add(3 * 24 * time.Hour)
|
||||||
if time.Since(threeDaysLater) > 5*time.Minute {
|
|
||||||
|
// 计算三天后的时间与当前时间的时间差
|
||||||
|
timeDifference := threeDaysLater.Sub(time.Now())
|
||||||
|
fmt.Println(timeDifference)
|
||||||
|
|
||||||
|
if timeDifference < 0 {
|
||||||
|
return false, errors.New("订单已完成,无法取消")
|
||||||
|
}
|
||||||
|
|
||||||
|
if 5*time.Minute > timeDifference {
|
||||||
return false, errors.New("距离订单完成时间不足5分钟,无法取消")
|
return false, errors.New("距离订单完成时间不足5分钟,无法取消")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user