新增上报处方平台接口

This commit is contained in:
2023-09-14 09:43:17 +08:00
parent 296199e760
commit 992a51267c
2 changed files with 28 additions and 2 deletions
+28 -1
View File
@@ -5,6 +5,7 @@ import (
"fmt"
"hospital-admin-api/api/dao"
"hospital-admin-api/extend/prescription"
"hospital-admin-api/global"
"hospital-admin-api/utils"
"strings"
"time"
@@ -262,6 +263,32 @@ func (r *OrderService) ReportPreProduct(orderProductId int64) (bool, error) {
PresList: presRequests,
}
fmt.Println(ReportPreRequest)
// 开始事务
tx := global.Db.Begin()
defer func() {
if r := recover(); r != nil {
tx.Rollback()
}
}()
// 上报处方
_, err = ReportPreRequest.ReportPre()
if err != nil {
tx.Rollback()
return false, errors.New("上报处方失败1")
}
orderProductData := make(map[string]interface{})
orderProductData["report_pre_status"] = 1
orderProductData["report_pre_time"] = time.Now().Format("2006-01-02 15:04:05")
err = orderProductDao.EditOrderProductById(tx, orderProductId, orderProductData)
if err != nil {
tx.Rollback()
return false, errors.New("上报处方失败2")
}
tx.Commit()
return true, nil
}