新增处方平台取消订单
This commit is contained in:
@@ -35,6 +35,7 @@ type basic struct {
|
||||
|
||||
// 订单管理
|
||||
type order struct {
|
||||
Order // 订单
|
||||
OrderInquiry // 问诊订单
|
||||
OrderProduct // 药品订单
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"hospital-admin-api/api/responses"
|
||||
"hospital-admin-api/extend/prescription"
|
||||
)
|
||||
|
||||
type Order struct{}
|
||||
|
||||
func (r *Order) ReportPreOrder(c *gin.Context) {
|
||||
token, err := prescription.NoticePreOrderCancel("124")
|
||||
if err != nil {
|
||||
responses.OkWithData(err.Error(), c)
|
||||
}
|
||||
fmt.Println(token)
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package middlewares
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"hospital-admin-api/consts"
|
||||
"hospital-admin-api/global"
|
||||
@@ -30,8 +29,6 @@ func Jwt() gin.HandlerFunc {
|
||||
|
||||
// 检测是否存在黑名单
|
||||
res, _ := global.Redis.Get(c, "jwt_black_"+authorization).Result()
|
||||
|
||||
fmt.Println(res)
|
||||
if res != "" {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"message": "token错误/过期",
|
||||
|
||||
@@ -386,5 +386,14 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
||||
// 取消药品订单
|
||||
productGroup.PUT("/cancel/:order_product_id", api.OrderProduct.CancelOrderProduct)
|
||||
}
|
||||
|
||||
// 上报数据
|
||||
reportGroup := orderGroup.Group("/report")
|
||||
{
|
||||
// 上报处方平台
|
||||
reportGroup.POST("/pre/:order_product_id", api.Order.ReportPreOrder)
|
||||
|
||||
// 上报监管平台
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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