|
|
@@ -69,6 +69,22 @@ func (s Service) SettleAccountList(req model.ListReq, info request.UserInfo) ([]
|
|
|
|
|
|
// 新增结算明细主表、明细子表
|
|
|
func (s Service) AddCountMainDetail(mobAppoint account.AppointInfoReq) error {
|
|
|
+ contractBreach := 1.0
|
|
|
+ paymentType := 1
|
|
|
+ // TODO 如果是已取消预约,则计算违约费用
|
|
|
+ if mobAppoint.Appointment.Appoint.Status == 4 {
|
|
|
+ contractBreachEntity := model.ContractBreach{}
|
|
|
+ // 计算取消时间与实验开始时间差,选择相应违约规则
|
|
|
+ startTime := mobAppoint.Appointment.Appoint.StartTime
|
|
|
+ cancelTime := mobAppoint.Appointment.Appoint.UpdateAt
|
|
|
+ totalMinute := (startTime.Hour()-cancelTime.Hour())*60 + (startTime.Minute() - cancelTime.Minute())
|
|
|
+ if err := s.Dao.DB.Model("contract_breach").
|
|
|
+ Where("MinPoint <= ? and MaxPoint >= ?", totalMinute, totalMinute).Scan(&contractBreachEntity); err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ contractBreach = contractBreachEntity.Persent
|
|
|
+ paymentType = 2
|
|
|
+ }
|
|
|
// 通过设备、用户查询优惠状态
|
|
|
var result account.AppointInfo
|
|
|
isDiscount := false
|
|
|
@@ -104,7 +120,7 @@ func (s Service) AddCountMainDetail(mobAppoint account.AppointInfoReq) error {
|
|
|
"AppointUserId": mobAppoint.Appointment.User.Id,
|
|
|
"AppointUser": mobAppoint.Appointment.User.Realname,
|
|
|
"SettleStatus": 1,
|
|
|
- "TotalPrice": totalPrice,
|
|
|
+ "TotalPrice": totalPrice * contractBreach,
|
|
|
"CreateUserId": mobAppoint.Appointment.User.Id,
|
|
|
"CreateBy": mobAppoint.Appointment.User.Realname,
|
|
|
"CreateOn": now,
|
|
|
@@ -119,8 +135,8 @@ func (s Service) AddCountMainDetail(mobAppoint account.AppointInfoReq) error {
|
|
|
"pid": id,
|
|
|
"UnitPrice": unitCount,
|
|
|
"Minutes": totalMinutes,
|
|
|
- "PaymentType": 1,
|
|
|
- "PaymentAccount": 1,
|
|
|
+ "PaymentType": paymentType,
|
|
|
+ "PaymentAccount": totalPrice * contractBreach,
|
|
|
"CreateUserId": mobAppoint.Appointment.User.Id,
|
|
|
"CreateBy": mobAppoint.Appointment.User.Realname,
|
|
|
"CreateOn": now,
|