1
This commit is contained in:
+101
-51
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user