From 3205005b9a4f1361881acee9f68a5d6f277c9dd5 Mon Sep 17 00:00:00 2001 From: haomingming Date: Mon, 7 Sep 2026 16:25:04 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8D=AF=E5=93=81=E3=80=81=E5=A4=84=E6=96=B9?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=85=B3=E8=81=94=E8=8D=AF=E6=88=BF=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/dao/orderPrescription.go | 59 +++++++++++++++++++++++++++++++ api/dao/orderProduct.go | 28 +++++++++++++++ api/dto/OrderPrescription.go | 38 ++++++++++++++++++++ api/dto/OrderProduct.go | 38 ++++++++++++++++++++ api/model/orderPrescription.go | 4 +++ api/model/orderProduct.go | 4 +++ api/requests/orderPrescription.go | 6 ++++ api/requests/orderProduct.go | 6 ++++ api/service/export.go | 34 ++++++++++++++++++ api/service/order.go | 8 ++++- 10 files changed, 224 insertions(+), 1 deletion(-) diff --git a/api/dao/orderPrescription.go b/api/dao/orderPrescription.go index a95829b..d93616b 100644 --- a/api/dao/orderPrescription.go +++ b/api/dao/orderPrescription.go @@ -27,6 +27,9 @@ func (r *OrderPrescriptionDao) GetById(orderPrescriptionId int64) (m *model.Orde }) }) + // 药房 + query = query.Preload("Pharmacy") + err = query.First(&m, orderPrescriptionId).Error if err != nil { return nil, err @@ -100,6 +103,9 @@ func (r *OrderPrescriptionDao) GetOrderPrescriptionPageSearch(req requests.GetOr query = query.Where("gdxz_order_inquiry.annual_review_hide = ?", req.AnnualReviewHide) } + // 药房表 + query = query.Preload("Pharmacy") + // 患者表 query = query.Preload("UserPatient", func(db *gorm.DB) *gorm.DB { return db.Omit("open_id", "union_id", "wx_session_key") @@ -130,6 +136,17 @@ func (r *OrderPrescriptionDao) GetOrderPrescriptionPageSearch(req requests.GetOr // 患者家庭成员表 query = query.Preload("PatientFamily") + // 药房筛选 + if req.PharmacyId != "" { + query = query.Where("gdxz_order_prescription.pharmacy_id = ?", req.PharmacyId) + } + if req.PharmacyCode != "" { + query = query.Where("gdxz_order_prescription.pharmacy_code LIKE ?", "%"+req.PharmacyCode+"%") + } + if req.PharmacyName != "" { + query = query.Where("gdxz_order_prescription.pharmacy_name LIKE ?", "%"+req.PharmacyName+"%") + } + // 处方编号 if req.PrescriptionCode != "" { query = query.Where("prescription_code = ?", req.PrescriptionCode) @@ -311,6 +328,20 @@ func (r *OrderPrescriptionDao) GetOrderPrescriptionTransferPageSearch(req reques // 患者家庭成员表 query = query.Preload("PatientFamily") + // 药房表 + query = query.Preload("Pharmacy") + + // 药房筛选 + if req.PharmacyId != "" { + query = query.Where(prescriptionTable+".pharmacy_id = ?", req.PharmacyId) + } + if req.PharmacyCode != "" { + query = query.Where(prescriptionTable+".pharmacy_code LIKE ?", "%"+req.PharmacyCode+"%") + } + if req.PharmacyName != "" { + query = query.Where(prescriptionTable+".pharmacy_name LIKE ?", "%"+req.PharmacyName+"%") + } + // 处方编号 if req.PrescriptionCode != "" { query = query.Where(prescriptionTable+".prescription_code = ?", req.PrescriptionCode) @@ -504,8 +535,22 @@ func (r *OrderPrescriptionDao) GetOrderTransferPrescriptionExportListSearch(req // 患者家庭成员表 query = query.Preload("PatientFamily") + // 药房表 + query = query.Preload("Pharmacy") + // 当前搜索数据 if req.Type == 1 { + // 药房筛选 + if req.PharmacyId != "" { + query = query.Where(prescriptionTable+".pharmacy_id = ?", req.PharmacyId) + } + if req.PharmacyCode != "" { + query = query.Where(prescriptionTable+".pharmacy_code LIKE ?", "%"+req.PharmacyCode+"%") + } + if req.PharmacyName != "" { + query = query.Where(prescriptionTable+".pharmacy_name LIKE ?", "%"+req.PharmacyName+"%") + } + // 处方编号 if req.PrescriptionCode != "" { query = query.Where("prescription_code = ?", req.PrescriptionCode) @@ -687,8 +732,22 @@ func (r *OrderPrescriptionDao) GetOrderPrescriptionExportListSearch(req requests // 患者家庭成员表 query = query.Preload("PatientFamily") + // 药房表 + query = query.Preload("Pharmacy") + // 当前搜索数据 if req.Type == 1 { + // 药房筛选 + if req.PharmacyId != "" { + query = query.Where("gdxz_order_prescription.pharmacy_id = ?", req.PharmacyId) + } + if req.PharmacyCode != "" { + query = query.Where("gdxz_order_prescription.pharmacy_code LIKE ?", "%"+req.PharmacyCode+"%") + } + if req.PharmacyName != "" { + query = query.Where("gdxz_order_prescription.pharmacy_name LIKE ?", "%"+req.PharmacyName+"%") + } + // 处方编号 if req.PrescriptionCode != "" { query = query.Where("prescription_code = ?", req.PrescriptionCode) diff --git a/api/dao/orderProduct.go b/api/dao/orderProduct.go index 4d528b1..cc2b496 100644 --- a/api/dao/orderProduct.go +++ b/api/dao/orderProduct.go @@ -132,6 +132,20 @@ func (r *OrderProductDao) GetOrderProductPageSearch(req requests.GetOrderProduct // 药品数据 query = query.Preload("OrderProductItem") + // 药房数据 + query = query.Preload("Pharmacy") + + // 药房筛选 + if req.PharmacyId != "" { + query = query.Where("gdxz_order_product.pharmacy_id = ?", req.PharmacyId) + } + if req.PharmacyCode != "" { + query = query.Where("gdxz_order_product.pharmacy_code LIKE ?", "%"+req.PharmacyCode+"%") + } + if req.PharmacyName != "" { + query = query.Where("gdxz_order_product.pharmacy_name LIKE ?", "%"+req.PharmacyName+"%") + } + // 医生 query = query.Preload("UserDoctor", func(db *gorm.DB) *gorm.DB { return db.Omit("open_id", "union_id", "wx_session_key") @@ -463,8 +477,22 @@ func (r *OrderProductDao) GetOrderProductExportListSearch(req requests.OrderProd // 药品列表-药品 query = query.Preload("OrderProductItem.Product") + // 药房数据 + query = query.Preload("Pharmacy") + // 当前搜索数据 if req.Type == 1 { + // 药房筛选 + if req.PharmacyId != "" { + query = query.Where("gdxz_order_product.pharmacy_id = ?", req.PharmacyId) + } + if req.PharmacyCode != "" { + query = query.Where("gdxz_order_product.pharmacy_code LIKE ?", "%"+req.PharmacyCode+"%") + } + if req.PharmacyName != "" { + query = query.Where("gdxz_order_product.pharmacy_name LIKE ?", "%"+req.PharmacyName+"%") + } + // 医生姓名 - 同时查询原医生和抄方医生 if req.DoctorName != "" { // 原医生查询条件 diff --git a/api/dto/OrderPrescription.go b/api/dto/OrderPrescription.go index 52e5c85..b2fc8c1 100644 --- a/api/dto/OrderPrescription.go +++ b/api/dto/OrderPrescription.go @@ -40,11 +40,28 @@ type OrderPrescriptionDto struct { UserDoctor *UserDoctorDto `json:"user_doctor"` // 原始医生 InquiryDoctor *UserDoctorDto `json:"inquiry_doctor"` // 问诊医生信息 TransferUserDoctor *UserDoctorDto `json:"transfer_prescription_doctor"` // 接受抄方的医生(抄方处方医生信息) + PharmacyId string `json:"pharmacy_id"` // 药房id + PharmacyCode string `json:"pharmacy_code"` // 药房代码 + PharmacyName string `json:"pharmacy_name"` // 药房名称 + Pharmacy *PharmacyDto `json:"pharmacy"` // 药房详情 CreatedAt model.LocalTime `json:"created_at"` // 创建时间 UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间 } func GetOrderPrescriptionDto(m *model.OrderPrescription) *OrderPrescriptionDto { + pharmacyName := m.PharmacyName + pharmacyCode := m.PharmacyCode + var pharmacyDto *PharmacyDto + if m.Pharmacy != nil { + pharmacyDto = GetPharmacyDto(m.Pharmacy) + if pharmacyName == "" { + pharmacyName = m.Pharmacy.PharmacyName + } + if pharmacyCode == "" { + pharmacyCode = m.Pharmacy.PharmacyCode + } + } + return &OrderPrescriptionDto{ OrderPrescriptionId: fmt.Sprintf("%d", m.OrderPrescriptionId), OrderInquiryId: fmt.Sprintf("%d", m.OrderInquiryId), @@ -69,6 +86,10 @@ func GetOrderPrescriptionDto(m *model.OrderPrescription) *OrderPrescriptionDto { PatientSex: m.PatientSex, PatientAge: m.PatientAge, DoctorAdvice: m.DoctorAdvice, + PharmacyId: fmt.Sprintf("%d", m.PharmacyId), + PharmacyCode: pharmacyCode, + PharmacyName: pharmacyName, + Pharmacy: pharmacyDto, CreatedAt: m.CreatedAt, UpdatedAt: m.UpdatedAt, } @@ -80,6 +101,19 @@ func GetOrderPrescriptionListDto(m []*model.OrderPrescription) []*OrderPrescript if len(m) > 0 { for i, v := range m { + pharmacyName := v.PharmacyName + pharmacyCode := v.PharmacyCode + var pharmacyDto *PharmacyDto + if v.Pharmacy != nil { + pharmacyDto = GetPharmacyDto(v.Pharmacy) + if pharmacyName == "" { + pharmacyName = v.Pharmacy.PharmacyName + } + if pharmacyCode == "" { + pharmacyCode = v.Pharmacy.PharmacyCode + } + } + response := &OrderPrescriptionDto{ OrderPrescriptionId: fmt.Sprintf("%d", v.OrderPrescriptionId), OrderInquiryId: fmt.Sprintf("%d", v.OrderInquiryId), @@ -104,6 +138,10 @@ func GetOrderPrescriptionListDto(m []*model.OrderPrescription) []*OrderPrescript PatientSex: v.PatientSex, PatientAge: v.PatientAge, DoctorAdvice: v.DoctorAdvice, + PharmacyId: fmt.Sprintf("%d", v.PharmacyId), + PharmacyCode: pharmacyCode, + PharmacyName: pharmacyName, + Pharmacy: pharmacyDto, CreatedAt: v.CreatedAt, UpdatedAt: v.UpdatedAt, } diff --git a/api/dto/OrderProduct.go b/api/dto/OrderProduct.go index 5a5c951..619b02a 100644 --- a/api/dto/OrderProduct.go +++ b/api/dto/OrderProduct.go @@ -65,6 +65,10 @@ type OrderProductDto struct { OrderProductCoupon *OrderProductCouponDto `json:"order_product_coupon"` // 优惠卷 ProductName string `json:"product_name"` // 药品数据 DiscountAmount float64 `json:"discount_amount"` // 优惠金额 + PharmacyId string `json:"pharmacy_id"` // 药房id + PharmacyCode string `json:"pharmacy_code"` // 药房代码 + PharmacyName string `json:"pharmacy_name"` // 药房名称 + Pharmacy *PharmacyDto `json:"pharmacy"` // 药房详情 } // OrderProductConsigneeDto 药品订单收货人数据 @@ -81,6 +85,19 @@ type OrderProductConsigneeDto struct { } func GetOrderProductDto(m *model.OrderProduct) *OrderProductDto { + pharmacyName := m.PharmacyName + pharmacyCode := m.PharmacyCode + var pharmacyDto *PharmacyDto + if m.Pharmacy != nil { + pharmacyDto = GetPharmacyDto(m.Pharmacy) + if pharmacyName == "" { + pharmacyName = m.Pharmacy.PharmacyName + } + if pharmacyCode == "" { + pharmacyCode = m.Pharmacy.PharmacyCode + } + } + return &OrderProductDto{ OrderProductId: fmt.Sprintf("%d", m.OrderProductId), OrderInquiryId: fmt.Sprintf("%d", m.OrderInquiryId), @@ -117,6 +134,10 @@ func GetOrderProductDto(m *model.OrderProduct) *OrderProductDto { AddressMask: m.AddressMask, ConsigneeNameMask: m.ConsigneeNameMask, ConsigneeTelMask: m.ConsigneeTelMask, + PharmacyId: fmt.Sprintf("%d", m.PharmacyId), + PharmacyCode: pharmacyCode, + PharmacyName: pharmacyName, + Pharmacy: pharmacyDto, CreatedAt: m.CreatedAt, UpdatedAt: m.UpdatedAt, } @@ -143,6 +164,19 @@ func GetOrderProductListDto(m []*model.OrderProduct) []*OrderProductDto { if len(m) > 0 { for i, v := range m { + pharmacyName := v.PharmacyName + pharmacyCode := v.PharmacyCode + var pharmacyDto *PharmacyDto + if v.Pharmacy != nil { + pharmacyDto = GetPharmacyDto(v.Pharmacy) + if pharmacyName == "" { + pharmacyName = v.Pharmacy.PharmacyName + } + if pharmacyCode == "" { + pharmacyCode = v.Pharmacy.PharmacyCode + } + } + response := &OrderProductDto{ OrderProductId: fmt.Sprintf("%d", v.OrderProductId), OrderInquiryId: fmt.Sprintf("%d", v.OrderInquiryId), @@ -169,6 +203,10 @@ func GetOrderProductListDto(m []*model.OrderProduct) []*OrderProductDto { ConsigneeNameMask: v.ConsigneeNameMask, ConsigneeTelMask: v.ConsigneeTelMask, PatientMobile: v.UserPatient.User.Mobile, + PharmacyId: fmt.Sprintf("%d", v.PharmacyId), + PharmacyCode: pharmacyCode, + PharmacyName: pharmacyName, + Pharmacy: pharmacyDto, CreatedAt: v.CreatedAt, UpdatedAt: v.UpdatedAt, } diff --git a/api/model/orderPrescription.go b/api/model/orderPrescription.go index d162ea8..8f1717c 100644 --- a/api/model/orderPrescription.go +++ b/api/model/orderPrescription.go @@ -31,12 +31,16 @@ type OrderPrescription struct { PatientSex int `gorm:"column:patient_sex;type:tinyint(1);comment:患者性别-就诊人(1:男 2:女)" json:"patient_sex"` PatientAge int `gorm:"column:patient_age;type:int(11);comment:患者年龄-就诊人" json:"patient_age"` DoctorAdvice string `gorm:"column:doctor_advice;type:varchar(255);comment:医嘱" json:"doctor_advice"` + PharmacyId int64 `gorm:"column:pharmacy_id;type:bigint(19);default:0;comment:开方药房id" json:"pharmacy_id"` + PharmacyCode string `gorm:"column:pharmacy_code;type:varchar(64);comment:开方药房代码快照" json:"pharmacy_code"` + PharmacyName string `gorm:"column:pharmacy_name;type:varchar(100);comment:开方药房名称快照" json:"pharmacy_name"` OrderInquiry *OrderInquiry `gorm:"foreignKey:OrderInquiryId;references:order_inquiry_id" json:"order_inquiry"` // 问诊订单 UserDoctor *UserDoctor `gorm:"foreignKey:DoctorId;references:doctor_id" json:"user_doctor"` // 医生 UserPharmacist *UserPharmacist `gorm:"foreignKey:PharmacistId;references:pharmacist_id" json:"user_pharmacist"` // 药师 UserPatient *UserPatient `gorm:"foreignKey:PatientId;references:patient_id" json:"user_patient"` // 患者 OrderPrescriptionIcd []*OrderPrescriptionIcd `gorm:"foreignKey:OrderPrescriptionId;references:order_prescription_id" json:"order_prescription_icd"` // 处方疾病 PatientFamily *PatientFamily `gorm:"foreignKey:FamilyId;references:family_id" json:"patient_family"` // 家庭成员 + Pharmacy *Pharmacy `gorm:"foreignKey:PharmacyId;references:pharmacy_id" json:"pharmacy"` // 药房 Model } diff --git a/api/model/orderProduct.go b/api/model/orderProduct.go index 836f1e8..c92d0c6 100644 --- a/api/model/orderProduct.go +++ b/api/model/orderProduct.go @@ -50,11 +50,15 @@ type OrderProduct struct { ConsigneeNameMask string `gorm:"column:consignee_name_mask;type:varchar(150);comment:收货人姓名(掩码)" json:"consignee_name_mask"` ConsigneeTel string `gorm:"column:consignee_tel;type:varchar(50);comment:收货人电话" json:"consignee_tel"` ConsigneeTelMask string `gorm:"column:consignee_tel_mask;type:varchar(50);comment:收货人电话(掩码)" json:"consignee_tel_mask"` + PharmacyId int64 `gorm:"column:pharmacy_id;type:bigint(19);default:0;comment:发货药房id" json:"pharmacy_id"` + PharmacyCode string `gorm:"column:pharmacy_code;type:varchar(64);comment:发货药房代码快照" json:"pharmacy_code"` + PharmacyName string `gorm:"column:pharmacy_name;type:varchar(100);comment:发货药房名称快照" json:"pharmacy_name"` UserDoctor *UserDoctor `gorm:"foreignKey:DoctorId;references:doctor_id" json:"user_doctor"` // 医生 OrderInquiry *OrderInquiry `gorm:"foreignKey:OrderInquiryId;references:order_inquiry_id" json:"order_inquiry"` // 问诊 UserPatient *UserPatient `gorm:"foreignKey:PatientId;references:patient_id" json:"user_patient"` // 患者 OrderPrescription *OrderPrescription `gorm:"foreignKey:OrderPrescriptionId;references:order_prescription_id" json:"order_prescription"` // 处方 OrderProductItem []*OrderProductItem `gorm:"foreignKey:OrderProductId;references:order_product_id" json:"order_product_item"` // 处方 + Pharmacy *Pharmacy `gorm:"foreignKey:PharmacyId;references:pharmacy_id" json:"pharmacy"` // 药房 Model } diff --git a/api/requests/orderPrescription.go b/api/requests/orderPrescription.go index f68256f..532cc01 100644 --- a/api/requests/orderPrescription.go +++ b/api/requests/orderPrescription.go @@ -20,6 +20,9 @@ type GetOrderPrescriptionPage struct { ExpiredTime string `json:"expired_time" form:"expired_time" label:"处方过期时间"` // 时间区间,数组形式,下标0为开始时间,下标1为结束时间 InquiryNo string `json:"inquiry_no" form:"inquiry_no" label:"问诊订单编号"` OrderProductNo string `json:"order_product_no" form:"order_product_no" label:"药品订单编号"` + PharmacyId string `json:"pharmacy_id" form:"pharmacy_id" label:"药房id"` + PharmacyCode string `json:"pharmacy_code" form:"pharmacy_code" label:"药房代码"` + PharmacyName string `json:"pharmacy_name" form:"pharmacy_name" label:"药房名称"` AnnualReviewHide *int `json:"-" form:"-"` // 内部传递条件 } @@ -38,5 +41,8 @@ type OrderPrescriptionExportList struct { ExpiredTime string `json:"expired_time" form:"expired_time" label:"处方过期时间"` // 时间区间,数组形式,下标0为开始时间,下标1为结束时间 InquiryNo string `json:"inquiry_no" form:"inquiry_no" label:"问诊订单编号"` OrderProductNo string `json:"order_product_no" form:"order_product_no" label:"药品订单编号"` + PharmacyId string `json:"pharmacy_id" form:"pharmacy_id" label:"药房id"` + PharmacyCode string `json:"pharmacy_code" form:"pharmacy_code" label:"药房代码"` + PharmacyName string `json:"pharmacy_name" form:"pharmacy_name" label:"药房名称"` AnnualReviewHide *int `json:"-" form:"-"` // 内部传递条件 } diff --git a/api/requests/orderProduct.go b/api/requests/orderProduct.go index 954602f..268be68 100644 --- a/api/requests/orderProduct.go +++ b/api/requests/orderProduct.go @@ -34,6 +34,9 @@ type GetOrderProductPage struct { ProductName string `json:"product_name" form:"product_name" label:"药品名称"` CommonName string `json:"common_name" form:"common_name" label:"药品通用名"` PrescriptionCode string `json:"prescription_code" form:"prescription_code" label:"处方编号"` + PharmacyId string `json:"pharmacy_id" form:"pharmacy_id" label:"药房id"` + PharmacyCode string `json:"pharmacy_code" form:"pharmacy_code" label:"药房代码"` + PharmacyName string `json:"pharmacy_name" form:"pharmacy_name" label:"药房名称"` AnnualReviewHide *int `json:"-" form:"-"` // 内部传递条件 } @@ -67,5 +70,8 @@ type OrderProductExportList struct { ConsigneeTel string `json:"consignee_tel" form:"cancel_reason" label:"收货人电话"` PatientName string `json:"patient_name" form:"patient_name" label:"患者姓名-就诊人"` Mobile string `json:"mobile" form:"mobile" label:"手机号-医生/患者"` + PharmacyId string `json:"pharmacy_id" form:"pharmacy_id" label:"药房id"` + PharmacyCode string `json:"pharmacy_code" form:"pharmacy_code" label:"药房代码"` + PharmacyName string `json:"pharmacy_name" form:"pharmacy_name" label:"药房名称"` AnnualReviewHide *int `json:"-" form:"-"` // 内部传递条件 } diff --git a/api/service/export.go b/api/service/export.go index eccc6bb..48e63e6 100644 --- a/api/service/export.go +++ b/api/service/export.go @@ -283,6 +283,8 @@ type OrderProductData struct { City string // 城市 County string // 区县 Address string // 详细地址 + PharmacyName string // 发货药房 + PharmacyCode string // 药房代码 } // OrderProductItemData 药品订单-药品列表 @@ -346,6 +348,8 @@ type OrderPrescriptionData struct { PatientMobile string // 患者电话 DoctorAdvice string // 医嘱 OrderPrescriptionIcd string // 处方诊断疾病 + PharmacyName string // 开方药房 + PharmacyCode string // 药房代码 CreatedAt string // 创建时间 } @@ -1497,6 +1501,8 @@ func (r *ExportService) OrderInquiry(d []*model.OrderInquiry) (string, error) { func (r *ExportService) OrderProduct(d []*model.OrderProduct) (string, error) { header := []utils.HeaderCellData{ {Value: "系统订单编号", CellType: "string", NumberFmt: "", ColWidth: 25, Colour: "#FFD700"}, + {Value: "发货药房", CellType: "string", NumberFmt: "", ColWidth: 25, Colour: "#FFD700"}, + {Value: "药房代码", CellType: "string", NumberFmt: "", ColWidth: 18, Colour: "#FFD700"}, {Value: "订单状态", CellType: "string", NumberFmt: "", ColWidth: 18, Colour: "#FFD700"}, {Value: "订单金额", CellType: "float64", NumberFmt: "0.0000", ColWidth: 18, Colour: "#FFD700"}, {Value: "优惠卷总金额", CellType: "float64", NumberFmt: "0.0000", ColWidth: 18, Colour: "#FFD700"}, @@ -1545,9 +1551,22 @@ func (r *ExportService) OrderProduct(d []*model.OrderProduct) (string, error) { var dataSlice []interface{} for _, v := range d { + pharmacyName := v.PharmacyName + pharmacyCode := v.PharmacyCode + if v.Pharmacy != nil { + if pharmacyName == "" { + pharmacyName = v.Pharmacy.PharmacyName + } + if pharmacyCode == "" { + pharmacyCode = v.Pharmacy.PharmacyCode + } + } + data := OrderProductData{ OrderProductNo: v.OrderProductNo, EscrowTradeNo: v.EscrowTradeNo, + PharmacyName: pharmacyName, + PharmacyCode: pharmacyCode, OrderProductStatus: utils.OrderProductStatusToString(v.OrderProductStatus), PayChannel: utils.PayChannelToString(v.PayChannel), PayStatus: utils.PayStatusToString(v.PayStatus), @@ -1789,6 +1808,8 @@ func (r *ExportService) OrderServicePackage(d []*model.OrderServicePackage) (str // OrderPrescription 处方 func (r *ExportService) OrderPrescription(d []*model.OrderPrescription) (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}, @@ -1815,7 +1836,20 @@ func (r *ExportService) OrderPrescription(d []*model.OrderPrescription) (string, var dataSlice []interface{} for _, v := range d { + pharmacyName := v.PharmacyName + pharmacyCode := v.PharmacyCode + if v.Pharmacy != nil { + if pharmacyName == "" { + pharmacyName = v.Pharmacy.PharmacyName + } + if pharmacyCode == "" { + pharmacyCode = v.Pharmacy.PharmacyCode + } + } + data := OrderPrescriptionData{ + PharmacyName: pharmacyName, + PharmacyCode: pharmacyCode, PrescriptionStatus: utils.PrescriptionStatusToString(v.PrescriptionStatus), PharmacistAuditStatus: utils.PharmacistAuditStatusToString(v.PharmacistAuditStatus), PharmacistFailReason: v.PharmacistFailReason, diff --git a/api/service/order.go b/api/service/order.go index 8f96b21..23bdfd9 100644 --- a/api/service/order.go +++ b/api/service/order.go @@ -247,9 +247,15 @@ func (r *OrderService) ReportPreProduct(orderProductId, adminUserId int64) (bool presRequests[0] = presRequest + // 终端代码:优先使用订单关联药房的代码,未配置则使用全局配置 + terminalCode := config.C.Pre.PrePlatTerminalCode + if orderProduct.PharmacyCode != "" { + terminalCode = orderProduct.PharmacyCode + } + // 处理上传数据-基础数据 ReportPreRequest := prescription.ReportPreRequest{ - TerminalCode: config.C.Pre.PrePlatTerminalCode, + TerminalCode: terminalCode, OrderNo: orderProduct.OrderProductNo, // 订单编号 TransactNo: orderProduct.EscrowTradeNo, // 流水单号 PayDate: time.Time(orderProduct.PayTime).Format("2006-01-02 15:04:05"), // 支付时间