| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- package settle_account_detail
- import (
- "database/sql"
- "fmt"
- "github.com/gogf/gf/util/gconv"
- "lims_adapter/dao/account"
- "lims_adapter/model"
- accountModel "lims_adapter/model/account"
- )
- // Service 会议室服务
- type Service struct {
- Dao *account.SettleAccountDetailDao
- Tenant string
- }
- // NewSrv 服务初始化
- func NewService(tenant string) Service {
- return Service{Dao: account.NewSettleAccountDetailDao(tenant), Tenant: tenant}
- }
- // List 获取数据列表
- func (s Service) List(req model.ListReq) ([]accountModel.SettleAccountDetail, error) {
- entityModel := s.Dao.M
- where := "(PaymentAccount>0 OR Data4='机器被占用,取消不扣费')" // 费用大于0,或者非自身原因的取消操作
- if req.Entity != nil {
- entity := new(accountModel.SettleAccountDetailReq)
- err := gconv.Struct(req.Entity, entity)
- if err != nil {
- return nil, err
- }
- if entity.MainUserId != 0 {
- where += fmt.Sprintf(" AND MainUserId='%v'", entity.MainUserId)
- }
- if entity.AttachUserId != 0 {
- where += fmt.Sprintf(" AND AttachUserId='%v'", entity.AttachUserId)
- }
- if entity.Pid != 0 {
- where += fmt.Sprintf(" AND pid='%v'", entity.Pid)
- }
- }
- entityModel = entityModel.Where(where)
- res, err := entityModel.Fields("settle_account_detail.*").FindAll()
- if err != nil {
- return nil, err
- }
- list := make([]accountModel.SettleAccountDetail, 0)
- err = res.Structs(&list)
- if err != nil && err != sql.ErrNoRows {
- return nil, err
- }
- return list, nil
- }
|