1
This commit is contained in:
parent
71c39e3829
commit
906dfc3abd
@ -85,28 +85,28 @@ func (r *OrderProduct) GetOrderProduct(c *gin.Context) {
|
||||
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)
|
||||
// }
|
||||
// CancelOrderProduct 取消药品订单
|
||||
func (r *OrderProduct) CancelOrderProduct(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{}
|
||||
_, err = orderProductService.CancelOrderProduct(orderProductId)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
responses.Ok(c)
|
||||
}
|
||||
|
||||
@ -71,6 +71,13 @@ type GetOrderProduct struct {
|
||||
CancelTime model.LocalTime `json:"cancel_time"` // 订单取消时间
|
||||
CancelRemarks string `json:"cancel_remarks"` // 订单取消备注(自动添加)
|
||||
ReportPreStatus int `json:"report_pre_status"` // 上报处方平台状态(0:未上报 1:已上报 2:上报失败))
|
||||
ProvinceId int `json:"province_id"` // 省份id
|
||||
Province string `json:"province"` // 省份
|
||||
CityId int `json:"city_id"` // 城市id
|
||||
City string `json:"city"` // 城市
|
||||
CountyId int `json:"county_id"` // county_id
|
||||
County string `json:"county"` // 区县
|
||||
AddressMask string `json:"address_mask"` // 详细地址(掩码)
|
||||
ConsigneeNameMask string `json:"consignee_name_mask"` // 收货人姓名(掩码)
|
||||
ConsigneeTelMask string `json:"consignee_tel_mask"` // 收货人电话(掩码)
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
|
||||
@ -381,7 +381,7 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
||||
productGroup.GET("/:order_product_id", api.OrderProduct.GetOrderProduct)
|
||||
|
||||
// 取消药品订单
|
||||
productGroup.PUT("/:order_inquiry_id", api.OrderProduct.GetOrderProductPage)
|
||||
productGroup.PUT("/:order_product_id", api.OrderProduct.CancelOrderProduct)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,8 +4,6 @@ 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"
|
||||
)
|
||||
|
||||
@ -14,7 +12,7 @@ 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 {
|
||||
@ -22,7 +20,8 @@ func (r *OrderProductService) GetOrderProduct(orderProductId int64) (getOrderPro
|
||||
}
|
||||
|
||||
// 获取退款数据
|
||||
orderProductRefund, err := r.GetOrderProductRefund(orderProductId)
|
||||
orderProductRefundService := OrderProductRefundService{}
|
||||
orderProductRefund, err := orderProductRefundService.GetOrderProductRefundByOrderProductId(orderProductId)
|
||||
if err != nil {
|
||||
return nil, errors.New(err.Error())
|
||||
}
|
||||
@ -35,7 +34,8 @@ func (r *OrderProductService) GetOrderProduct(orderProductId int64) (getOrderPro
|
||||
}
|
||||
|
||||
// 获取物流数据
|
||||
orderProductLogistics, err := r.GetOrderProductLogistics(orderProductId)
|
||||
orderProductLogisticsService := OrderProductLogisticsService{}
|
||||
orderProductLogistics, err := orderProductLogisticsService.GetOrderProductLogisticsByOrderProductId(orderProductId)
|
||||
if err != nil {
|
||||
return nil, errors.New(err.Error())
|
||||
}
|
||||
@ -87,6 +87,15 @@ func (r *OrderProductService) GetOrderProduct(orderProductId int64) (getOrderPro
|
||||
CancelTime: orderProduct.CancelTime,
|
||||
CancelRemarks: orderProduct.CancelRemarks,
|
||||
ReportPreStatus: orderProduct.ReportPreStatus,
|
||||
ProvinceId: orderProduct.ProvinceId,
|
||||
Province: orderProduct.Province,
|
||||
CityId: orderProduct.CityId,
|
||||
City: orderProduct.City,
|
||||
CountyId: orderProduct.CountyId,
|
||||
County: orderProduct.County,
|
||||
AddressMask: orderProduct.AddressMask,
|
||||
ConsigneeNameMask: orderProduct.ConsigneeNameMask,
|
||||
ConsigneeTelMask: orderProduct.ConsigneeTelMask,
|
||||
CreatedAt: orderProduct.CreatedAt,
|
||||
UpdatedAt: orderProduct.UpdatedAt,
|
||||
OrderProductRefund: orderProductRefund,
|
||||
@ -100,51 +109,92 @@ func (r *OrderProductService) GetOrderProduct(orderProductId int64) (getOrderPro
|
||||
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
|
||||
}
|
||||
// CancelOrderProduct 取消药品订单
|
||||
func (r *OrderProductService) CancelOrderProduct(orderProductId int64) (bool, error) {
|
||||
// // 获取药品订单详情
|
||||
// orderProductDao := dao.OrderProductDao{}
|
||||
// orderProduct, err := orderProductDao.GetOrderProductPreloadById(orderProductId)
|
||||
// if err != nil || orderProduct == nil {
|
||||
// return false, errors.New("订单数据错误")
|
||||
// }
|
||||
//
|
||||
// // 检测订单状态
|
||||
// if orderProduct.OrderProductStatus == 1 {
|
||||
// return false, errors.New("订单处于待支付状态,无法取消")
|
||||
// }
|
||||
//
|
||||
// if orderProduct.OrderProductStatus == 3 {
|
||||
// return false, errors.New("订单已发货,无法取消")
|
||||
// }
|
||||
//
|
||||
// if orderProduct.OrderProductStatus == 4 {
|
||||
// return false, errors.New("订单已签收,无法取消")
|
||||
// }
|
||||
//
|
||||
// if orderProduct.OrderProductStatus == 5 {
|
||||
// return false, errors.New("订单已取消,无法取消")
|
||||
// }
|
||||
//
|
||||
// // 检测订单退款状态
|
||||
// if orderProduct.RefundStatus == 1 {
|
||||
// return false, errors.New("订单申请退款中,无法取消")
|
||||
// }
|
||||
//
|
||||
// if orderProduct.RefundStatus == 2 {
|
||||
// return false, errors.New("订单正在退款中,无法取消")
|
||||
// }
|
||||
//
|
||||
// if orderProduct.RefundStatus == 3 {
|
||||
// return false, errors.New("订单已退款成功,无法取消")
|
||||
// }
|
||||
//
|
||||
// if orderProduct.RefundStatus == 6 {
|
||||
// return false, errors.New("订单退款异常,请联系技术人员")
|
||||
// }
|
||||
//
|
||||
// // 检测订单支付状态
|
||||
// if orderProduct.PayStatus != 2 {
|
||||
// return false, errors.New("订单未支付,无需取消")
|
||||
// }
|
||||
//
|
||||
// // 开始事务
|
||||
// tx := global.Db.Begin()
|
||||
// defer func() {
|
||||
// if r := recover(); r != nil {
|
||||
// tx.Rollback()
|
||||
// }
|
||||
// }()
|
||||
//
|
||||
// // 药品订单修改数据
|
||||
// orderProductData := make(map[string]interface{})
|
||||
//
|
||||
// // 退款编号
|
||||
// refundNo := strconv.FormatInt(global.Snowflake.Generate().Int64(), 10)
|
||||
//
|
||||
// // 退款状态转换
|
||||
// var productRefundStatus int
|
||||
// var successTime time.Time
|
||||
// var refundId string
|
||||
//
|
||||
// refundRequest := weChat.RefundRequest{
|
||||
// TransactionId: orderProduct.EscrowTradeNo,
|
||||
// OutTradeNo: orderProduct.OrderProductNo,
|
||||
// OutRefundNo: refundNo,
|
||||
// Reason: "客服取消",
|
||||
// PaymentAmountTotal: int64(orderProduct.PaymentAmountTotal * 100),
|
||||
// NotifyUrl: config.C.Wechat.RefundNotifyDomain + config.C.Wechat.PatientProductRefundNotifyUrl,
|
||||
// }
|
||||
//
|
||||
// refund, err := refundRequest.Refund()
|
||||
// if err != nil {
|
||||
// tx.Rollback()
|
||||
// return false, errors.New(err.Error())
|
||||
// }
|
||||
//
|
||||
// if refund.Status == nil {
|
||||
// tx.Rollback()
|
||||
// return false, errors.New("退款状态错误")
|
||||
// }
|
||||
|
||||
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{
|
||||
LogisticsId: fmt.Sprintf("%d", orderProductLogistics.LogisticsId),
|
||||
OrderProductId: fmt.Sprintf("%d", orderProductLogistics.OrderProductId),
|
||||
LogisticsStatus: orderProductLogistics.LogisticsStatus,
|
||||
LogisticsNo: orderProductLogistics.LogisticsNo,
|
||||
CompanyName: orderProductLogistics.CompanyName,
|
||||
CompanyCode: orderProductLogistics.CompanyCode,
|
||||
LogisticsContent: orderProductLogistics.LogisticsContent,
|
||||
CreatedAt: orderProductLogistics.CreatedAt,
|
||||
UpdatedAt: orderProductLogistics.UpdatedAt,
|
||||
}
|
||||
|
||||
return u, nil
|
||||
return true, nil
|
||||
}
|
||||
|
||||
33
api/service/orderProductLogistics.go
Normal file
33
api/service/orderProductLogistics.go
Normal file
@ -0,0 +1,33 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hospital-admin-api/api/dao"
|
||||
"hospital-admin-api/api/responses/orderProductLogisticsResponse"
|
||||
)
|
||||
|
||||
type OrderProductLogisticsService struct {
|
||||
}
|
||||
|
||||
// GetOrderProductLogisticsByOrderProductId 获取物流数据-药品订单id
|
||||
func (r *OrderProductLogisticsService) GetOrderProductLogisticsByOrderProductId(orderProductId int64) (u *orderProductLogisticsResponse.OrderProductLogistics, err error) {
|
||||
orderProductLogisticsDao := dao.OrderProductLogisticsDao{}
|
||||
orderProductLogistics, err := orderProductLogisticsDao.GetOrderProductLogisticsByOrderProductId(orderProductId)
|
||||
if orderProductLogistics == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
u = &orderProductLogisticsResponse.OrderProductLogistics{
|
||||
LogisticsId: fmt.Sprintf("%d", orderProductLogistics.LogisticsId),
|
||||
OrderProductId: fmt.Sprintf("%d", orderProductLogistics.OrderProductId),
|
||||
LogisticsStatus: orderProductLogistics.LogisticsStatus,
|
||||
LogisticsNo: orderProductLogistics.LogisticsNo,
|
||||
CompanyName: orderProductLogistics.CompanyName,
|
||||
CompanyCode: orderProductLogistics.CompanyCode,
|
||||
LogisticsContent: orderProductLogistics.LogisticsContent,
|
||||
CreatedAt: orderProductLogistics.CreatedAt,
|
||||
UpdatedAt: orderProductLogistics.UpdatedAt,
|
||||
}
|
||||
|
||||
return u, nil
|
||||
}
|
||||
36
api/service/orderProductRefund.go
Normal file
36
api/service/orderProductRefund.go
Normal file
@ -0,0 +1,36 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hospital-admin-api/api/dao"
|
||||
"hospital-admin-api/api/responses/orderProductRefundResponse"
|
||||
)
|
||||
|
||||
type OrderProductRefundService struct {
|
||||
}
|
||||
|
||||
// GetOrderProductRefundByOrderProductId 获取退款数据
|
||||
func (r *OrderProductRefundService) GetOrderProductRefundByOrderProductId(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
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user