|
|
@@ -0,0 +1,76 @@
|
|
|
+package settle_account_main
|
|
|
+
|
|
|
+import (
|
|
|
+ "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.SettleAccountMainDao
|
|
|
+ Tenant string
|
|
|
+}
|
|
|
+
|
|
|
+// NewSrv 服务初始化
|
|
|
+func NewService(tenant string) Service {
|
|
|
+ return Service{Dao: account.NewSettleAccountMainDao(tenant), Tenant: tenant}
|
|
|
+}
|
|
|
+
|
|
|
+// List 会议室列表
|
|
|
+func (s Service) List(req model.ListReq) ([]accountModel.SettleAccountMain, int, error) {
|
|
|
+ entityModel := s.Dao.M
|
|
|
+ where := "1=1"
|
|
|
+
|
|
|
+ if req.Entity != nil {
|
|
|
+ entity := new(accountModel.SettleAccountMainReq)
|
|
|
+ err := gconv.Struct(req.Entity, entity)
|
|
|
+ if err != nil {
|
|
|
+ return nil, 0, 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.InstrumentId != 0 {
|
|
|
+ where += fmt.Sprintf(" AND InstrumentId='%v'", entity.InstrumentId)
|
|
|
+ }
|
|
|
+ if entity.Status != "" {
|
|
|
+ where += fmt.Sprintf(" AND Status='%v'", entity.Status)
|
|
|
+ }
|
|
|
+ if entity.SettleStatus != "" {
|
|
|
+ where += fmt.Sprintf(" AND SettleStatus='%v'", entity.SettleStatus)
|
|
|
+ }
|
|
|
+ if entity.FeeType != "" {
|
|
|
+ where += fmt.Sprintf(" AND FeeType='%v'", entity.FeeType)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ entityModel = entityModel.Where(where)
|
|
|
+ total, err := entityModel.Count()
|
|
|
+ if err != nil {
|
|
|
+ return nil, 0, err
|
|
|
+ }
|
|
|
+ if total == 0 {
|
|
|
+ return nil, 0, nil
|
|
|
+ }
|
|
|
+
|
|
|
+ res, err := entityModel.Page(req.Current, req.Size).Order("settle_account_main.CreateOn DESC").Fields("settle_account_main.*").FindAll()
|
|
|
+ if err != nil {
|
|
|
+ return nil, 0, err
|
|
|
+ }
|
|
|
+ if res.IsEmpty() {
|
|
|
+ return nil, 0, nil
|
|
|
+ }
|
|
|
+
|
|
|
+ list := make([]accountModel.SettleAccountMain, 0)
|
|
|
+ err = res.Structs(&list)
|
|
|
+ if err != nil {
|
|
|
+ return nil, 0, err
|
|
|
+ }
|
|
|
+
|
|
|
+ return list, total, nil
|
|
|
+}
|