|
|
@@ -27,7 +27,7 @@ func NewService(tenant string) Service {
|
|
|
}
|
|
|
|
|
|
// List 结算明细
|
|
|
-func (s Service) List(req model.ListReq, user request.UserInfo) ([]accountModel.SettleAccountMain, int, error) {
|
|
|
+func (s Service) List(req model.ListReq, user request.UserInfo) ([]accountModel.MainInfo, int, error) {
|
|
|
entityModel := s.Dao.M
|
|
|
where := "1=1"
|
|
|
|
|
|
@@ -122,12 +122,41 @@ func (s Service) List(req model.ListReq, user request.UserInfo) ([]accountModel.
|
|
|
return nil, 0, nil
|
|
|
}
|
|
|
|
|
|
- list := make([]accountModel.SettleAccountMain, 0)
|
|
|
+ list := make([]accountModel.MainInfo, 0)
|
|
|
err = res.Structs(&list)
|
|
|
if err != nil {
|
|
|
return nil, 0, err
|
|
|
}
|
|
|
|
|
|
+ var appoints []accountModel.SearchEntity
|
|
|
+ appointMap := make(map[int]accountModel.SearchEntity, 0)
|
|
|
+
|
|
|
+ ids := "-1"
|
|
|
+ for _, item := range list {
|
|
|
+ ids += fmt.Sprintf(",%v", item.AppointId)
|
|
|
+ }
|
|
|
+ res, err = s.Dao.DB.Model("appointment").Where(fmt.Sprintf("Id IN (%v)", ids)).FindAll()
|
|
|
+ if err != nil {
|
|
|
+ return nil, 0, err
|
|
|
+ }
|
|
|
+ err = res.Structs(&appoints)
|
|
|
+ if err != nil {
|
|
|
+ if err == sql.ErrNoRows {
|
|
|
+ return list, total, nil
|
|
|
+ }
|
|
|
+ return list, total, err
|
|
|
+ }
|
|
|
+ for _, item := range appoints {
|
|
|
+ appointMap[item.Id] = item
|
|
|
+ }
|
|
|
+
|
|
|
+ for index, item := range list {
|
|
|
+ if appointMap[item.AppointId].Id != 0 {
|
|
|
+ list[index].SignInTime = appointMap[item.AppointId].SignInTime
|
|
|
+ list[index].SignOutTime = appointMap[item.AppointId].SignOutTime
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return list, total, nil
|
|
|
}
|
|
|
|
|
|
@@ -334,6 +363,8 @@ func (s Service) Cancel(req accountModel.AccountMainCancelReq) error {
|
|
|
oldAmount := main.TotalPrice
|
|
|
main.TotalPrice = detail.PaymentAccount
|
|
|
diffValue := oldAmount - detail.PaymentAccount
|
|
|
+ main.ActualStartDate = nil
|
|
|
+ main.ActualEndDate = nil
|
|
|
|
|
|
baseAccount.Available += diffValue // 账户可用金额返还
|
|
|
|