新增处方平台取消订单
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
package service
|
||||
|
||||
// ReportPreProduct 商品订单上报处方平台
|
||||
func ReportPreProduct() {
|
||||
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"hospital-admin-api/api/requests"
|
||||
"hospital-admin-api/api/responses/orderProductResponse"
|
||||
"hospital-admin-api/config"
|
||||
"hospital-admin-api/extend/prescription"
|
||||
"hospital-admin-api/extend/weChat"
|
||||
"hospital-admin-api/global"
|
||||
"strconv"
|
||||
@@ -142,11 +143,6 @@ func (r *OrderProductService) CancelOrderProduct(req requests.CancelOrderProduct
|
||||
return false, errors.New("订单已取消,无法取消")
|
||||
}
|
||||
|
||||
// 已上报暂不允许取消订单
|
||||
if orderProduct.ReportPreStatus == 1 {
|
||||
return false, errors.New("订单已上报,暂不允许取消")
|
||||
}
|
||||
|
||||
// 检测订单退款状态
|
||||
if orderProduct.RefundStatus == 1 {
|
||||
return false, errors.New("订单申请退款中,无法取消")
|
||||
@@ -188,6 +184,14 @@ func (r *OrderProductService) CancelOrderProduct(req requests.CancelOrderProduct
|
||||
var successTime time.Time
|
||||
var refundId string
|
||||
|
||||
// 通知处方平台订单取消
|
||||
_, err = prescription.NoticePreOrderCancel(orderProduct.OrderProductNo)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New("取消订单失败")
|
||||
}
|
||||
|
||||
// 微信退款
|
||||
refundRequest := weChat.RefundRequest{
|
||||
TransactionId: orderProduct.EscrowTradeNo,
|
||||
OutTradeNo: orderProduct.OrderProductNo,
|
||||
@@ -240,13 +244,12 @@ func (r *OrderProductService) CancelOrderProduct(req requests.CancelOrderProduct
|
||||
// 退款编号
|
||||
refundId = *refund.RefundId
|
||||
|
||||
// 修改问诊订单退款状态
|
||||
orderProductData["refund_status"] = refundStatus
|
||||
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"] = req.CancelRemarks // 取消订单备注(自动添加)
|
||||
|
||||
// 修改问诊订单退款状态
|
||||
err = orderProductDao.EditOrderProductById(tx, orderProductId, orderProductData)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
|
||||
Reference in New Issue
Block a user