新增取消订单备注

This commit is contained in:
wucongxing 2023-09-12 11:54:01 +08:00
parent 69208b27be
commit 885242a9b4
3 changed files with 23 additions and 4 deletions

View File

@ -100,9 +100,21 @@ func (r *OrderProduct) CancelOrderProduct(c *gin.Context) {
return
}
req := requests.OrderProductRequest{}
if err := c.ShouldBind(&req.CancelOrderProduct); err != nil {
responses.FailWithMessage(err.Error(), c)
return
}
// 参数验证
if err := global.Validate.Struct(req.CancelOrderProduct); err != nil {
responses.FailWithMessage(utils.Translate(err), c)
return
}
// 业务处理
orderProductService := service.OrderProductService{}
_, err = orderProductService.CancelOrderProduct(orderProductId)
_, err = orderProductService.CancelOrderProduct(req.CancelOrderProduct, orderProductId)
if err != nil {
responses.FailWithMessage(err.Error(), c)
return

View File

@ -2,6 +2,7 @@ package requests
type OrderProductRequest struct {
GetOrderProductPage // 获取药品订单列表-分页
CancelOrderProduct // 取消药品订单
}
// GetOrderProductPage 获取药品订单列表-分页
@ -29,3 +30,8 @@ type GetOrderProductPage struct {
PatientName string `json:"patient_name" form:"patient_name" label:"患者姓名-就诊人"`
Mobile string `json:"mobile" form:"mobile" label:"手机号-医生/患者"`
}
// CancelOrderProduct 取消药品订单
type CancelOrderProduct struct {
CancelRemarks string `json:"cancel_remarks" form:"cancel_remarks" validate:"required" label:"取消订单备注"`
}

View File

@ -5,6 +5,7 @@ import (
"fmt"
"hospital-admin-api/api/dao"
"hospital-admin-api/api/model"
"hospital-admin-api/api/requests"
"hospital-admin-api/api/responses/orderProductResponse"
"hospital-admin-api/config"
"hospital-admin-api/extend/weChat"
@ -116,7 +117,7 @@ func (r *OrderProductService) GetOrderProduct(orderProductId int64) (getOrderPro
}
// CancelOrderProduct 取消药品订单
func (r *OrderProductService) CancelOrderProduct(orderProductId int64) (bool, error) {
func (r *OrderProductService) CancelOrderProduct(req requests.CancelOrderProduct, orderProductId int64) (bool, error) {
// 获取药品订单详情
orderProductDao := dao.OrderProductDao{}
orderProduct, err := orderProductDao.GetOrderProductPreloadById(orderProductId)
@ -243,7 +244,7 @@ func (r *OrderProductService) CancelOrderProduct(orderProductId int64) (bool, er
orderProductData["order_product_status"] = 5 // 订单状态1:待支付 2:待发货 3:已发货 4:已签收 5:已取消)
orderProductData["cancel_time"] = time.Now().Format("2006-01-02 15:04:05") // 订单取消时间
orderProductData["cancel_reason"] = 4 // 订单取消原因1:主动取消 2:复核失败/库存不足 3:支付超时 4:客服取消)
orderProductData["cancel_remarks"] = "客服取消" // 取消订单备注(自动添加)
orderProductData["cancel_remarks"] = req.CancelRemarks // 取消订单备注(自动添加)
// 修改问诊订单退款状态
err = orderProductDao.EditOrderProductById(tx, orderProductId, orderProductData)
@ -261,7 +262,7 @@ func (r *OrderProductService) CancelOrderProduct(orderProductId int64) (bool, er
RefundId: refundId,
ProductRefundStatus: refundStatus,
RefundTotal: orderProduct.PaymentAmountTotal,
RefundReason: "客服取消",
RefundReason: req.CancelRemarks,
SuccessTime: model.LocalTime(successTime),
}