药品、处方列表关联药房信息

This commit is contained in:
haomingming
2026-09-07 16:25:04 +08:00
parent 5f2baaace7
commit 3205005b9a
10 changed files with 224 additions and 1 deletions
+38
View File
@@ -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,
}