修正返回目录
This commit is contained in:
+39
-75
@@ -2,11 +2,10 @@ package service
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"hospital-admin-api/api/dao"
|
||||
"hospital-admin-api/api/dto"
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/api/requests"
|
||||
"hospital-admin-api/api/responses/orderProductResponse"
|
||||
"hospital-admin-api/config"
|
||||
"hospital-admin-api/extend/weChat"
|
||||
"hospital-admin-api/global"
|
||||
@@ -18,7 +17,7 @@ type OrderProductService struct {
|
||||
}
|
||||
|
||||
// GetOrderProduct 药品订单详情
|
||||
func (r *OrderProductService) GetOrderProduct(orderProductId int64) (getOrderProductResponse *orderProductResponse.GetOrderProduct, err error) {
|
||||
func (r *OrderProductService) GetOrderProduct(orderProductId int64) (g *dto.OrderProductDto, err error) {
|
||||
// 获取药品订单数据
|
||||
orderProductDao := dao.OrderProductDao{}
|
||||
orderProduct, err := orderProductDao.GetOrderProductPreloadById(orderProductId)
|
||||
@@ -27,95 +26,60 @@ func (r *OrderProductService) GetOrderProduct(orderProductId int64) (getOrderPro
|
||||
}
|
||||
|
||||
// 获取退款数据
|
||||
orderProductRefundService := OrderProductRefundService{}
|
||||
orderProductRefund, err := orderProductRefundService.GetOrderProductRefundByOrderProductId(orderProductId)
|
||||
if err != nil {
|
||||
return nil, errors.New(err.Error())
|
||||
}
|
||||
orderProductRefundDao := dao.OrderProductRefundDao{}
|
||||
orderProductRefund, err := orderProductRefundDao.GetOrderProductRefundByOrderProductId(orderProductId)
|
||||
|
||||
// 获取商品数据
|
||||
orderProductItemService := OrderProductItemService{}
|
||||
orderProductItem, err := orderProductItemService.GetOrderProductItemByOrderProductId(orderProductId)
|
||||
if err != nil {
|
||||
return nil, errors.New(err.Error())
|
||||
orderProductItemDao := dao.OrderProductItemDao{}
|
||||
orderProductItems, err := orderProductItemDao.GetOrderProductItemByOrderProductId(orderProductId)
|
||||
if err != nil || len(orderProductItems) == 0 {
|
||||
return nil, errors.New("数据错误,无药品数据")
|
||||
}
|
||||
|
||||
// 获取物流数据
|
||||
orderProductLogisticsService := OrderProductLogisticsService{}
|
||||
orderProductLogistics, err := orderProductLogisticsService.GetOrderProductLogisticsByOrderProductId(orderProductId)
|
||||
if err != nil {
|
||||
return nil, errors.New(err.Error())
|
||||
}
|
||||
orderProductLogisticsDao := dao.OrderProductLogisticsDao{}
|
||||
orderProductLogistics, err := orderProductLogisticsDao.GetOrderProductLogisticsByOrderProductId(orderProductId)
|
||||
|
||||
// 获取处方数据
|
||||
orderPrescriptionService := OrderPrescriptionService{}
|
||||
orderPrescription, err := orderPrescriptionService.GetOrderPrescriptionById(orderProduct.OrderPrescriptionId)
|
||||
if err != nil {
|
||||
return nil, errors.New(err.Error())
|
||||
}
|
||||
orderPrescriptionDao := dao.OrderPrescriptionDao{}
|
||||
orderPrescription, err := orderPrescriptionDao.GetById(orderProduct.OrderPrescriptionId)
|
||||
|
||||
// 获取问诊病例
|
||||
orderInquiryCaseService := OrderInquiryCaseService{}
|
||||
orderInquiryCase, err := orderInquiryCaseService.GetOrderInquiryCaseByOrderInquiryId(orderProduct.OrderInquiryId)
|
||||
if err != nil {
|
||||
return nil, errors.New(err.Error())
|
||||
orderInquiryCaseDao := dao.OrderInquiryCaseDao{}
|
||||
orderInquiryCase, err := orderInquiryCaseDao.GetOrderInquiryCaseByOrderInquiryId(orderProduct.OrderInquiryId)
|
||||
if orderInquiryCase == nil {
|
||||
return nil, errors.New("数据错误,无问诊病例")
|
||||
}
|
||||
|
||||
// 医生数据
|
||||
userDoctorService := UserDoctorService{}
|
||||
userDoctor, err := userDoctorService.GetOrderInquiryUserDoctor(orderProduct.DoctorId)
|
||||
userDoctor, err := userDoctorService.GetUserDoctorById(orderProduct.DoctorId)
|
||||
if err != nil {
|
||||
return nil, errors.New(err.Error())
|
||||
}
|
||||
|
||||
// 处理返回值
|
||||
getOrderProductResponse = &orderProductResponse.GetOrderProduct{
|
||||
OrderProductId: fmt.Sprintf("%v", orderProduct.OrderProductId),
|
||||
OrderInquiryId: fmt.Sprintf("%v", orderProduct.OrderInquiryId),
|
||||
OrderPrescriptionId: fmt.Sprintf("%v", orderProduct.OrderPrescriptionId),
|
||||
DoctorId: fmt.Sprintf("%v", orderProduct.DoctorId),
|
||||
PatientId: fmt.Sprintf("%v", orderProduct.PatientId),
|
||||
FamilyId: fmt.Sprintf("%v", orderProduct.FamilyId),
|
||||
OrderProductNo: orderProduct.OrderProductNo,
|
||||
EscrowTradeNo: orderProduct.EscrowTradeNo,
|
||||
OrderProductStatus: orderProduct.OrderProductStatus,
|
||||
PayChannel: orderProduct.PayChannel,
|
||||
PayStatus: orderProduct.PayStatus,
|
||||
CancelReason: orderProduct.CancelReason,
|
||||
AmountTotal: orderProduct.AmountTotal,
|
||||
PaymentAmountTotal: orderProduct.PaymentAmountTotal,
|
||||
LogisticsFee: orderProduct.LogisticsFee,
|
||||
LogisticsNo: orderProduct.LogisticsNo,
|
||||
LogisticsCompanyCode: orderProduct.LogisticsCompanyCode,
|
||||
DeliveryTime: orderProduct.DeliveryTime,
|
||||
PayTime: orderProduct.PayTime,
|
||||
Remarks: orderProduct.Remarks,
|
||||
RefundStatus: orderProduct.RefundStatus,
|
||||
CancelTime: orderProduct.CancelTime,
|
||||
CancelRemarks: orderProduct.CancelRemarks,
|
||||
ReportPreStatus: orderProduct.ReportPreStatus,
|
||||
ReportPreTime: orderProduct.ReportPreTime,
|
||||
ReportPreFailReason: orderProduct.ReportPreFailReason,
|
||||
ProvinceId: orderProduct.ProvinceId,
|
||||
Province: orderProduct.Province,
|
||||
CityId: orderProduct.CityId,
|
||||
City: orderProduct.City,
|
||||
CountyId: orderProduct.CountyId,
|
||||
County: orderProduct.County,
|
||||
AddressMask: orderProduct.AddressMask,
|
||||
ConsigneeNameMask: orderProduct.ConsigneeNameMask,
|
||||
ConsigneeTelMask: orderProduct.ConsigneeTelMask,
|
||||
CreatedAt: orderProduct.CreatedAt,
|
||||
UpdatedAt: orderProduct.UpdatedAt,
|
||||
OrderProductRefund: orderProductRefund,
|
||||
OrderProductItem: orderProductItem,
|
||||
OrderProductLogistics: orderProductLogistics,
|
||||
UserDoctor: userDoctor,
|
||||
OrderPrescription: orderPrescription,
|
||||
OrderInquiryCase: orderInquiryCase,
|
||||
}
|
||||
g = dto.GetOrderProductDto(orderProduct)
|
||||
|
||||
return getOrderProductResponse, nil
|
||||
// 加载医生数据
|
||||
g.UserDoctor = userDoctor
|
||||
|
||||
// 加载问诊病例
|
||||
g.LoadOrderInquiryCase(orderInquiryCase)
|
||||
|
||||
// 加载处方数据
|
||||
g.LoadOrderPrescription(orderPrescription)
|
||||
|
||||
// 加载物流数据
|
||||
g.LoadOrderProductLogistics(orderProductLogistics)
|
||||
|
||||
// 加载商品数据
|
||||
g.LoadOrderProductItem(orderProductItems)
|
||||
|
||||
// 加载退款数据
|
||||
g.LoadOrderProductRefund(orderProductRefund)
|
||||
|
||||
return g, nil
|
||||
}
|
||||
|
||||
// CancelOrderProduct 取消药品订单
|
||||
@@ -305,7 +269,7 @@ func (r *OrderProductService) CancelOrderProduct(req requests.CancelOrderProduct
|
||||
}
|
||||
|
||||
// GetOrderProductConsignee 获取药品订单收货人数据
|
||||
func (r *OrderProductService) GetOrderProductConsignee(orderProductId int64) (*orderProductResponse.GetOrderProductConsignee, error) {
|
||||
func (r *OrderProductService) GetOrderProductConsignee(orderProductId int64) (*dto.OrderProductConsigneeDto, error) {
|
||||
// 获取药品订单数据
|
||||
orderProductDao := dao.OrderProductDao{}
|
||||
orderProduct, err := orderProductDao.GetOrderProductById(orderProductId)
|
||||
@@ -314,7 +278,7 @@ func (r *OrderProductService) GetOrderProductConsignee(orderProductId int64) (*o
|
||||
}
|
||||
|
||||
// 处理返回值
|
||||
u := orderProductResponse.GetOrderProductConsigneeResponse(orderProduct)
|
||||
u := dto.GetOrderProductConsigneeDtoDto(orderProduct)
|
||||
|
||||
return u, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user