新增问诊订单详情。修改错误码格式
This commit is contained in:
+212
-2
@@ -6,6 +6,11 @@ import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/api/dao"
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/api/responses/orderEvaluationResponse"
|
||||
"hospital-admin-api/api/responses/orderInquiryCaseResponse"
|
||||
"hospital-admin-api/api/responses/orderInquiryCouponResponse"
|
||||
"hospital-admin-api/api/responses/orderInquiryRefundResponse"
|
||||
"hospital-admin-api/api/responses/orderInquiryResponse"
|
||||
"hospital-admin-api/config"
|
||||
"hospital-admin-api/extend/weChat"
|
||||
"hospital-admin-api/global"
|
||||
@@ -132,7 +137,6 @@ func (r *OrderInquiryService) CancelOrderInquiry(orderInquiryId int64) (bool, er
|
||||
inquiryRefundStatus = 3
|
||||
|
||||
if refund.SuccessTime != nil {
|
||||
// 使用 time.Parse 解析时间字符串为 time.Time 类型
|
||||
successTime = *refund.SuccessTime
|
||||
}
|
||||
} else if *refund.Status == "CLOSED" {
|
||||
@@ -198,7 +202,7 @@ func (r *OrderInquiryService) CancelOrderInquiry(orderInquiryId int64) (bool, er
|
||||
InquiryRefundStatus: inquiryRefundStatus,
|
||||
RefundTotal: orderInquiry.PaymentAmountTotal,
|
||||
RefundReason: "客服取消",
|
||||
SuccessTime: successTime,
|
||||
SuccessTime: model.LocalTime(successTime),
|
||||
}
|
||||
|
||||
orderInquiryRefundDao := dao.OrderInquiryRefundDao{}
|
||||
@@ -250,3 +254,209 @@ func ReturnInquiryCoupon(tx *gorm.DB, orderInquiryId int64) bool {
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// GetOrderInquiry 问诊订单详情
|
||||
func (r *OrderInquiryService) GetOrderInquiry(orderInquiryId int64) (getOrderInquiryResponse *orderInquiryResponse.GetOrderInquiry, err error) {
|
||||
// 获取问诊订单数据
|
||||
orderInquiryDao := dao.OrderInquiryDao{}
|
||||
orderInquiry, err := orderInquiryDao.GetOrderInquiryPreloadById(orderInquiryId)
|
||||
if err != nil || orderInquiry == nil {
|
||||
return nil, errors.New(err.Error())
|
||||
}
|
||||
|
||||
// 获取问诊订单优惠卷
|
||||
orderInquiryCoupon, err := r.GetOrderInquiryCoupon(orderInquiryId)
|
||||
if err != nil {
|
||||
return nil, errors.New(err.Error())
|
||||
}
|
||||
|
||||
// 获取问诊病例
|
||||
orderInquiryCase, err := r.GetOrderInquiryCase(orderInquiryId)
|
||||
if err != nil {
|
||||
return nil, errors.New(err.Error())
|
||||
}
|
||||
|
||||
// 获取退款数据
|
||||
orderInquiryRefund, err := r.GetOrderInquiryRefund(orderInquiryId)
|
||||
if err != nil {
|
||||
return nil, errors.New(err.Error())
|
||||
}
|
||||
|
||||
// 获取订单评价
|
||||
orderEvaluation, err := r.GetOrderEvaluation(orderInquiryId)
|
||||
if err != nil {
|
||||
return nil, errors.New(err.Error())
|
||||
}
|
||||
|
||||
// 医生数据
|
||||
userDoctorService := UserDoctorService{}
|
||||
userDoctor, err := userDoctorService.GetOrderInquiryUserDoctor(orderInquiry.DoctorId)
|
||||
if err != nil {
|
||||
return nil, errors.New(err.Error())
|
||||
}
|
||||
|
||||
// 处理医生id
|
||||
var doctorId string
|
||||
if orderInquiry.DoctorId != 0 {
|
||||
doctorId = fmt.Sprintf("%v", orderInquiry.DoctorId)
|
||||
}
|
||||
|
||||
// 处理返回值
|
||||
getOrderInquiryResponse = &orderInquiryResponse.GetOrderInquiry{
|
||||
OrderInquiryId: strconv.FormatInt(orderInquiry.OrderInquiryId, 10),
|
||||
UserId: strconv.FormatInt(orderInquiry.UserId, 10),
|
||||
DoctorId: doctorId,
|
||||
PatientId: strconv.FormatInt(orderInquiry.PatientId, 10),
|
||||
FamilyId: strconv.FormatInt(orderInquiry.FamilyId, 10),
|
||||
InquiryType: orderInquiry.InquiryType,
|
||||
InquiryMode: orderInquiry.InquiryMode,
|
||||
InquiryStatus: orderInquiry.InquiryStatus,
|
||||
IsDelete: orderInquiry.IsDelete,
|
||||
InquiryRefundStatus: orderInquiry.InquiryRefundStatus,
|
||||
InquiryPayChannel: orderInquiry.InquiryPayChannel,
|
||||
InquiryPayStatus: orderInquiry.InquiryPayStatus,
|
||||
InquiryNo: orderInquiry.InquiryNo,
|
||||
EscrowTradeNo: orderInquiry.EscrowTradeNo,
|
||||
AmountTotal: orderInquiry.AmountTotal,
|
||||
CouponAmountTotal: orderInquiry.CouponAmountTotal,
|
||||
PaymentAmountTotal: orderInquiry.PaymentAmountTotal,
|
||||
PayTime: orderInquiry.PayTime,
|
||||
ReceptionTime: orderInquiry.ReceptionTime,
|
||||
CompleteTime: orderInquiry.CompleteTime,
|
||||
FinishTime: orderInquiry.FinishTime,
|
||||
StatisticsStatus: orderInquiry.StatisticsStatus,
|
||||
StatisticsTime: orderInquiry.StatisticsTime,
|
||||
IsWithdrawal: orderInquiry.IsWithdrawal,
|
||||
WithdrawalTime: orderInquiry.WithdrawalTime,
|
||||
CancelTime: orderInquiry.CancelTime,
|
||||
CancelReason: orderInquiry.CancelReason,
|
||||
CancelRemarks: orderInquiry.CancelRemarks,
|
||||
PatientName: orderInquiry.PatientName,
|
||||
PatientNameMask: orderInquiry.PatientNameMask,
|
||||
PatientSex: orderInquiry.PatientSex,
|
||||
PatientAge: orderInquiry.PatientAge,
|
||||
OrderInquiryCoupon: orderInquiryCoupon,
|
||||
OrderInquiryCase: orderInquiryCase,
|
||||
OrderInquiryRefund: orderInquiryRefund,
|
||||
OrderEvaluation: orderEvaluation,
|
||||
UserDoctor: userDoctor,
|
||||
CreatedAt: orderInquiry.CreatedAt,
|
||||
UpdatedAt: orderInquiry.UpdatedAt,
|
||||
}
|
||||
|
||||
return getOrderInquiryResponse, nil
|
||||
}
|
||||
|
||||
// GetOrderInquiryCoupon 获取问诊订单优惠卷
|
||||
func (r *OrderInquiryService) GetOrderInquiryCoupon(orderInquiryId int64) (u *orderInquiryCouponResponse.OrderInquiryCoupon, err error) {
|
||||
orderInquiryCouponDao := dao.OrderInquiryCouponDao{}
|
||||
orderInquiryCoupon, err := orderInquiryCouponDao.GetOrderInquiryCouponByOrderInquiryId(orderInquiryId)
|
||||
if orderInquiryCoupon == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
u = &orderInquiryCouponResponse.OrderInquiryCoupon{
|
||||
OrderCouponId: strconv.FormatInt(orderInquiryCoupon.OrderCouponId, 10),
|
||||
OrderInquiryId: strconv.FormatInt(orderInquiryCoupon.OrderInquiryId, 10),
|
||||
UserCouponId: strconv.FormatInt(orderInquiryCoupon.UserCouponId, 10),
|
||||
CouponName: orderInquiryCoupon.CouponName,
|
||||
CouponUsePrice: orderInquiryCoupon.CouponUsePrice,
|
||||
CreatedAt: orderInquiryCoupon.CreatedAt,
|
||||
UpdatedAt: orderInquiryCoupon.UpdatedAt,
|
||||
}
|
||||
|
||||
return u, nil
|
||||
}
|
||||
|
||||
// GetOrderInquiryCase 获取问诊订单病例
|
||||
func (r *OrderInquiryService) GetOrderInquiryCase(orderInquiryId int64) (u *orderInquiryCaseResponse.OrderInquiryCase, err error) {
|
||||
orderInquiryCaseDao := dao.OrderInquiryCaseDao{}
|
||||
orderInquiryCase, err := orderInquiryCaseDao.GetOrderInquiryCaseByOrderInquiryId(orderInquiryId)
|
||||
if orderInquiryCase == nil {
|
||||
return nil, errors.New("数据错误,无问诊病例")
|
||||
}
|
||||
|
||||
u = &orderInquiryCaseResponse.OrderInquiryCase{
|
||||
InquiryCaseId: strconv.FormatInt(orderInquiryCase.InquiryCaseId, 10),
|
||||
UserId: strconv.FormatInt(orderInquiryCase.UserId, 10),
|
||||
PatientId: strconv.FormatInt(orderInquiryCase.PatientId, 10),
|
||||
OrderInquiryId: strconv.FormatInt(orderInquiryCase.OrderInquiryId, 10),
|
||||
FamilyId: strconv.FormatInt(orderInquiryCase.FamilyId, 10),
|
||||
Relation: orderInquiryCase.Relation,
|
||||
Status: orderInquiryCase.Status,
|
||||
Name: orderInquiryCase.Name,
|
||||
Sex: orderInquiryCase.Sex,
|
||||
Age: orderInquiryCase.Age,
|
||||
Height: orderInquiryCase.Height,
|
||||
Weight: orderInquiryCase.Weight,
|
||||
DiseaseClassId: strconv.FormatInt(orderInquiryCase.DiseaseClassId, 10),
|
||||
DiseaseClassName: orderInquiryCase.DiseaseClassName,
|
||||
DiagnosisDate: orderInquiryCase.DiagnosisDate,
|
||||
DiseaseDesc: orderInquiryCase.DiseaseDesc,
|
||||
DiagnoseImages: orderInquiryCase.DiagnoseImages,
|
||||
IsAllergyHistory: orderInquiryCase.IsAllergyHistory,
|
||||
AllergyHistory: orderInquiryCase.AllergyHistory,
|
||||
IsFamilyHistory: orderInquiryCase.IsFamilyHistory,
|
||||
FamilyHistory: orderInquiryCase.FamilyHistory,
|
||||
IsPregnant: orderInquiryCase.IsPregnant,
|
||||
Pregnant: orderInquiryCase.Pregnant,
|
||||
IsTaboo: orderInquiryCase.IsTaboo,
|
||||
CreatedAt: orderInquiryCase.CreatedAt,
|
||||
UpdatedAt: orderInquiryCase.UpdatedAt,
|
||||
}
|
||||
|
||||
return u, nil
|
||||
}
|
||||
|
||||
// GetOrderInquiryRefund 获取问诊订单退款数据
|
||||
func (r *OrderInquiryService) GetOrderInquiryRefund(orderInquiryId int64) (u *orderInquiryRefundResponse.OrderInquiryRefund, err error) {
|
||||
orderInquiryRefundDao := dao.OrderInquiryRefundDao{}
|
||||
orderInquiryRefund, err := orderInquiryRefundDao.GetOrderInquiryRefundByOrderInquiryId(orderInquiryId)
|
||||
if orderInquiryRefund == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
u = &orderInquiryRefundResponse.OrderInquiryRefund{
|
||||
InquiryRefundId: strconv.FormatInt(orderInquiryRefund.InquiryRefundId, 10),
|
||||
PatientId: strconv.FormatInt(orderInquiryRefund.PatientId, 10),
|
||||
OrderInquiryId: strconv.FormatInt(orderInquiryRefund.OrderInquiryId, 10),
|
||||
InquiryNo: orderInquiryRefund.InquiryNo,
|
||||
InquiryRefundNo: orderInquiryRefund.InquiryRefundNo,
|
||||
RefundId: orderInquiryRefund.RefundId,
|
||||
InquiryRefundStatus: orderInquiryRefund.InquiryRefundStatus,
|
||||
RefundTotal: orderInquiryRefund.RefundTotal,
|
||||
RefundReason: orderInquiryRefund.RefundReason,
|
||||
SuccessTime: orderInquiryRefund.SuccessTime,
|
||||
CreatedAt: orderInquiryRefund.CreatedAt,
|
||||
UpdatedAt: orderInquiryRefund.UpdatedAt,
|
||||
}
|
||||
|
||||
return u, nil
|
||||
}
|
||||
|
||||
// GetOrderEvaluation 获取问诊订单评价数据
|
||||
func (r *OrderInquiryService) GetOrderEvaluation(orderInquiryId int64) (u *orderEvaluationResponse.OrderEvaluation, err error) {
|
||||
orderEvaluationDao := dao.OrderEvaluationDao{}
|
||||
orderEvaluation, err := orderEvaluationDao.GetOrderEvaluationByOrderInquiryId(orderInquiryId)
|
||||
if orderEvaluation == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
u = &orderEvaluationResponse.OrderEvaluation{
|
||||
EvaluationId: strconv.FormatInt(orderEvaluation.EvaluationId, 10),
|
||||
DoctorId: strconv.FormatInt(orderEvaluation.DoctorId, 10),
|
||||
PatientId: strconv.FormatInt(orderEvaluation.PatientId, 10),
|
||||
OrderInquiryId: strconv.FormatInt(orderEvaluation.OrderInquiryId, 10),
|
||||
NameMask: orderEvaluation.NameMask,
|
||||
ReplyQuality: orderEvaluation.ReplyQuality,
|
||||
ServiceAttitude: orderEvaluation.ServiceAttitude,
|
||||
ReplyProgress: orderEvaluation.ReplyProgress,
|
||||
AvgScore: orderEvaluation.AvgScore,
|
||||
Type: orderEvaluation.Type,
|
||||
Content: orderEvaluation.Content,
|
||||
CreatedAt: orderEvaluation.CreatedAt,
|
||||
UpdatedAt: orderEvaluation.UpdatedAt,
|
||||
}
|
||||
|
||||
return u, nil
|
||||
}
|
||||
|
||||
@@ -1738,3 +1738,45 @@ func (r *UserDoctorService) PutMulti(doctorId int64, req requests.PutMulti) (boo
|
||||
tx.Commit()
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// GetOrderInquiryUserDoctor 获取医生数据-问诊订单
|
||||
func (r *UserDoctorService) GetOrderInquiryUserDoctor(doctorId int64) (u *userDoctorResponse.OrderInquiryUserDoctor, err error) {
|
||||
if doctorId == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
userDoctorDao := dao.UserDoctorDao{}
|
||||
userDoctor, err := userDoctorDao.GetUserDoctorPreloadById(doctorId)
|
||||
if err != nil || userDoctor == nil {
|
||||
return nil, errors.New("医生数据错误")
|
||||
}
|
||||
|
||||
// 医院
|
||||
var hospital *hospitalResponse.Hospital
|
||||
if userDoctor.Hospital != nil {
|
||||
hospital = hospitalResponse.HospitalResponse(userDoctor.Hospital)
|
||||
}
|
||||
|
||||
var userDoctorInfo *userDoctorInfoResponse.UserDoctorInfo
|
||||
if userDoctor.UserDoctorInfo != nil {
|
||||
userDoctorInfo = userDoctorInfoResponse.UserDoctorInfoResponse(userDoctor.UserDoctorInfo)
|
||||
}
|
||||
|
||||
u = &userDoctorResponse.OrderInquiryUserDoctor{
|
||||
DoctorID: strconv.Itoa(int(userDoctor.DoctorId)),
|
||||
UserID: strconv.Itoa(int(userDoctor.UserId)),
|
||||
UserName: userDoctor.UserName,
|
||||
Status: userDoctor.Status,
|
||||
IDCardStatus: userDoctor.Status,
|
||||
MultiPointStatus: userDoctor.MultiPointStatus,
|
||||
Avatar: utils.AddOssDomain(userDoctor.Avatar),
|
||||
DoctorTitle: userDoctor.DoctorTitle,
|
||||
DepartmentCustomName: userDoctor.DepartmentCustomName,
|
||||
HospitalID: strconv.Itoa(int(userDoctor.HospitalID)),
|
||||
CreatedAt: userDoctor.CreatedAt,
|
||||
UpdatedAt: userDoctor.UpdatedAt,
|
||||
Hospital: hospital,
|
||||
UserDoctorInfo: userDoctorInfo,
|
||||
}
|
||||
|
||||
return u, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user