|
|
@@ -9,6 +9,7 @@ import (
|
|
|
"lims_adapter/dao/account"
|
|
|
"lims_adapter/model"
|
|
|
accountModel "lims_adapter/model/account"
|
|
|
+ "math"
|
|
|
"strconv"
|
|
|
)
|
|
|
|
|
|
@@ -112,6 +113,11 @@ func (s Service) Add(req accountModel.AccountMainAddReq, user request.UserInfo)
|
|
|
req.Main.UpdateUserId = int(user.Id)
|
|
|
req.Main.UpdateBy = user.RealName
|
|
|
req.Main.UpdateOn = now
|
|
|
+ req.Main.ActualStartDate = req.Main.AppointStartDate
|
|
|
+ req.Main.ActualEndDate = req.Main.AppointEndDate
|
|
|
+ span := req.Main.ActualEndDate.Sub(req.Main.ActualStartDate)
|
|
|
+ req.Main.FeeTime = int(math.Ceil(span.Minutes()))
|
|
|
+ req.Main.ActualMachineHour = req.Main.FeeTime
|
|
|
|
|
|
// 获取账户
|
|
|
result1, err := s.Dao.DB.Model("base_account").Where(fmt.Sprintf("MainUserId='%v'", req.Main.MainUserId)).Order("Advance ASC").FindOne()
|
|
|
@@ -144,6 +150,19 @@ func (s Service) Add(req accountModel.AccountMainAddReq, user request.UserInfo)
|
|
|
req.Details[index].UpdateBy = user.RealName
|
|
|
req.Details[index].UpdateOn = now
|
|
|
req.Details[index].Pid = int(id)
|
|
|
+ if req.Details[index].PaymentType == "0" {
|
|
|
+ req.Details[index].ActualMinutes = strconv.Itoa(req.Main.ActualMachineHour)
|
|
|
+ req.Details[index].Minutes = strconv.Itoa(req.Main.ActualMachineHour)
|
|
|
+
|
|
|
+ discount := float64(1) // 计算折扣
|
|
|
+ if req.Details[index].Data5 != "" {
|
|
|
+ d, _ := strconv.ParseFloat(req.Details[index].Data5, 64)
|
|
|
+ discount = 1 - d / 100
|
|
|
+ }
|
|
|
+
|
|
|
+ req.Details[index].PaymentAccount = float64(req.Main.ActualMachineHour) * req.Details[index].UnitPrice * discount / 60 // 计算实际费用
|
|
|
+ }
|
|
|
+ req.Main.TotalPrice += req.Details[index].PaymentAccount
|
|
|
}
|
|
|
_, err = tx.Insert("settle_account_detail", req.Details)
|
|
|
if err != nil {
|
|
|
@@ -171,7 +190,7 @@ func (s Service) Confirm(req accountModel.AccountMainConfirmReq, user request.Us
|
|
|
}
|
|
|
|
|
|
// 预约取消
|
|
|
-func (s Service) Cancel(req accountModel.AccountMainCancelReq, user request.UserInfo) error {
|
|
|
+func (s Service) Cancel(req accountModel.AccountMainCancelReq) error {
|
|
|
if req.AppointId == 0 {
|
|
|
return errors.New("参数缺失")
|
|
|
}
|