获取药品订单列表-分页,新增了 药品数据名称

This commit is contained in:
wucongxing8150 2024-05-21 14:15:38 +08:00
parent deb9a25f97
commit f1588a096e
4 changed files with 77 additions and 48 deletions

View File

@ -92,6 +92,9 @@ func (r *OrderProductDao) GetOrderProductPageSearch(req requests.GetOrderProduct
// 构建查询条件 // 构建查询条件
query := global.Db.Model(&model.OrderProduct{}) query := global.Db.Model(&model.OrderProduct{})
// 药品数据
query = query.Preload("OrderProductItem")
// 医生 // 医生
query = query.Preload("UserDoctor", func(db *gorm.DB) *gorm.DB { query = query.Preload("UserDoctor", func(db *gorm.DB) *gorm.DB {
return db.Omit("open_id", "union_id", "wx_session_key") return db.Omit("open_id", "union_id", "wx_session_key")

View File

@ -3,6 +3,7 @@ package dto
import ( import (
"fmt" "fmt"
"hospital-admin-api/api/model" "hospital-admin-api/api/model"
"strings"
) )
// OrderProductDto 订单详情 // OrderProductDto 订单详情
@ -58,6 +59,7 @@ type OrderProductDto struct {
OrderPrescription *OrderPrescriptionDto `json:"order_prescription"` // 处方数据 OrderPrescription *OrderPrescriptionDto `json:"order_prescription"` // 处方数据
OrderInquiryCase *OrderInquiryCaseDto `json:"order_inquiry_case"` // 问诊病例 OrderInquiryCase *OrderInquiryCaseDto `json:"order_inquiry_case"` // 问诊病例
OrderProductCoupon *OrderProductCouponDto `json:"order_product_coupon"` // 优惠卷 OrderProductCoupon *OrderProductCouponDto `json:"order_product_coupon"` // 优惠卷
ProductName string `json:"product_name"` // 药品数据
} }
// OrderProductConsigneeDto 药品订单收货人数据 // OrderProductConsigneeDto 药品订单收货人数据
@ -115,8 +117,8 @@ func GetOrderProductDto(m *model.OrderProduct) *OrderProductDto {
} }
} }
// GetOrderProductConsigneeDtoDto 药品订单收货人数据 // GetOrderProductConsigneeDto 药品订单收货人数据
func GetOrderProductConsigneeDtoDto(m *model.OrderProduct) *OrderProductConsigneeDto { func GetOrderProductConsigneeDto(m *model.OrderProduct) *OrderProductConsigneeDto {
return &OrderProductConsigneeDto{ return &OrderProductConsigneeDto{
ProvinceId: m.ProvinceId, ProvinceId: m.ProvinceId,
Province: m.Province, Province: m.Province,
@ -181,6 +183,11 @@ func GetOrderProductListDto(m []*model.OrderProduct) []*OrderProductDto {
response = response.LoadOrderPrescriptionCode(v.OrderPrescription) response = response.LoadOrderPrescriptionCode(v.OrderPrescription)
} }
// 加载药品数据
if v.OrderProductItem != nil {
response = response.LoadProductName(v.OrderProductItem)
}
// 将转换后的结构体添加到新切片中 // 将转换后的结构体添加到新切片中
responses[i] = response responses[i] = response
} }
@ -274,3 +281,21 @@ func (r *OrderProductDto) LoadOrderProductCoupon(m *model.OrderProductCoupon) *O
} }
return r return r
} }
// LoadProductName 加载药品数据
func (r *OrderProductDto) LoadProductName(m []*model.OrderProductItem) *OrderProductDto {
if len(m) > 0 {
var products []string
for _, item := range m {
amount := fmt.Sprintf("%d", item.Amount)
productPrice := fmt.Sprintf("%.2f", item.ProductPrice)
product := item.ProductName + "(N:" + amount + " " + "P:" + productPrice + ")"
products = append(products, product)
r.ProductName = strings.Join(products, "; ")
}
}
return r
}

View File

@ -8,51 +8,52 @@ import (
// OrderProduct 订单-商品订单表 // OrderProduct 订单-商品订单表
type OrderProduct struct { type OrderProduct struct {
OrderProductId int64 `gorm:"column:order_product_id;type:bigint(20);primary_key;comment:主键id" json:"order_product_id"` OrderProductId int64 `gorm:"column:order_product_id;type:bigint(20);primary_key;comment:主键id" json:"order_product_id"`
OrderInquiryId int64 `gorm:"column:order_inquiry_id;type:bigint(19);comment:订单-问诊id;NOT NULL" json:"order_inquiry_id"` OrderInquiryId int64 `gorm:"column:order_inquiry_id;type:bigint(19);comment:订单-问诊id;NOT NULL" json:"order_inquiry_id"`
OrderPrescriptionId int64 `gorm:"column:order_prescription_id;type:bigint(19);comment:订单-处方id;NOT NULL" json:"order_prescription_id"` OrderPrescriptionId int64 `gorm:"column:order_prescription_id;type:bigint(19);comment:订单-处方id;NOT NULL" json:"order_prescription_id"`
OrderId int64 `gorm:"column:order_id;type:bigint(19);comment:订单id" json:"order_id"` OrderId int64 `gorm:"column:order_id;type:bigint(19);comment:订单id" json:"order_id"`
DoctorId int64 `gorm:"column:doctor_id;type:bigint(19);comment:医生id" json:"doctor_id"` DoctorId int64 `gorm:"column:doctor_id;type:bigint(19);comment:医生id" json:"doctor_id"`
PatientId int64 `gorm:"column:patient_id;type:bigint(19);comment:患者id" json:"patient_id"` PatientId int64 `gorm:"column:patient_id;type:bigint(19);comment:患者id" json:"patient_id"`
FamilyId int64 `gorm:"column:family_id;type:bigint(19);comment:家庭成员id就诊用户" json:"family_id"` FamilyId int64 `gorm:"column:family_id;type:bigint(19);comment:家庭成员id就诊用户" json:"family_id"`
OrderProductNo string `gorm:"column:order_product_no;type:varchar(100);comment:订单编号" json:"order_product_no"` OrderProductNo string `gorm:"column:order_product_no;type:varchar(100);comment:订单编号" json:"order_product_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"`
OrderProductStatus int `gorm:"column:order_product_status;type:tinyint(1);comment:订单状态1:待支付 2:待发货 3:已发货 4:已签收 5:已取消)" json:"order_product_status"` OrderProductStatus int `gorm:"column:order_product_status;type:tinyint(1);comment:订单状态1:待支付 2:待发货 3:已发货 4:已签收 5:已取消)" json:"order_product_status"`
PayChannel int `gorm:"column:pay_channel;type:tinyint(1);comment:支付渠道1:小程序支付 2:微信扫码支付);NOT NULL" json:"pay_channel"` PayChannel int `gorm:"column:pay_channel;type:tinyint(1);comment:支付渠道1:小程序支付 2:微信扫码支付);NOT NULL" json:"pay_channel"`
PayStatus int `gorm:"column:pay_status;type:tinyint(4);default:1;comment:支付状态1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)" json:"pay_status"` PayStatus int `gorm:"column:pay_status;type:tinyint(4);default:1;comment:支付状态1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)" json:"pay_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"`
CancelReason int `gorm:"column:cancel_reason;type:tinyint(1);comment:订单取消原因1:主动取消 2:复核失败/库存不足 3:支付超时 4:客服取消)" json:"cancel_reason"` CancelReason int `gorm:"column:cancel_reason;type:tinyint(1);comment:订单取消原因1:主动取消 2:复核失败/库存不足 3:支付超时 4:客服取消)" json:"cancel_reason"`
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"`
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"`
LogisticsFee float64 `gorm:"column:logistics_fee;type:decimal(10,2);default:0.00;comment:运费金额" json:"logistics_fee"` LogisticsFee float64 `gorm:"column:logistics_fee;type:decimal(10,2);default:0.00;comment:运费金额" json:"logistics_fee"`
LogisticsNo string `gorm:"column:logistics_no;type:varchar(100);comment:物流编号" json:"logistics_no"` LogisticsNo string `gorm:"column:logistics_no;type:varchar(100);comment:物流编号" json:"logistics_no"`
LogisticsCompanyCode string `gorm:"column:logistics_company_code;type:varchar(255);comment:快递公司编码" json:"logistics_company_code"` LogisticsCompanyCode string `gorm:"column:logistics_company_code;type:varchar(255);comment:快递公司编码" json:"logistics_company_code"`
SubLogisticsStatus int `gorm:"column:sub_logistics_status;type:tinyint(1);default:0;comment:快递推送订阅状态0:未订阅/无需订阅 1:已订阅 2:订阅失败)" json:"sub_logistics_status"` SubLogisticsStatus int `gorm:"column:sub_logistics_status;type:tinyint(1);default:0;comment:快递推送订阅状态0:未订阅/无需订阅 1:已订阅 2:订阅失败)" json:"sub_logistics_status"`
DeliveryTime LocalTime `gorm:"column:delivery_time;type:datetime;comment:发货时间" json:"delivery_time"` DeliveryTime LocalTime `gorm:"column:delivery_time;type:datetime;comment:发货时间" json:"delivery_time"`
PayTime LocalTime `gorm:"column:pay_time;type:datetime;comment:支付时间" json:"pay_time"` PayTime LocalTime `gorm:"column:pay_time;type:datetime;comment:支付时间" json:"pay_time"`
Remarks string `gorm:"column:remarks;type:varchar(255);comment:订单备注" json:"remarks"` Remarks string `gorm:"column:remarks;type:varchar(255);comment:订单备注" json:"remarks"`
RefundStatus int `gorm:"column:refund_status;type:tinyint(1);default:0;comment:商品订单退款状态0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常)" json:"refund_status"` RefundStatus int `gorm:"column:refund_status;type:tinyint(1);default:0;comment:商品订单退款状态0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常)" json:"refund_status"`
CancelTime LocalTime `gorm:"column:cancel_time;type:datetime;comment:订单取消时间" json:"cancel_time"` CancelTime LocalTime `gorm:"column:cancel_time;type:datetime;comment:订单取消时间" json:"cancel_time"`
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"`
ReportPreStatus int `gorm:"column:report_pre_status;type:tinyint(1);default:0;comment:上报处方平台状态0:未上报 1:已上报 2:上报失败))" json:"report_pre_status"` ReportPreStatus int `gorm:"column:report_pre_status;type:tinyint(1);default:0;comment:上报处方平台状态0:未上报 1:已上报 2:上报失败))" json:"report_pre_status"`
ReportPreTime LocalTime `gorm:"column:report_pre_time;type:datetime;comment:上报处方平台时间" json:"report_pre_time"` ReportPreTime LocalTime `gorm:"column:report_pre_time;type:datetime;comment:上报处方平台时间" json:"report_pre_time"`
ReportPreFailReason string `gorm:"column:report_pre_fail_reason;type:text;comment:上报失败原因" json:"report_pre_fail_reason"` ReportPreFailReason string `gorm:"column:report_pre_fail_reason;type:text;comment:上报失败原因" json:"report_pre_fail_reason"`
ProvinceId int `gorm:"column:province_id;type:int(11);comment:省份id" json:"province_id"` ProvinceId int `gorm:"column:province_id;type:int(11);comment:省份id" json:"province_id"`
Province string `gorm:"column:province;type:varchar(40);comment:省份" json:"province"` Province string `gorm:"column:province;type:varchar(40);comment:省份" json:"province"`
CityId int `gorm:"column:city_id;type:int(11);comment:城市id" json:"city_id"` CityId int `gorm:"column:city_id;type:int(11);comment:城市id" json:"city_id"`
City string `gorm:"column:city;type:varchar(50);comment:城市" json:"city"` City string `gorm:"column:city;type:varchar(50);comment:城市" json:"city"`
CountyId int `gorm:"column:county_id;type:int(11);comment:区县id" json:"county_id"` CountyId int `gorm:"column:county_id;type:int(11);comment:区县id" json:"county_id"`
County string `gorm:"column:county;type:varchar(255);comment:区县" json:"county"` County string `gorm:"column:county;type:varchar(255);comment:区县" json:"county"`
Address string `gorm:"column:address;type:varchar(255);comment:详细地址" json:"address"` Address string `gorm:"column:address;type:varchar(255);comment:详细地址" json:"address"`
AddressMask string `gorm:"column:address_mask;type:varchar(255);comment:详细地址(掩码)" json:"address_mask"` AddressMask string `gorm:"column:address_mask;type:varchar(255);comment:详细地址(掩码)" json:"address_mask"`
ConsigneeName string `gorm:"column:consignee_name;type:varchar(150);comment:收货人姓名" json:"consignee_name"` ConsigneeName string `gorm:"column:consignee_name;type:varchar(150);comment:收货人姓名" json:"consignee_name"`
ConsigneeNameMask string `gorm:"column:consignee_name_mask;type:varchar(150);comment:收货人姓名(掩码)" json:"consignee_name_mask"` 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"` 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"` ConsigneeTelMask string `gorm:"column:consignee_tel_mask;type:varchar(50);comment:收货人电话(掩码)" json:"consignee_tel_mask"`
UserDoctor *UserDoctor `gorm:"foreignKey:DoctorId;references:doctor_id" json:"user_doctor"` // 医生 UserDoctor *UserDoctor `gorm:"foreignKey:DoctorId;references:doctor_id" json:"user_doctor"` // 医生
OrderInquiry *OrderInquiry `gorm:"foreignKey:OrderInquiryId;references:order_inquiry_id" json:"order_inquiry"` // 问诊 OrderInquiry *OrderInquiry `gorm:"foreignKey:OrderInquiryId;references:order_inquiry_id" json:"order_inquiry"` // 问诊
UserPatient *UserPatient `gorm:"foreignKey:PatientId;references:patient_id" json:"user_patient"` // 患者 UserPatient *UserPatient `gorm:"foreignKey:PatientId;references:patient_id" json:"user_patient"` // 患者
OrderPrescription *OrderPrescription `gorm:"foreignKey:OrderPrescriptionId;references:order_prescription_id" json:"order_prescription"` // 处方 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"` // 处方
Model Model
} }

View File

@ -286,7 +286,7 @@ func (r *OrderProductService) GetOrderProductConsignee(orderProductId int64) (*d
} }
// 处理返回值 // 处理返回值
u := dto.GetOrderProductConsigneeDtoDto(orderProduct) u := dto.GetOrderProductConsigneeDto(orderProduct)
return u, nil return u, nil
} }