新增药品订单详情
This commit is contained in:
parent
e82932ab53
commit
0a51e0fcbc
@ -6,8 +6,10 @@ import (
|
||||
"hospital-admin-api/api/requests"
|
||||
"hospital-admin-api/api/responses"
|
||||
"hospital-admin-api/api/responses/orderProductResponse"
|
||||
"hospital-admin-api/api/service"
|
||||
"hospital-admin-api/global"
|
||||
"hospital-admin-api/utils"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type OrderProduct struct{}
|
||||
@ -57,32 +59,32 @@ func (r *OrderProduct) GetOrderProductPage(c *gin.Context) {
|
||||
responses.OkWithData(result, c)
|
||||
}
|
||||
|
||||
// // GetOrderProduct 药品订单详情
|
||||
// func (r *OrderProduct) GetOrderProduct(c *gin.Context) {
|
||||
// id := c.Param("order_inquiry_id")
|
||||
// if id == "" {
|
||||
// responses.FailWithMessage("缺少参数", c)
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// // 将 id 转换为 int64 类型
|
||||
// orderInquiryId, err := strconv.ParseInt(id, 10, 64)
|
||||
// if err != nil {
|
||||
// responses.Fail(c)
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// // 业务处理
|
||||
// orderInquiryService := service.OrderProductService{}
|
||||
// getUserDoctorResponses, err := orderInquiryService.GetOrderProduct(orderInquiryId)
|
||||
// if err != nil {
|
||||
// responses.FailWithMessage(err.Error(), c)
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// responses.OkWithData(getUserDoctorResponses, c)
|
||||
// }
|
||||
//
|
||||
// GetOrderProduct 药品订单详情
|
||||
func (r *OrderProduct) GetOrderProduct(c *gin.Context) {
|
||||
id := c.Param("order_product_id")
|
||||
if id == "" {
|
||||
responses.FailWithMessage("缺少参数", c)
|
||||
return
|
||||
}
|
||||
|
||||
// 将 id 转换为 int64 类型
|
||||
orderProductId, err := strconv.ParseInt(id, 10, 64)
|
||||
if err != nil {
|
||||
responses.Fail(c)
|
||||
return
|
||||
}
|
||||
|
||||
// 业务处理
|
||||
orderProductService := service.OrderProductService{}
|
||||
getUserDoctorResponses, err := orderProductService.GetOrderProduct(orderProductId)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
responses.OkWithData(getUserDoctorResponses, c)
|
||||
}
|
||||
|
||||
// // CancelOrderProduct 取消药品订单
|
||||
// func (r *OrderProduct) CancelOrderProduct(c *gin.Context) {
|
||||
// id := c.Param("order_inquiry_id")
|
||||
|
||||
82
api/dao/orderProductItem.go
Normal file
82
api/dao/orderProductItem.go
Normal file
@ -0,0 +1,82 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/global"
|
||||
)
|
||||
|
||||
type OrderProductItemDao struct {
|
||||
}
|
||||
|
||||
// GetOrderProductItemById 获取商品订单列表数据-商品订单列表id
|
||||
func (r *OrderProductItemDao) GetOrderProductItemById(productItemId int64) (m *model.OrderProductItem, err error) {
|
||||
err = global.Db.First(&m, productItemId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetOrderProductItemPreloadById 获取商品订单列表数据-加载全部关联-商品订单列表id
|
||||
func (r *OrderProductItemDao) GetOrderProductItemPreloadById(productItemId int64) (m *model.OrderProductItem, err error) {
|
||||
err = global.Db.Preload(clause.Associations).First(&m, productItemId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetOrderProductItemByOrderProductId 获取商品订单列表数据-药品订单id
|
||||
func (r *OrderProductItemDao) GetOrderProductItemByOrderProductId(orderProductId int64) (m []*model.OrderProductItem, err error) {
|
||||
err = global.Db.Where("order_product_id = ?", orderProductId).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// DeleteOrderProductItem 删除商品订单列表
|
||||
func (r *OrderProductItemDao) DeleteOrderProductItem(tx *gorm.DB, maps interface{}) error {
|
||||
err := tx.Where(maps).Delete(&model.OrderProductItem{}).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditOrderProductItem 修改商品订单列表
|
||||
func (r *OrderProductItemDao) EditOrderProductItem(tx *gorm.DB, maps interface{}, data interface{}) error {
|
||||
err := tx.Model(&model.OrderProductItem{}).Where(maps).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditOrderProductItemById 修改商品订单列表-商品订单列表id
|
||||
func (r *OrderProductItemDao) EditOrderProductItemById(tx *gorm.DB, orderProductId int64, data interface{}) error {
|
||||
err := tx.Model(&model.OrderProductItem{}).Where("order_product_id = ?", orderProductId).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetOrderProductItemList 获取商品订单列表列表
|
||||
func (r *OrderProductItemDao) GetOrderProductItemList(maps interface{}) (m []*model.OrderProductItem, err error) {
|
||||
err = global.Db.Where(maps).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// AddOrderProductItem 新增商品订单列表
|
||||
func (r *OrderProductItemDao) AddOrderProductItem(tx *gorm.DB, model *model.OrderProductItem) (*model.OrderProductItem, error) {
|
||||
if err := tx.Create(model).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return model, nil
|
||||
}
|
||||
82
api/dao/orderProductLogistics.go
Normal file
82
api/dao/orderProductLogistics.go
Normal file
@ -0,0 +1,82 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/global"
|
||||
)
|
||||
|
||||
type OrderProductLogisticsDao struct {
|
||||
}
|
||||
|
||||
// GetOrderProductLogisticsById 获取药品订单物流数据-药品订单物流id
|
||||
func (r *OrderProductLogisticsDao) GetOrderProductLogisticsById(LogisticsId int64) (m *model.OrderProductLogistics, err error) {
|
||||
err = global.Db.First(&m, LogisticsId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetOrderProductLogisticsPreloadById 获取药品订单物流数据-加载全部关联-药品订单物流id
|
||||
func (r *OrderProductLogisticsDao) GetOrderProductLogisticsPreloadById(LogisticsId int64) (m *model.OrderProductLogistics, err error) {
|
||||
err = global.Db.Preload(clause.Associations).First(&m, LogisticsId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetOrderProductLogisticsByOrderProductId 获取药品订单物流数据-药品订单id
|
||||
func (r *OrderProductLogisticsDao) GetOrderProductLogisticsByOrderProductId(orderProductId int64) (m *model.OrderProductLogistics, err error) {
|
||||
err = global.Db.Where("order_product_id = ?", orderProductId).First(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// DeleteOrderProductLogistics 删除药品订单物流
|
||||
func (r *OrderProductLogisticsDao) DeleteOrderProductLogistics(tx *gorm.DB, maps interface{}) error {
|
||||
err := tx.Where(maps).Delete(&model.OrderProductLogistics{}).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditOrderProductLogistics 修改药品订单物流
|
||||
func (r *OrderProductLogisticsDao) EditOrderProductLogistics(tx *gorm.DB, maps interface{}, data interface{}) error {
|
||||
err := tx.Model(&model.OrderProductLogistics{}).Where(maps).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditOrderProductLogisticsById 修改药品订单物流-药品订单物流id
|
||||
func (r *OrderProductLogisticsDao) EditOrderProductLogisticsById(tx *gorm.DB, orderProductId int64, data interface{}) error {
|
||||
err := tx.Model(&model.OrderProductLogistics{}).Where("order_product_id = ?", orderProductId).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetOrderProductLogisticsList 获取药品订单物流列表
|
||||
func (r *OrderProductLogisticsDao) GetOrderProductLogisticsList(maps interface{}) (m []*model.OrderProductLogistics, err error) {
|
||||
err = global.Db.Where(maps).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// AddOrderProductLogistics 新增药品订单物流
|
||||
func (r *OrderProductLogisticsDao) AddOrderProductLogistics(tx *gorm.DB, model *model.OrderProductLogistics) (*model.OrderProductLogistics, error) {
|
||||
if err := tx.Create(model).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return model, nil
|
||||
}
|
||||
82
api/dao/orderProductRefund.go
Normal file
82
api/dao/orderProductRefund.go
Normal file
@ -0,0 +1,82 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/global"
|
||||
)
|
||||
|
||||
type OrderProductRefundDao struct {
|
||||
}
|
||||
|
||||
// GetOrderProductRefundById 获取药品退款订单数据-药品退款订单id
|
||||
func (r *OrderProductRefundDao) GetOrderProductRefundById(productRefundId int64) (m *model.OrderProductRefund, err error) {
|
||||
err = global.Db.First(&m, productRefundId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetOrderProductRefundPreloadById 获取药品退款订单数据-加载全部关联-药品退款订单id
|
||||
func (r *OrderProductRefundDao) GetOrderProductRefundPreloadById(productRefundId int64) (m *model.OrderProductRefund, err error) {
|
||||
err = global.Db.Preload(clause.Associations).First(&m, productRefundId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetOrderProductRefundByOrderProductId 获取药品退款订单数据-药品订单id
|
||||
func (r *OrderProductRefundDao) GetOrderProductRefundByOrderProductId(productRefundId int64) (m *model.OrderProductRefund, err error) {
|
||||
err = global.Db.Where("order_product_id = ?", productRefundId).First(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// DeleteOrderProductRefund 删除药品退款订单
|
||||
func (r *OrderProductRefundDao) DeleteOrderProductRefund(tx *gorm.DB, maps interface{}) error {
|
||||
err := tx.Where(maps).Delete(&model.OrderProductRefund{}).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditOrderProductRefund 修改药品退款订单
|
||||
func (r *OrderProductRefundDao) EditOrderProductRefund(tx *gorm.DB, maps interface{}, data interface{}) error {
|
||||
err := tx.Model(&model.OrderProductRefund{}).Where(maps).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditOrderProductRefundById 修改药品退款订单-药品退款订单id
|
||||
func (r *OrderProductRefundDao) EditOrderProductRefundById(tx *gorm.DB, productRefundId int64, data interface{}) error {
|
||||
err := tx.Model(&model.OrderProductRefund{}).Where("order_product_id = ?", productRefundId).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetOrderProductRefundList 获取药品退款订单列表
|
||||
func (r *OrderProductRefundDao) GetOrderProductRefundList(maps interface{}) (m []*model.OrderProductRefund, err error) {
|
||||
err = global.Db.Where(maps).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// AddOrderProductRefund 新增药品退款订单
|
||||
func (r *OrderProductRefundDao) AddOrderProductRefund(tx *gorm.DB, model *model.OrderProductRefund) (*model.OrderProductRefund, error) {
|
||||
if err := tx.Create(model).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return model, nil
|
||||
}
|
||||
@ -16,15 +16,15 @@ type OrderPrescription struct {
|
||||
PharmacistId int64 `gorm:"column:pharmacist_id;type:bigint(19);comment:药师id" json:"pharmacist_id"`
|
||||
PrescriptionStatus int `gorm:"column:prescription_status;type:tinyint(1);comment:处方状态(1:待审核 2:待使用 3:已失效 4:已使用)" json:"prescription_status"`
|
||||
PharmacistAuditStatus int `gorm:"column:pharmacist_audit_status;type:tinyint(1);default:0;comment:药师审核状态(0:审核中 1:审核成功 2:审核驳回)" json:"pharmacist_audit_status"`
|
||||
PharmacistVerifyTime time.Time `gorm:"column:pharmacist_verify_time;type:datetime;comment:药师审核时间" json:"pharmacist_verify_time"`
|
||||
PharmacistVerifyTime LocalTime `gorm:"column:pharmacist_verify_time;type:datetime;comment:药师审核时间" json:"pharmacist_verify_time"`
|
||||
PharmacistFailReason string `gorm:"column:pharmacist_fail_reason;type:varchar(255);comment:药师审核驳回原因" json:"pharmacist_fail_reason"`
|
||||
PlatformAuditStatus int `gorm:"column:platform_audit_status;type:tinyint(1);default:0;comment:处方平台审核状态(0:审核中 1:审核成功 2:审核驳回)" json:"platform_audit_status"`
|
||||
PlatformFailTime time.Time `gorm:"column:platform_fail_time;type:datetime;comment:平台审核失败时间" json:"platform_fail_time"`
|
||||
PlatformFailTime LocalTime `gorm:"column:platform_fail_time;type:datetime;comment:平台审核失败时间" json:"platform_fail_time"`
|
||||
PlatformFailReason string `gorm:"column:platform_fail_reason;type:varchar(255);comment:处方平台驳回原因" json:"platform_fail_reason"`
|
||||
IsAutoPharVerify int `gorm:"column:is_auto_phar_verify;type:tinyint(1);default:0;comment:是否药师自动审核(0:否 1:是)" json:"is_auto_phar_verify"`
|
||||
DoctorCreatedTime time.Time `gorm:"column:doctor_created_time;type:datetime;comment:医生开具处方时间" json:"doctor_created_time"`
|
||||
ExpiredTime time.Time `gorm:"column:expired_time;type:datetime;comment:处方过期时间" json:"expired_time"`
|
||||
VoidTime time.Time `gorm:"column:void_time;type:datetime;comment:处方作废时间" json:"void_time"`
|
||||
DoctorCreatedTime LocalTime `gorm:"column:doctor_created_time;type:datetime;comment:医生开具处方时间" json:"doctor_created_time"`
|
||||
ExpiredTime LocalTime `gorm:"column:expired_time;type:datetime;comment:处方过期时间" json:"expired_time"`
|
||||
VoidTime LocalTime `gorm:"column:void_time;type:datetime;comment:处方作废时间" json:"void_time"`
|
||||
IsDelete int `gorm:"column:is_delete;type:tinyint(1);default:0;comment:是否删除(0:否 1:是)" json:"is_delete"`
|
||||
PrescriptionCode string `gorm:"column:prescription_code;type:varchar(255);comment:处方编号" json:"prescription_code"`
|
||||
DoctorName string `gorm:"column:doctor_name;type:varchar(100);comment:医生名称" json:"doctor_name"`
|
||||
|
||||
42
api/model/orderProductItem.go
Normal file
42
api/model/orderProductItem.go
Normal file
@ -0,0 +1,42 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// OrderProductItem 订单-商品订单列表
|
||||
type OrderProductItem struct {
|
||||
ProductItemId int64 `gorm:"column:product_item_id;type:bigint(19);primary_key;comment:主键id" json:"product_item_id"`
|
||||
OrderProductId int64 `gorm:"column:order_product_id;type:bigint(19);comment:订单-商品订单id" json:"order_product_id"`
|
||||
OrderInquiryId int64 `gorm:"column:order_inquiry_id;type:bigint(19);comment:订单-问诊id" json:"order_inquiry_id"`
|
||||
OrderPrescriptionId int64 `gorm:"column:order_prescription_id;type:bigint(19);comment:订单-处方id" json:"order_prescription_id"`
|
||||
ProductId int64 `gorm:"column:product_id;type:bigint(19);comment:商品id" json:"product_id"`
|
||||
ProductName string `gorm:"column:product_name;type:varchar(255);comment:商品名称" json:"product_name"`
|
||||
ProductPrice float64 `gorm:"column:product_price;type:decimal(10,2);comment:商品价格" json:"product_price"`
|
||||
ProductPlatformCode string `gorm:"column:product_platform_code;type:varchar(100);comment:商品处方平台编码" json:"product_platform_code"`
|
||||
Amount int `gorm:"column:amount;type:int(11);comment:数量" json:"amount"`
|
||||
Manufacturer string `gorm:"column:manufacturer;type:varchar(255);comment:生产厂家" json:"manufacturer"`
|
||||
ProductCoverImg string `gorm:"column:product_cover_img;type:varchar(255);comment:商品封面图" json:"product_cover_img"`
|
||||
ProductSpec string `gorm:"column:product_spec;type:varchar(255);comment:商品规格" json:"product_spec"`
|
||||
Model
|
||||
}
|
||||
|
||||
func (m *OrderProductItem) TableName() string {
|
||||
return "gdxz_order_product_item"
|
||||
}
|
||||
|
||||
func (m *OrderProductItem) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.ProductItemId == 0 {
|
||||
m.ProductItemId = global.Snowflake.Generate().Int64()
|
||||
}
|
||||
|
||||
m.CreatedAt = LocalTime(time.Now())
|
||||
tx.Statement.SetColumn("CreatedAt", m.CreatedAt)
|
||||
|
||||
m.UpdatedAt = LocalTime(time.Now())
|
||||
tx.Statement.SetColumn("UpdatedAt", m.UpdatedAt)
|
||||
|
||||
return nil
|
||||
}
|
||||
37
api/model/orderProductLogistics.go
Normal file
37
api/model/orderProductLogistics.go
Normal file
@ -0,0 +1,37 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// OrderProductLogistics 商品订单-物流数据
|
||||
type OrderProductLogistics struct {
|
||||
LogisticsId int64 `gorm:"column:logistics_id;type:bigint(19);primary_key;comment:主键id" json:"logistics_id"`
|
||||
OrderProductId int64 `gorm:"column:order_product_id;type:bigint(19);comment:药品订单id;NOT NULL" json:"order_product_id"`
|
||||
LogisticsStatus int `gorm:"column:logistics_status;type:tinyint(1);comment:运单签收状态(0在途 1揽收 2疑难 3签收 4退签 5派件 8清关 14拒签);NOT NULL" json:"logistics_status"`
|
||||
LogisticsNo string `gorm:"column:logistics_no;type:varchar(255);comment:物流编号" json:"logistics_no"`
|
||||
CompanyName string `gorm:"column:company_name;type:varchar(255);comment:快递公司名称" json:"company_name"`
|
||||
CompanyCode string `gorm:"column:company_code;type:varchar(255);comment:快递公司编码" json:"company_code"`
|
||||
LogisticsContent string `gorm:"column:logistics_content;type:text;comment:内容" json:"logistics_content"`
|
||||
Model
|
||||
}
|
||||
|
||||
func (m *OrderProductLogistics) TableName() string {
|
||||
return "gdxz_order_product_logistics"
|
||||
}
|
||||
|
||||
func (m *OrderProductLogistics) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.LogisticsId == 0 {
|
||||
m.LogisticsId = global.Snowflake.Generate().Int64()
|
||||
}
|
||||
|
||||
m.CreatedAt = LocalTime(time.Now())
|
||||
tx.Statement.SetColumn("CreatedAt", m.CreatedAt)
|
||||
|
||||
m.UpdatedAt = LocalTime(time.Now())
|
||||
tx.Statement.SetColumn("UpdatedAt", m.UpdatedAt)
|
||||
|
||||
return nil
|
||||
}
|
||||
40
api/model/orderProductRefund.go
Normal file
40
api/model/orderProductRefund.go
Normal file
@ -0,0 +1,40 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// OrderProductRefund 订单-药品-退款表
|
||||
type OrderProductRefund struct {
|
||||
ProductRefundId int64 `gorm:"column:product_refund_id;type:bigint(19);primary_key;comment:主键id" json:"product_refund_id"`
|
||||
PatientId int64 `gorm:"column:patient_id;type:bigint(19);comment:患者id" json:"patient_id"`
|
||||
OrderProductId int64 `gorm:"column:order_product_id;type:bigint(19);comment:订单-药品订单id" json:"order_product_id"`
|
||||
OrderProductNo string `gorm:"column:order_product_no;type:varchar(100);comment:系统订单编号" json:"order_product_no"`
|
||||
ProductRefundNo string `gorm:"column:product_refund_no;type:varchar(50);comment:系统退款编号" json:"product_refund_no"`
|
||||
RefundId string `gorm:"column:refund_id;type:varchar(50);comment:第三方退款单号" json:"refund_id"`
|
||||
ProductRefundStatus int `gorm:"column:product_refund_status;type:tinyint(4);comment:商品订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常)" json:"product_refund_status"`
|
||||
RefundTotal float64 `gorm:"column:refund_total;type:decimal(10,2);comment:退款金额" json:"refund_total"`
|
||||
RefundReason string `gorm:"column:refund_reason;type:varchar(255);comment:退款原因" json:"refund_reason"`
|
||||
SuccessTime LocalTime `gorm:"column:success_time;type:datetime;comment:退款成功时间" json:"success_time"`
|
||||
Model
|
||||
}
|
||||
|
||||
func (m *OrderProductRefund) TableName() string {
|
||||
return "gdxz_order_product_refund"
|
||||
}
|
||||
|
||||
func (m *OrderProductRefund) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.ProductRefundId == 0 {
|
||||
m.ProductRefundId = global.Snowflake.Generate().Int64()
|
||||
}
|
||||
|
||||
m.CreatedAt = LocalTime(time.Now())
|
||||
tx.Statement.SetColumn("CreatedAt", m.CreatedAt)
|
||||
|
||||
m.UpdatedAt = LocalTime(time.Now())
|
||||
tx.Statement.SetColumn("UpdatedAt", m.UpdatedAt)
|
||||
|
||||
return nil
|
||||
}
|
||||
34
api/responses/orderPrescriptionResponse/orderPrescription.go
Normal file
34
api/responses/orderPrescriptionResponse/orderPrescription.go
Normal file
@ -0,0 +1,34 @@
|
||||
package orderPrescriptionResponse
|
||||
|
||||
import (
|
||||
"hospital-admin-api/api/model"
|
||||
)
|
||||
|
||||
type OrderPrescription struct {
|
||||
OrderPrescriptionId string `json:"order_prescription_id"` // 主键id
|
||||
OrderInquiryId string `json:"order_inquiry_id"` // 订单-问诊id;NOT NULL
|
||||
DoctorId string `json:"doctor_id"` // 医生id;NOT NULL
|
||||
PatientId string `json:"patient_id"` // 患者id
|
||||
FamilyId string `json:"family_id"` // 家庭成员id(就诊用户)
|
||||
PharmacistId string `json:"pharmacist_id"` // 药师id
|
||||
PrescriptionStatus int `json:"prescription_status"` // 处方状态(1:待审核 2:待使用 3:已失效 4:已使用)
|
||||
PharmacistAuditStatus int `json:"pharmacist_audit_status"` // 药师审核状态(0:审核中 1:审核成功 2:审核驳回)
|
||||
PharmacistVerifyTime model.LocalTime `json:"pharmacist_verify_time"` // 药师审核时间
|
||||
PharmacistFailReason string `json:"pharmacist_fail_reason"` // 药师审核驳回原因
|
||||
PlatformAuditStatus int `json:"platform_audit_status"` // 处方平台审核状态(0:审核中 1:审核成功 2:审核驳回)
|
||||
PlatformFailTime model.LocalTime `json:"platform_fail_time"` // 平台审核失败时间
|
||||
PlatformFailReason string `json:"platform_fail_reason"` // 处方平台驳回原因
|
||||
IsAutoPharVerify int `json:"is_auto_phar_verify"` // 是否药师自动审核(0:否 1:是)
|
||||
DoctorCreatedTime model.LocalTime `json:"doctor_created_time"` // 医生开具处方时间
|
||||
ExpiredTime model.LocalTime `json:"expired_time"` // 处方过期时间
|
||||
VoidTime model.LocalTime `json:"void_time"` // 处方作废时间
|
||||
IsDelete int `json:"is_delete"` // 是否删除(0:否 1:是)
|
||||
PrescriptionCode string `json:"prescription_code"` // 处方编号
|
||||
DoctorName string `json:"doctor_name"` // 医生名称
|
||||
PatientName string `json:"patient_name"` // 患者姓名-就诊人
|
||||
PatientSex int `json:"patient_sex"` // 患者性别-就诊人(1:男 2:女)
|
||||
PatientAge int `json:"patient_age"` // 患者年龄-就诊人
|
||||
DoctorAdvice string `json:"doctor_advice"` // 医嘱
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
|
||||
}
|
||||
57
api/responses/orderProductItemResponse/orderProductItem.go
Normal file
57
api/responses/orderProductItemResponse/orderProductItem.go
Normal file
@ -0,0 +1,57 @@
|
||||
package orderProductItemResponse
|
||||
|
||||
import (
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/utils"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type OrderProductItem struct {
|
||||
ProductItemId string `json:"product_item_id"` // 主键id
|
||||
OrderProductId string `json:"order_product_id"` // 订单-商品订单id
|
||||
OrderInquiryId string `json:"order_inquiry_id"` // 订单-问诊id
|
||||
OrderPrescriptionId string `json:"order_prescription_id"` // 订单-处方id
|
||||
ProductId string `json:"product_id"` // 商品id
|
||||
ProductName string `json:"product_name"` // 商品名称
|
||||
ProductPrice float64 `json:"product_price"` // 商品价格
|
||||
ProductPlatformCode string `json:"product_platform_code"` // 商品处方平台编码
|
||||
Amount int `json:"amount"` // 数量
|
||||
Manufacturer string `json:"manufacturer"` // 生产厂家
|
||||
ProductCoverImg string `json:"product_cover_img"` // 商品封面图
|
||||
ProductSpec string `json:"product_spec"` // 商品规格
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
|
||||
}
|
||||
|
||||
// GetOrderProductItemListResponse 获取订单商品列表
|
||||
func GetOrderProductItemListResponse(u []*model.OrderProductItem) []*OrderProductItem {
|
||||
// 处理返回值
|
||||
orderProductItemResponses := make([]*OrderProductItem, len(u))
|
||||
|
||||
if len(u) > 0 {
|
||||
for i, v := range u {
|
||||
// 将原始结构体转换为新结构体
|
||||
orderProductItemResponse := &OrderProductItem{
|
||||
ProductItemId: strconv.Itoa(int(v.ProductItemId)),
|
||||
OrderProductId: strconv.Itoa(int(v.OrderProductId)),
|
||||
OrderInquiryId: strconv.Itoa(int(v.OrderInquiryId)),
|
||||
OrderPrescriptionId: strconv.Itoa(int(v.OrderPrescriptionId)),
|
||||
ProductId: strconv.Itoa(int(v.ProductId)),
|
||||
ProductName: v.ProductName,
|
||||
ProductPrice: v.ProductPrice,
|
||||
ProductPlatformCode: v.ProductPlatformCode,
|
||||
Amount: v.Amount,
|
||||
Manufacturer: v.Manufacturer,
|
||||
ProductCoverImg: utils.AddOssDomain(v.ProductCoverImg),
|
||||
ProductSpec: v.ProductSpec,
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
orderProductItemResponses[i] = orderProductItemResponse
|
||||
}
|
||||
}
|
||||
|
||||
return orderProductItemResponses
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package orderProductLogisticsResponse
|
||||
|
||||
import (
|
||||
"hospital-admin-api/api/model"
|
||||
)
|
||||
|
||||
type OrderProductLogistics struct {
|
||||
LogisticsId string `json:"logistics_id"` // 主键id
|
||||
OrderProductId string `json:"order_product_id"` // 药品订单id;NOT NULL
|
||||
LogisticsStatus int `json:"logistics_status"` // 运单签收状态(0在途 1揽收 2疑难 3签收 4退签 5派件 8清关 14拒签);NOT NULL
|
||||
LogisticsNo string `json:"logistics_no"` // 物流编号
|
||||
CompanyName string `json:"company_name"` // 快递公司名称
|
||||
CompanyCode string `json:"company_code"` // 快递公司编码
|
||||
LogisticsContent string `json:"logistics_content"` // 内容
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package orderProductRefundResponse
|
||||
|
||||
import (
|
||||
"hospital-admin-api/api/model"
|
||||
)
|
||||
|
||||
// OrderProductRefund 药品订单退款详情
|
||||
type OrderProductRefund struct {
|
||||
ProductRefundId string `json:"product_refund_id"` // 主键id
|
||||
PatientId string `json:"patient_id"` // 患者id
|
||||
OrderProductId string `json:"order_product_id"` // 订单-药品订单id
|
||||
OrderProductNo string `json:"order_product_no"` // 系统订单编号
|
||||
ProductRefundNo string `json:"product_refund_no"` // 系统退款编号
|
||||
RefundId string `json:"refund_id"` // 第三方退款单号
|
||||
ProductRefundStatus int `json:"product_refund_status"` // 商品订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常)
|
||||
RefundTotal float64 `json:"refund_total"` // 退款金额
|
||||
RefundReason string `json:"refund_reason"` // 退款原因
|
||||
SuccessTime model.LocalTime `json:"success_time"` // 退款成功时间
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
|
||||
}
|
||||
@ -3,6 +3,12 @@ package orderProductResponse
|
||||
import (
|
||||
"fmt"
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/api/responses/orderInquiryCaseResponse"
|
||||
"hospital-admin-api/api/responses/orderPrescriptionResponse"
|
||||
"hospital-admin-api/api/responses/orderProductItemResponse"
|
||||
"hospital-admin-api/api/responses/orderProductLogisticsResponse"
|
||||
"hospital-admin-api/api/responses/orderProductRefundResponse"
|
||||
"hospital-admin-api/api/responses/userDoctorResponse"
|
||||
)
|
||||
|
||||
// getOrderProductPage 获取医生列表-分页
|
||||
@ -39,48 +45,44 @@ type getOrderProductPage struct {
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||
}
|
||||
|
||||
// // GetOrderProduct 问诊订单详情
|
||||
// type GetOrderProduct struct {
|
||||
// OrderProductId string `json:"order_inquiry_id"` // 主键id
|
||||
// UserId string `json:"user_id"` // 用户id-患者
|
||||
// PatientId string `json:"patient_id"` // 患者id
|
||||
// DoctorId string `json:"doctor_id"` // 医生id(未分配时为null)
|
||||
// FamilyId string `json:"family_id"` // 家庭成员id(就诊用户)
|
||||
// InquiryType int `json:"inquiry_type"` // 订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药 5:检测)
|
||||
// InquiryMode int `json:"inquiry_mode"` // 订单问诊方式(1:图文 2:视频 3:语音 4:电话 5:会员)
|
||||
// InquiryStatus int `json:"inquiry_status"` // 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||
// IsDelete int `json:"is_delete"` // 删除状态(0:否 1:是)
|
||||
// InquiryRefundStatus int `json:"inquiry_refund_status"` // 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常)
|
||||
// InquiryPayChannel int `json:"inquiry_pay_channel"` // 支付渠道(1:小程序支付 2:微信扫码支付 3:模拟支付)
|
||||
// InquiryPayStatus int `json:"inquiry_pay_status"` // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||
// InquiryNo string `json:"inquiry_no"` // 系统订单编号
|
||||
// EscrowTradeNo string `json:"escrow_trade_no"` // 第三方支付流水号
|
||||
// AmountTotal float64 `json:"amount_total"` // 订单金额
|
||||
// CouponAmountTotal float64 `json:"coupon_amount_total"` // 优惠卷总金额
|
||||
// PaymentAmountTotal float64 `json:"payment_amount_total"` // 实际付款金额
|
||||
// PayTime model.LocalTime `json:"pay_time"` // 支付时间
|
||||
// ReceptionTime model.LocalTime `json:"reception_time"` // 接诊时间(已接诊)
|
||||
// CompleteTime model.LocalTime `json:"complete_time"` // 订单完成时间(问诊完成时间)
|
||||
// FinishTime model.LocalTime `json:"finish_time"` // 订单结束时间
|
||||
// StatisticsStatus int `json:"statistics_status"` // 订单统计状态(0:未统计 1:已统计 2:统计失败)
|
||||
// StatisticsTime model.LocalTime `json:"statistics_time"` // 订单统计时间
|
||||
// IsWithdrawal int `json:"is_withdrawal"` // 是否提现(0:否 1:是 2:提现中)
|
||||
// WithdrawalTime model.LocalTime `json:"withdrawal_time"` // 提现时间
|
||||
// CancelTime model.LocalTime `json:"cancel_time"` // 订单取消时间
|
||||
// CancelReason int `json:"cancel_reason"` // 取消订单原因(1:医生未接诊 2:主动取消 3:无可分配医生 4:客服取消 5:支付超时)
|
||||
// CancelRemarks string `json:"cancel_remarks"` // 取消订单备注(自动添加)
|
||||
// PatientName string `json:"patient_name"` // 患者姓名-就诊人
|
||||
// PatientNameMask string `json:"patient_name_mask"` // 患者姓名-就诊人(掩码)
|
||||
// PatientSex int `json:"patient_sex"` // 患者性别-就诊人(0:未知 1:男 2:女)
|
||||
// PatientAge int `json:"patient_age"` // 患者年龄-就诊人
|
||||
// OrderProductCoupon *orderInquiryCouponResponse.OrderProductCoupon `json:"order_inquiry_coupon"` // 订单优惠卷
|
||||
// OrderProductCase *orderInquiryCaseResponse.OrderProductCase `json:"order_inquiry_case"` // 问诊病例
|
||||
// OrderProductRefund *orderInquiryRefundResponse.OrderProductRefund `json:"order_inquiry_refund"` // 退款数据
|
||||
// OrderEvaluation *orderEvaluationResponse.OrderEvaluation `json:"order_evaluation"` // 订单评价
|
||||
// UserDoctor *userDoctorResponse.OrderProductUserDoctor `json:"user_doctor"` // 医生数据
|
||||
// CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
// UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||
// }
|
||||
// GetOrderProduct 问诊订单详情
|
||||
type GetOrderProduct struct {
|
||||
OrderProductId string `json:"order_product_id"` // 主键id
|
||||
OrderInquiryId string `json:"order_inquiry_id"` // 订单-问诊id;NOT NULL
|
||||
OrderPrescriptionId string `json:"order_prescription_id"` // 订单-处方id;NOT NULL
|
||||
DoctorId string `json:"doctor_id"` // 医生id
|
||||
PatientId string `json:"patient_id"` // 患者id
|
||||
FamilyId string `json:"family_id"` // 家庭成员id(就诊用户)
|
||||
OrderProductNo string `json:"order_product_no"` // 订单编号
|
||||
EscrowTradeNo string `json:"escrow_trade_no"` // 第三方支付流水号
|
||||
OrderProductStatus int `json:"order_product_status"` // 订单状态(1:待支付 2:待发货 3:已发货 4:已签收 5:已取消)
|
||||
PayChannel int `json:"pay_channel"` // 支付渠道(1:小程序支付 2:微信扫码支付);NOT NULL
|
||||
PayStatus int `json:"pay_status"` // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||
CancelReason int `json:"cancel_reason"` // 订单取消原因(1:主动取消 2:复核失败/库存不足 3:支付超时 4:客服取消)
|
||||
AmountTotal float64 `json:"amount_total"` // 订单金额
|
||||
PaymentAmountTotal float64 `json:"payment_amount_total"` // 实际付款金额
|
||||
LogisticsFee float64 `json:"logistics_fee"` // 运费金额
|
||||
LogisticsNo string `json:"logistics_no"` // 物流编号
|
||||
LogisticsCompanyCode string `json:"logistics_company_code"` // 快递公司编码
|
||||
DeliveryTime model.LocalTime `json:"delivery_time"` // 发货时间
|
||||
PayTime model.LocalTime `json:"pay_time"` // 支付时间
|
||||
Remarks string `json:"remarks"` // 订单备注
|
||||
RefundStatus int `json:"refund_status"` // 商品订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常)
|
||||
ReportPreStatus int `json:"report_pre_status"` // 上报处方平台状态(0:未上报 1:已上报 2:上报失败))
|
||||
ConsigneeNameMask string `json:"consignee_name_mask"` // 收货人姓名(掩码)
|
||||
ConsigneeTelMask string `json:"consignee_tel_mask"` // 收货人电话(掩码)
|
||||
PatientNameMask string `json:"patient_name_mask"` // 患者姓名-就诊人(掩码)
|
||||
PatientSex int `json:"patient_sex"` // 患者性别-就诊人(0:未知 1:男 2:女)
|
||||
PatientAge int `json:"patient_age"` // 患者年龄-就诊人
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||
OrderProductRefund *orderProductRefundResponse.OrderProductRefund `json:"order_product_refund"` // 退款数据
|
||||
OrderProductItem []*orderProductItemResponse.OrderProductItem `json:"order_product_item"` // 商品数据
|
||||
OrderProductLogistics *orderProductLogisticsResponse.OrderProductLogistics `json:"order_product_logistics"` // 物流数据
|
||||
UserDoctor *userDoctorResponse.OrderInquiryUserDoctor `json:"user_doctor"` // 医生数据
|
||||
OrderPrescription *orderPrescriptionResponse.OrderPrescription `json:"order_prescription"` // 处方数据
|
||||
OrderInquiryCase *orderInquiryCaseResponse.OrderInquiryCase `json:"order_inquiry_case"` // 问诊病例
|
||||
}
|
||||
|
||||
// GetOrderProductPageResponse 获取药品订单列表-分页
|
||||
func GetOrderProductPageResponse(orderProduct []*model.OrderProduct) []getOrderProductPage {
|
||||
|
||||
@ -378,7 +378,7 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
||||
productGroup.GET("", api.OrderProduct.GetOrderProductPage)
|
||||
|
||||
// 药品订单详情
|
||||
productGroup.GET("/:order_inquiry_id", api.OrderProduct.GetOrderProductPage)
|
||||
productGroup.GET("/:order_product_id", api.OrderProduct.GetOrderProduct)
|
||||
|
||||
// 取消药品订单
|
||||
productGroup.PUT("/:order_inquiry_id", api.OrderProduct.GetOrderProductPage)
|
||||
|
||||
@ -7,7 +7,6 @@ import (
|
||||
"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"
|
||||
@ -271,7 +270,8 @@ func (r *OrderInquiryService) GetOrderInquiry(orderInquiryId int64) (getOrderInq
|
||||
}
|
||||
|
||||
// 获取问诊病例
|
||||
orderInquiryCase, err := r.GetOrderInquiryCase(orderInquiryId)
|
||||
orderInquiryCaseService := OrderInquiryCaseService{}
|
||||
orderInquiryCase, err := orderInquiryCaseService.GetOrderInquiryCaseByOrderInquiryId(orderInquiryId)
|
||||
if err != nil {
|
||||
return nil, errors.New(err.Error())
|
||||
}
|
||||
@ -368,46 +368,6 @@ func (r *OrderInquiryService) GetOrderInquiryCoupon(orderInquiryId int64) (u *or
|
||||
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{}
|
||||
|
||||
51
api/service/orderInquiryCase.go
Normal file
51
api/service/orderInquiryCase.go
Normal file
@ -0,0 +1,51 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"hospital-admin-api/api/dao"
|
||||
"hospital-admin-api/api/responses/orderInquiryCaseResponse"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type OrderInquiryCaseService struct {
|
||||
}
|
||||
|
||||
// GetOrderInquiryCaseByOrderInquiryId 获取问诊订单病例-问诊订单
|
||||
func (r *OrderInquiryCaseService) GetOrderInquiryCaseByOrderInquiryId(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
|
||||
}
|
||||
50
api/service/orderPrescription.go
Normal file
50
api/service/orderPrescription.go
Normal file
@ -0,0 +1,50 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hospital-admin-api/api/dao"
|
||||
"hospital-admin-api/api/responses/orderPrescriptionResponse"
|
||||
)
|
||||
|
||||
// OrderPrescriptionService 处方
|
||||
type OrderPrescriptionService struct {
|
||||
}
|
||||
|
||||
// GetOrderPrescriptionById 获取处方数据
|
||||
func (r *OrderPrescriptionService) GetOrderPrescriptionById(OrderPrescriptionId int64) (u *orderPrescriptionResponse.OrderPrescription, err error) {
|
||||
orderPrescriptionDao := dao.OrderPrescriptionDao{}
|
||||
orderPrescription, err := orderPrescriptionDao.GetById(OrderPrescriptionId)
|
||||
if orderPrescription == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
u = &orderPrescriptionResponse.OrderPrescription{
|
||||
OrderPrescriptionId: fmt.Sprintf("%d", orderPrescription.OrderPrescriptionId),
|
||||
OrderInquiryId: fmt.Sprintf("%d", orderPrescription.OrderInquiryId),
|
||||
DoctorId: fmt.Sprintf("%d", orderPrescription.DoctorId),
|
||||
PatientId: fmt.Sprintf("%d", orderPrescription.PatientId),
|
||||
FamilyId: fmt.Sprintf("%d", orderPrescription.FamilyId),
|
||||
PharmacistId: fmt.Sprintf("%d", orderPrescription.PharmacistId),
|
||||
PrescriptionStatus: orderPrescription.PrescriptionStatus,
|
||||
PharmacistAuditStatus: orderPrescription.PrescriptionStatus,
|
||||
PharmacistVerifyTime: orderPrescription.PharmacistVerifyTime,
|
||||
PharmacistFailReason: orderPrescription.PharmacistFailReason,
|
||||
PlatformAuditStatus: orderPrescription.PlatformAuditStatus,
|
||||
PlatformFailTime: orderPrescription.PlatformFailTime,
|
||||
PlatformFailReason: orderPrescription.PlatformFailReason,
|
||||
IsAutoPharVerify: orderPrescription.IsAutoPharVerify,
|
||||
DoctorCreatedTime: orderPrescription.DoctorCreatedTime,
|
||||
ExpiredTime: orderPrescription.ExpiredTime,
|
||||
VoidTime: orderPrescription.VoidTime,
|
||||
IsDelete: orderPrescription.IsDelete,
|
||||
PrescriptionCode: orderPrescription.PrescriptionCode,
|
||||
DoctorName: orderPrescription.DoctorName,
|
||||
PatientName: orderPrescription.PatientName,
|
||||
PatientSex: orderPrescription.PatientSex,
|
||||
PatientAge: orderPrescription.PatientAge,
|
||||
DoctorAdvice: orderPrescription.DoctorAdvice,
|
||||
CreatedAt: orderPrescription.CreatedAt,
|
||||
UpdatedAt: orderPrescription.UpdatedAt,
|
||||
}
|
||||
return u, nil
|
||||
}
|
||||
140
api/service/orderProduct.go
Normal file
140
api/service/orderProduct.go
Normal file
@ -0,0 +1,140 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"hospital-admin-api/api/dao"
|
||||
"hospital-admin-api/api/responses/orderProductLogisticsResponse"
|
||||
"hospital-admin-api/api/responses/orderProductRefundResponse"
|
||||
"hospital-admin-api/api/responses/orderProductResponse"
|
||||
)
|
||||
|
||||
type OrderProductService struct {
|
||||
}
|
||||
|
||||
// GetOrderProduct 药品订单详情
|
||||
func (r *OrderProductService) GetOrderProduct(orderProductId int64) (getOrderProductResponse *orderProductResponse.GetOrderProduct, err error) {
|
||||
// 获取问诊订单数据
|
||||
orderProductDao := dao.OrderProductDao{}
|
||||
orderProduct, err := orderProductDao.GetOrderProductPreloadById(orderProductId)
|
||||
if err != nil || orderProduct == nil {
|
||||
return nil, errors.New(err.Error())
|
||||
}
|
||||
|
||||
// 获取退款数据
|
||||
orderProductRefund, err := r.GetOrderProductRefund(orderProductId)
|
||||
if err != nil {
|
||||
return nil, errors.New(err.Error())
|
||||
}
|
||||
|
||||
// 获取商品数据
|
||||
orderProductItemService := OrderProductItemService{}
|
||||
orderProductItem, err := orderProductItemService.GetOrderProductItemByOrderProductId(orderProductId)
|
||||
if err != nil {
|
||||
return nil, errors.New(err.Error())
|
||||
}
|
||||
|
||||
// 获取物流数据
|
||||
orderProductLogistics, err := r.GetOrderProductLogistics(orderProductId)
|
||||
if err != nil {
|
||||
return nil, errors.New(err.Error())
|
||||
}
|
||||
|
||||
// 获取处方数据
|
||||
orderPrescriptionService := OrderPrescriptionService{}
|
||||
orderPrescription, err := orderPrescriptionService.GetOrderPrescriptionById(orderProduct.OrderPrescriptionId)
|
||||
if err != nil {
|
||||
return nil, errors.New(err.Error())
|
||||
}
|
||||
|
||||
// 获取问诊病例
|
||||
orderInquiryCaseService := OrderInquiryCaseService{}
|
||||
orderInquiryCase, err := orderInquiryCaseService.GetOrderInquiryCaseByOrderInquiryId(orderProduct.OrderInquiryId)
|
||||
if err != nil {
|
||||
return nil, errors.New(err.Error())
|
||||
}
|
||||
|
||||
// 医生数据
|
||||
userDoctorService := UserDoctorService{}
|
||||
userDoctor, err := userDoctorService.GetOrderInquiryUserDoctor(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,
|
||||
ReportPreStatus: orderProduct.ReportPreStatus,
|
||||
ConsigneeNameMask: orderProduct.ConsigneeNameMask,
|
||||
ConsigneeTelMask: orderProduct.ConsigneeTelMask,
|
||||
CreatedAt: orderProduct.CreatedAt,
|
||||
UpdatedAt: orderProduct.UpdatedAt,
|
||||
OrderProductRefund: orderProductRefund,
|
||||
OrderProductItem: orderProductItem,
|
||||
OrderProductLogistics: orderProductLogistics,
|
||||
UserDoctor: userDoctor,
|
||||
OrderPrescription: orderPrescription,
|
||||
OrderInquiryCase: orderInquiryCase,
|
||||
}
|
||||
|
||||
return getOrderProductResponse, nil
|
||||
}
|
||||
|
||||
// GetOrderProductRefund 获取退款数据
|
||||
func (r *OrderProductService) GetOrderProductRefund(orderProductId int64) (u *orderProductRefundResponse.OrderProductRefund, err error) {
|
||||
orderProductRefundDao := dao.OrderProductRefundDao{}
|
||||
orderProductRefund, err := orderProductRefundDao.GetOrderProductRefundByOrderProductId(orderProductId)
|
||||
if orderProductRefund == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
u = &orderProductRefundResponse.OrderProductRefund{
|
||||
ProductRefundId: fmt.Sprintf("%d", orderProductRefund.ProductRefundId),
|
||||
PatientId: fmt.Sprintf("%d", orderProductRefund.PatientId),
|
||||
OrderProductId: fmt.Sprintf("%d", orderProductRefund.OrderProductId),
|
||||
OrderProductNo: orderProductRefund.OrderProductNo,
|
||||
ProductRefundNo: orderProductRefund.ProductRefundNo,
|
||||
RefundId: orderProductRefund.RefundId,
|
||||
ProductRefundStatus: orderProductRefund.ProductRefundStatus,
|
||||
RefundTotal: orderProductRefund.RefundTotal,
|
||||
RefundReason: orderProductRefund.RefundReason,
|
||||
SuccessTime: orderProductRefund.SuccessTime,
|
||||
CreatedAt: orderProductRefund.CreatedAt,
|
||||
UpdatedAt: orderProductRefund.UpdatedAt,
|
||||
}
|
||||
|
||||
return u, nil
|
||||
}
|
||||
|
||||
// GetOrderProductLogistics 获取物流数据
|
||||
func (r *OrderProductService) GetOrderProductLogistics(orderProductId int64) (u *orderProductLogisticsResponse.OrderProductLogistics, err error) {
|
||||
orderProductLogisticsDao := dao.OrderProductLogisticsDao{}
|
||||
orderProductLogistics, err := orderProductLogisticsDao.GetOrderProductLogisticsByOrderProductId(orderProductId)
|
||||
if orderProductLogistics == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
u = &orderProductLogisticsResponse.OrderProductLogistics{}
|
||||
|
||||
return u, nil
|
||||
}
|
||||
54
api/service/orderProductItem.go
Normal file
54
api/service/orderProductItem.go
Normal file
@ -0,0 +1,54 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"hospital-admin-api/api/dao"
|
||||
"hospital-admin-api/api/responses/orderProductItemResponse"
|
||||
"hospital-admin-api/utils"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type OrderProductItemService struct {
|
||||
}
|
||||
|
||||
// GetOrderProductItemByOrderProductId 获取商品列表-问诊订单id
|
||||
func (r *OrderProductItemService) GetOrderProductItemByOrderProductId(orderProductId int64) (u []*orderProductItemResponse.OrderProductItem, err error) {
|
||||
orderProductItemDao := dao.OrderProductItemDao{}
|
||||
orderProductItems, err := orderProductItemDao.GetOrderProductItemByOrderProductId(orderProductId)
|
||||
if err != nil {
|
||||
return nil, errors.New("数据错误,无药品数据")
|
||||
}
|
||||
|
||||
if len(orderProductItems) == 0 {
|
||||
return nil, errors.New("数据错误,无药品数据")
|
||||
}
|
||||
|
||||
// 处理返回值
|
||||
items := make([]*orderProductItemResponse.OrderProductItem, len(orderProductItems))
|
||||
|
||||
if len(orderProductItems) > 0 {
|
||||
for i, v := range orderProductItems {
|
||||
// 将原始结构体转换为新结构体
|
||||
item := &orderProductItemResponse.OrderProductItem{
|
||||
ProductItemId: strconv.Itoa(int(v.ProductItemId)),
|
||||
OrderProductId: strconv.Itoa(int(v.OrderProductId)),
|
||||
OrderInquiryId: strconv.Itoa(int(v.OrderInquiryId)),
|
||||
OrderPrescriptionId: strconv.Itoa(int(v.OrderPrescriptionId)),
|
||||
ProductId: strconv.Itoa(int(v.ProductId)),
|
||||
ProductName: v.ProductName,
|
||||
ProductPrice: v.ProductPrice,
|
||||
ProductPlatformCode: v.ProductPlatformCode,
|
||||
Amount: v.Amount,
|
||||
Manufacturer: v.Manufacturer,
|
||||
ProductCoverImg: utils.AddOssDomain(v.ProductCoverImg),
|
||||
ProductSpec: v.ProductSpec,
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
items[i] = item
|
||||
}
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user