新增药品订单列表
This commit is contained in:
parent
654c0fed05
commit
e82932ab53
@ -36,4 +36,5 @@ type basic struct {
|
||||
// 订单管理
|
||||
type order struct {
|
||||
OrderInquiry // 问诊订单
|
||||
OrderProduct // 药品订单
|
||||
}
|
||||
|
||||
@ -85,11 +85,6 @@ func (r *OrderInquiry) GetOrderInquiry(c *gin.Context) {
|
||||
responses.OkWithData(getUserDoctorResponses, c)
|
||||
}
|
||||
|
||||
// DeleteOrderInquiry 删除问诊订单
|
||||
func (r *OrderInquiry) DeleteOrderInquiry(c *gin.Context) {
|
||||
responses.Ok(c)
|
||||
}
|
||||
|
||||
// CancelOrderInquiry 取消问诊订单
|
||||
func (r *OrderInquiry) CancelOrderInquiry(c *gin.Context) {
|
||||
id := c.Param("order_inquiry_id")
|
||||
|
||||
110
api/controller/orderProduct.go
Normal file
110
api/controller/orderProduct.go
Normal file
@ -0,0 +1,110 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"hospital-admin-api/api/dao"
|
||||
"hospital-admin-api/api/requests"
|
||||
"hospital-admin-api/api/responses"
|
||||
"hospital-admin-api/api/responses/orderProductResponse"
|
||||
"hospital-admin-api/global"
|
||||
"hospital-admin-api/utils"
|
||||
)
|
||||
|
||||
type OrderProduct struct{}
|
||||
|
||||
// GetOrderProductPage 获取药品订单列表-分页
|
||||
func (r *OrderProduct) GetOrderProductPage(c *gin.Context) {
|
||||
req := requests.OrderProductRequest{}
|
||||
if err := c.ShouldBind(&req.GetOrderProductPage); err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 参数验证
|
||||
if err := global.Validate.Struct(req.GetOrderProductPage); err != nil {
|
||||
responses.FailWithMessage(utils.Translate(err), c)
|
||||
return
|
||||
}
|
||||
|
||||
if req.GetOrderProductPage.Page == 0 {
|
||||
req.GetOrderProductPage.Page = 1
|
||||
}
|
||||
|
||||
if req.GetOrderProductPage.PageSize == 0 {
|
||||
req.GetOrderProductPage.PageSize = 20
|
||||
}
|
||||
|
||||
orderProductDao := dao.OrderProductDao{}
|
||||
orderProduct, total, err := orderProductDao.GetOrderProductPageSearch(req.GetOrderProductPage, req.GetOrderProductPage.Page, req.GetOrderProductPage.PageSize)
|
||||
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 处理返回值
|
||||
GetOrderProductPageResponses := orderProductResponse.GetOrderProductPageResponse(orderProduct)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
result := make(map[string]interface{})
|
||||
result["page"] = req.GetOrderProductPage.Page
|
||||
result["page_size"] = req.GetOrderProductPage.PageSize
|
||||
result["total"] = total
|
||||
result["data"] = GetOrderProductPageResponses
|
||||
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)
|
||||
// }
|
||||
//
|
||||
// // CancelOrderProduct 取消药品订单
|
||||
// func (r *OrderProduct) CancelOrderProduct(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{}
|
||||
// _, err = orderInquiryService.CancelOrderProduct(orderInquiryId)
|
||||
// if err != nil {
|
||||
// responses.FailWithMessage(err.Error(), c)
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// responses.Ok(c)
|
||||
// }
|
||||
231
api/dao/orderProduct.go
Normal file
231
api/dao/orderProduct.go
Normal file
@ -0,0 +1,231 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/api/requests"
|
||||
"hospital-admin-api/global"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type OrderProductDao struct {
|
||||
}
|
||||
|
||||
// GetOrderProductById 获取药品订单数据-药品订单id
|
||||
func (r *OrderProductDao) GetOrderProductById(orderProductId int64) (m *model.OrderProduct, err error) {
|
||||
err = global.Db.First(&m, orderProductId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetOrderProductPreloadById 获取药品订单数据-加载全部关联-药品订单id
|
||||
func (r *OrderProductDao) GetOrderProductPreloadById(orderProductId int64) (m *model.OrderProduct, err error) {
|
||||
err = global.Db.Preload(clause.Associations).First(&m, orderProductId).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// DeleteOrderProduct 删除药品订单
|
||||
func (r *OrderProductDao) DeleteOrderProduct(tx *gorm.DB, maps interface{}) error {
|
||||
err := tx.Where(maps).Delete(&model.OrderProduct{}).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditOrderProduct 修改药品订单
|
||||
func (r *OrderProductDao) EditOrderProduct(tx *gorm.DB, maps interface{}, data interface{}) error {
|
||||
err := tx.Model(&model.OrderProduct{}).Where(maps).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EditOrderProductById 修改药品订单-药品订单id
|
||||
func (r *OrderProductDao) EditOrderProductById(tx *gorm.DB, orderProductId int64, data interface{}) error {
|
||||
err := tx.Model(&model.OrderProduct{}).Where("order_product_id = ?", orderProductId).Updates(data).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetOrderProductList 获取药品订单列表
|
||||
func (r *OrderProductDao) GetOrderProductList(maps interface{}) (m []*model.OrderProduct, err error) {
|
||||
err = global.Db.Where(maps).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// AddOrderProduct 新增药品订单
|
||||
func (r *OrderProductDao) AddOrderProduct(tx *gorm.DB, model *model.OrderProduct) (*model.OrderProduct, error) {
|
||||
if err := tx.Create(model).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return model, nil
|
||||
}
|
||||
|
||||
// GetOrderProductPageSearch 获取药品订单列表-分页
|
||||
func (r *OrderProductDao) GetOrderProductPageSearch(req requests.GetOrderProductPage, page, pageSize int) (m []*model.OrderProduct, total int64, err error) {
|
||||
var totalRecords int64
|
||||
|
||||
// 构建查询条件
|
||||
query := global.Db.Model(&model.OrderProduct{})
|
||||
|
||||
// 医生
|
||||
query = query.Preload("UserDoctor", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Omit("open_id", "union_id", "wx_session_key")
|
||||
})
|
||||
|
||||
// 问诊订单
|
||||
query = query.Preload("OrderInquiry", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Select("order_inquiry_id", "patient_name_mask", "patient_sex", "patient_age")
|
||||
})
|
||||
|
||||
// 医生姓名
|
||||
if req.DoctorName != "" {
|
||||
subQuery := global.Db.Model(&model.UserDoctor{}).
|
||||
Select("doctor_id").
|
||||
Where("user_name LIKE ?", "%"+req.DoctorName+"%")
|
||||
|
||||
query = query.Where(gorm.Expr("doctor_id IN (?)", subQuery))
|
||||
}
|
||||
|
||||
// 患者姓名-就诊人
|
||||
if req.PatientName != "" {
|
||||
subQuery := global.Db.Model(&model.OrderInquiry{}).
|
||||
Select("order_inquiry_id").
|
||||
Where("patient_name LIKE ?", "%"+req.PatientName+"%")
|
||||
|
||||
query = query.Where(gorm.Expr("order_inquiry_id IN (?)", subQuery))
|
||||
}
|
||||
|
||||
// 订单编号
|
||||
if req.OrderProductNo != "" {
|
||||
query = query.Where("order_product_no = ?", req.OrderProductNo)
|
||||
}
|
||||
|
||||
// 第三方支付流水号
|
||||
if req.EscrowTradeNo != "" {
|
||||
query = query.Where("escrow_trade_no = ?", req.EscrowTradeNo)
|
||||
}
|
||||
|
||||
// 订单状态
|
||||
if req.OrderProductStatus != nil {
|
||||
query = query.Where("order_product_status = ?", req.OrderProductStatus)
|
||||
}
|
||||
|
||||
// 支付渠道
|
||||
if req.PayChannel != nil {
|
||||
query = query.Where("pay_channel = ?", req.PayChannel)
|
||||
}
|
||||
|
||||
// 支付状态
|
||||
if req.PayStatus != nil {
|
||||
query = query.Where("pay_status = ?", req.PayStatus)
|
||||
}
|
||||
|
||||
// 订单取消原因
|
||||
if req.CancelReason != nil {
|
||||
query = query.Where("cancel_reason = ?", req.CancelReason)
|
||||
}
|
||||
|
||||
// 物流编号
|
||||
if req.LogisticsNo != "" {
|
||||
query = query.Where("logistics_no = ?", req.LogisticsNo)
|
||||
}
|
||||
|
||||
// 快递公司编码
|
||||
if req.LogisticsCompanyCode != "" {
|
||||
query = query.Where("logistics_company_code = ?", req.LogisticsCompanyCode)
|
||||
}
|
||||
|
||||
// 订单备注
|
||||
if req.Remarks != "" {
|
||||
query = query.Where("remarks like ?", "%"+req.Remarks+"%")
|
||||
}
|
||||
|
||||
// 退款状态
|
||||
if req.RefundStatus != nil {
|
||||
query = query.Where("refund_status = ?", req.RefundStatus)
|
||||
}
|
||||
|
||||
// 上报处方平台状态
|
||||
if req.ReportPreStatus != nil {
|
||||
query = query.Where("report_pre_status = ?", req.ReportPreStatus)
|
||||
}
|
||||
|
||||
// 发货时间
|
||||
if req.DeliveryTime != "" {
|
||||
deliveryTime := strings.Split(req.DeliveryTime, "&")
|
||||
if len(deliveryTime) == 2 {
|
||||
startTime, _ := time.Parse("2006-01-02", deliveryTime[0])
|
||||
endTime, _ := time.Parse("2006-01-02", deliveryTime[1])
|
||||
query = query.Where("delivery_time BETWEEN ? AND ?", startTime, endTime)
|
||||
}
|
||||
}
|
||||
|
||||
// 订单取消时间
|
||||
if req.CancelTime != "" {
|
||||
cancelTime := strings.Split(req.CancelTime, "&")
|
||||
if len(cancelTime) == 2 {
|
||||
startTime, _ := time.Parse("2006-01-02", cancelTime[0])
|
||||
endTime, _ := time.Parse("2006-01-02", cancelTime[1])
|
||||
query = query.Where("cancel_time BETWEEN ? AND ?", startTime, endTime)
|
||||
}
|
||||
}
|
||||
|
||||
// 支付时间
|
||||
if req.PayTime != "" {
|
||||
payTime := strings.Split(req.PayTime, "&")
|
||||
if len(payTime) == 2 {
|
||||
startTime, _ := time.Parse("2006-01-02", payTime[0])
|
||||
endTime, _ := time.Parse("2006-01-02", payTime[1])
|
||||
query = query.Where("complete_time BETWEEN ? AND ?", startTime, endTime)
|
||||
}
|
||||
}
|
||||
|
||||
// 上报处方平台时间
|
||||
if req.ReportPreTime != "" {
|
||||
reportPreTime := strings.Split(req.ReportPreTime, "&")
|
||||
if len(reportPreTime) == 2 {
|
||||
startTime, _ := time.Parse("2006-01-02", reportPreTime[0])
|
||||
endTime, _ := time.Parse("2006-01-02", reportPreTime[1])
|
||||
query = query.Where("report_pre_time BETWEEN ? AND ?", startTime, endTime)
|
||||
}
|
||||
}
|
||||
|
||||
// 收货人姓名
|
||||
if req.ConsigneeName != "" {
|
||||
query = query.Where("consignee_name LIKE ?", "%"+req.ConsigneeName+"%")
|
||||
}
|
||||
|
||||
// 收货人电话
|
||||
if req.ConsigneeTel != "" {
|
||||
query = query.Where("consignee_tel LIKE ?", "%"+req.ConsigneeTel+"%")
|
||||
}
|
||||
|
||||
// 排序
|
||||
query = query.Order("created_at desc")
|
||||
|
||||
// 查询总数量
|
||||
if err := query.Count(&totalRecords).Error; err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
err = query.Scopes(model.Paginate(page, pageSize)).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
return m, totalRecords, nil
|
||||
}
|
||||
72
api/model/orderProduct.go
Normal file
72
api/model/orderProduct.go
Normal file
@ -0,0 +1,72 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// OrderProduct 订单-商品订单表
|
||||
type OrderProduct struct {
|
||||
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"`
|
||||
OrderPrescriptionId int64 `gorm:"column:order_prescription_id;type:bigint(19);comment:订单-处方id;NOT NULL" json:"order_prescription_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"`
|
||||
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"`
|
||||
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"`
|
||||
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"`
|
||||
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"`
|
||||
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"`
|
||||
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"`
|
||||
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"`
|
||||
DeliveryTime LocalTime `gorm:"column:delivery_time;type:datetime;comment:发货时间" json:"delivery_time"`
|
||||
PayTime LocalTime `gorm:"column:pay_time;type:datetime;comment:支付时间" json:"pay_time"`
|
||||
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"`
|
||||
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"`
|
||||
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"`
|
||||
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"`
|
||||
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"`
|
||||
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"`
|
||||
County string `gorm:"column:county;type:varchar(255);comment:区县" json:"county"`
|
||||
Address string `gorm:"column:address;type:varchar(255);comment:详细地址" json:"address"`
|
||||
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"`
|
||||
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"`
|
||||
UserDoctor *UserDoctor `gorm:"foreignKey:DoctorId;references:doctor_id" json:"user_doctor"` // 医生
|
||||
OrderInquiry *OrderInquiry `gorm:"foreignKey:OrderInquiryId;references:order_inquiry_id" json:"order_inquiry"` // 问诊
|
||||
Model
|
||||
}
|
||||
|
||||
func (m *OrderProduct) TableName() string {
|
||||
return "gdxz_order_product"
|
||||
}
|
||||
|
||||
func (m *OrderProduct) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.OrderProductId == 0 {
|
||||
m.OrderProductId = 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
|
||||
}
|
||||
30
api/requests/orderProduct.go
Normal file
30
api/requests/orderProduct.go
Normal file
@ -0,0 +1,30 @@
|
||||
package requests
|
||||
|
||||
type OrderProductRequest struct {
|
||||
GetOrderProductPage // 获取药品订单列表-分页
|
||||
}
|
||||
|
||||
// GetOrderProductPage 获取药品订单列表-分页
|
||||
type GetOrderProductPage struct {
|
||||
Page int `json:"page" form:"page" label:"页码"`
|
||||
PageSize int `json:"page_size" form:"page_size" label:"每页个数"`
|
||||
DoctorName string `json:"doctor_name" form:"doctor_name" label:"医生姓名"`
|
||||
OrderProductNo string `json:"order_product_no" form:"order_product_no" label:"订单编号"`
|
||||
EscrowTradeNo string `json:"escrow_trade_no" form:"escrow_trade_no" label:"第三方支付流水号"`
|
||||
OrderProductStatus *int `json:"order_product_status" form:"order_product_status" label:"订单状态"` // 1:1:待支付 2:待发货 3:已发货 4:已签收 5:已取消
|
||||
PayChannel *int `json:"pay_channel" form:"pay_channel" label:"支付渠道"` // 1:小程序支付 2:微信扫码支付
|
||||
PayStatus *int `json:"pay_status" form:"pay_status" label:"支付状态"` // (1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||
CancelReason *int `json:"cancel_reason" form:"cancel_reason" label:"订单取消原因"` // 1:主动取消 2:复核失败/库存不足 3:支付超时 4:客服取消
|
||||
LogisticsNo string `json:"logistics_no" form:"logistics_no" label:"物流编号"`
|
||||
LogisticsCompanyCode string `json:"logistics_company_code" form:"logistics_company_code" label:"快递公司编码"`
|
||||
Remarks string `json:"remarks" form:"remarks" label:"订单备注"`
|
||||
RefundStatus *int `json:"refund_status" form:"refund_status" label:"退款状态"` // 0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常
|
||||
ReportPreStatus *int `json:"report_pre_status" form:"report_pre_status" label:"上报处方平台状态"` // 0:未上报 1:已上报 2:上报失败
|
||||
DeliveryTime string `json:"delivery_time" form:"delivery_time" label:"发货时间"` // 时间区间,数组形式,下标0为开始时间,下标1为结束时间
|
||||
CancelTime string `json:"cancel_time" form:"cancel_time" label:"订单取消时间"` // 时间区间,数组形式,下标0为开始时间,下标1为结束时间
|
||||
PayTime string `json:"pay_time" form:"pay_time" label:"支付时间"` // 时间区间,数组形式,下标0为开始时间,下标1为结束时间
|
||||
ReportPreTime string `json:"report_pre_time" form:"report_pre_time" label:"上报处方平台时间"` // 时间区间,数组形式,下标0为开始时间,下标1为结束时间
|
||||
ConsigneeName string `json:"consignee_name" form:"consignee_name" label:"收货人姓名"`
|
||||
ConsigneeTel string `json:"consignee_tel" form:"cancel_reason" label:"收货人电话"`
|
||||
PatientName string `json:"patient_name" form:"patient_name" label:"患者姓名-就诊人"`
|
||||
}
|
||||
138
api/responses/orderProductResponse/orderProduct.go
Normal file
138
api/responses/orderProductResponse/orderProduct.go
Normal file
@ -0,0 +1,138 @@
|
||||
package orderProductResponse
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hospital-admin-api/api/model"
|
||||
)
|
||||
|
||||
// getOrderProductPage 获取医生列表-分页
|
||||
type getOrderProductPage 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"` // 收货人电话(掩码)
|
||||
DoctorName string `json:"doctor_name"` // 医生姓名
|
||||
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"` // 更新时间
|
||||
}
|
||||
|
||||
// // 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"` // 更新时间
|
||||
// }
|
||||
|
||||
// GetOrderProductPageResponse 获取药品订单列表-分页
|
||||
func GetOrderProductPageResponse(orderProduct []*model.OrderProduct) []getOrderProductPage {
|
||||
// 处理返回值
|
||||
getOrderProductPages := make([]getOrderProductPage, len(orderProduct))
|
||||
|
||||
if len(orderProduct) > 0 {
|
||||
for i, v := range orderProduct {
|
||||
// 将原始结构体转换为新结构体
|
||||
res := getOrderProductPage{
|
||||
OrderProductId: fmt.Sprintf("%d", v.OrderProductId),
|
||||
OrderInquiryId: fmt.Sprintf("%d", v.OrderInquiryId),
|
||||
OrderPrescriptionId: fmt.Sprintf("%d", v.OrderPrescriptionId),
|
||||
DoctorId: fmt.Sprintf("%d", v.DoctorId),
|
||||
PatientId: fmt.Sprintf("%d", v.PatientId),
|
||||
FamilyId: fmt.Sprintf("%d", v.FamilyId),
|
||||
OrderProductNo: v.OrderProductNo,
|
||||
EscrowTradeNo: v.OrderProductNo,
|
||||
OrderProductStatus: v.OrderProductStatus,
|
||||
PayChannel: v.PayChannel,
|
||||
PayStatus: v.PayStatus,
|
||||
CancelReason: v.CancelReason,
|
||||
AmountTotal: v.AmountTotal,
|
||||
PaymentAmountTotal: v.PaymentAmountTotal,
|
||||
LogisticsFee: v.LogisticsFee,
|
||||
LogisticsNo: v.LogisticsNo,
|
||||
LogisticsCompanyCode: v.LogisticsCompanyCode,
|
||||
DeliveryTime: v.DeliveryTime,
|
||||
PayTime: v.PayTime,
|
||||
Remarks: v.Remarks,
|
||||
RefundStatus: v.RefundStatus,
|
||||
ReportPreStatus: v.ReportPreStatus,
|
||||
ConsigneeNameMask: v.ConsigneeNameMask,
|
||||
ConsigneeTelMask: v.ConsigneeTelMask,
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
}
|
||||
|
||||
if v.UserDoctor != nil {
|
||||
res.DoctorName = v.UserDoctor.UserName
|
||||
}
|
||||
|
||||
if v.OrderInquiry != nil {
|
||||
res.PatientNameMask = v.OrderInquiry.PatientNameMask
|
||||
res.PatientSex = v.OrderInquiry.PatientSex
|
||||
res.PatientAge = v.OrderInquiry.PatientAge
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
getOrderProductPages[i] = res
|
||||
}
|
||||
}
|
||||
|
||||
return getOrderProductPages
|
||||
}
|
||||
@ -367,11 +367,21 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
||||
// 问诊订单详情
|
||||
inquiryGroup.GET("/:order_inquiry_id", api.OrderInquiry.GetOrderInquiry)
|
||||
|
||||
// 删除问诊订单
|
||||
inquiryGroup.DELETE("/:order_inquiry_id", api.OrderInquiry.DeleteOrderInquiry)
|
||||
|
||||
// 取消问诊订单
|
||||
inquiryGroup.PUT("/:order_inquiry_id", api.OrderInquiry.CancelOrderInquiry)
|
||||
}
|
||||
|
||||
// 问诊订单
|
||||
productGroup := orderGroup.Group("/product")
|
||||
{
|
||||
// 获取药品订单列表-分页
|
||||
productGroup.GET("", api.OrderProduct.GetOrderProductPage)
|
||||
|
||||
// 药品订单详情
|
||||
productGroup.GET("/:order_inquiry_id", api.OrderProduct.GetOrderProductPage)
|
||||
|
||||
// 取消药品订单
|
||||
productGroup.PUT("/:order_inquiry_id", api.OrderProduct.GetOrderProductPage)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user