新增操作记录日志

This commit is contained in:
2023-09-14 14:38:21 +08:00
parent 16615530de
commit e1887b52e7
8 changed files with 192 additions and 7 deletions
+20 -2
View File
@@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"hospital-admin-api/api/dao"
"hospital-admin-api/api/model"
"hospital-admin-api/extend/prescription"
"hospital-admin-api/global"
"hospital-admin-api/utils"
@@ -15,7 +16,7 @@ type OrderService struct {
}
// ReportPreProduct 商品订单上报处方平台
func (r *OrderService) ReportPreProduct(orderProductId int64) (bool, error) {
func (r *OrderService) ReportPreProduct(orderProductId, adminUserId int64) (bool, error) {
// 获取药品订单详情
orderProductDao := dao.OrderProductDao{}
orderProduct, err := orderProductDao.GetOrderProductPreloadById(orderProductId)
@@ -278,6 +279,7 @@ func (r *OrderService) ReportPreProduct(orderProductId int64) (bool, error) {
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")
@@ -285,7 +287,23 @@ func (r *OrderService) ReportPreProduct(orderProductId int64) (bool, error) {
err = orderProductDao.EditOrderProductById(tx, orderProductId, orderProductData)
if err != nil {
tx.Rollback()
return false, errors.New("上报处方失败2")
return false, errors.New("上报处方失败")
}
// 记录日志
orderOperationLog := &model.OrderOperationLog{
OrderId: orderProduct.OrderProductId,
OrderNo: orderProduct.OrderProductNo,
OrderType: 2,
OperatorId: adminUserId,
OperationContent: "上报处方平台",
}
orderOperationLogDao := dao.OrderOperationLogDao{}
orderOperationLog, err = orderOperationLogDao.AddOrderOperationLog(tx, orderOperationLog)
if err != nil || orderOperationLog == nil {
tx.Rollback()
return false, errors.New(err.Error())
}
tx.Commit()