作者 yangfu

Merge branch 'dev' of http://gitlab.fjmaimaimai.com/allied-creation/allied-creat…

…ion-cooperation into dev
@@ -13,6 +13,7 @@ require ( @@ -13,6 +13,7 @@ require (
13 github.com/google/go-querystring v1.1.0 // indirect 13 github.com/google/go-querystring v1.1.0 // indirect
14 github.com/gorilla/websocket v1.4.2 // indirect 14 github.com/gorilla/websocket v1.4.2 // indirect
15 github.com/imkira/go-interpol v1.1.0 // indirect 15 github.com/imkira/go-interpol v1.1.0 // indirect
  16 + github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 // indirect
16 github.com/linmadan/egglib-go v0.0.0-20210527091316-06b0732fb5f6 17 github.com/linmadan/egglib-go v0.0.0-20210527091316-06b0732fb5f6
17 github.com/mattn/go-colorable v0.1.8 // indirect 18 github.com/mattn/go-colorable v0.1.8 // indirect
18 github.com/moul/http2curl v1.0.0 // indirect 19 github.com/moul/http2curl v1.0.0 // indirect
@@ -138,6 +138,8 @@ github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/ @@ -138,6 +138,8 @@ github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/
138 github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= 138 github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
139 github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= 139 github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
140 github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= 140 github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
  141 +github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 h1:uC1QfSlInpQF+M0ao65imhwqKnz3Q2z/d8PWZRMQvDM=
  142 +github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k=
141 github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= 143 github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
142 github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= 144 github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
143 github.com/klauspost/compress v1.9.7/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= 145 github.com/klauspost/compress v1.9.7/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
@@ -11,6 +11,7 @@ import ( @@ -11,6 +11,7 @@ import (
11 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" 11 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
12 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service" 12 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
13 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/dao" 13 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/dao"
  14 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
14 "strconv" 15 "strconv"
15 "time" 16 "time"
16 ) 17 )
@@ -529,42 +530,43 @@ func (cooperationProjectService *CooperationProjectService) BatchEndCooperationP @@ -529,42 +530,43 @@ func (cooperationProjectService *CooperationProjectService) BatchEndCooperationP
529 }() 530 }()
530 531
531 // 共创项目仓储初始化 532 // 共创项目仓储初始化
532 - //var cooperationProjectRepository domain.CooperationProjectRepository  
533 - //if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{  
534 - // "transactionContext": transactionContext,  
535 - //}); err != nil {  
536 - // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
537 - //} else {  
538 - // cooperationProjectRepository = value  
539 - //} 533 + var cooperationProjectRepository domain.CooperationProjectRepository
  534 + if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
  535 + "transactionContext": transactionContext,
  536 + }); err != nil {
  537 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  538 + } else {
  539 + cooperationProjectRepository = value
  540 + }
540 541
541 // 转换共创项目ID列表类型 542 // 转换共创项目ID列表类型
542 - //cooperationProjectIds, err := utils.SliceAtoi(batchEndCooperationProjectCommand.CooperationProjectIds)  
543 - //if err != nil {  
544 - // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
545 - //}  
546 -  
547 - //cooperationProject, err := cooperationProjectRepository.FindOne(map[string]interface{}{"cooperationProjectId": batchEndCooperationProjectCommand.CooperationProjectId})  
548 - //if err != nil {  
549 - // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
550 - //}  
551 - //if cooperationProject == nil {  
552 - // return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(batchEndCooperationProjectCommand.CooperationProjectId)))  
553 - //}  
554 -  
555 - //if err := cooperationProject.Update(tool_funs.SimpleStructToMap(batchEndCooperationProjectCommand)); err != nil {  
556 - // return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())  
557 - //}  
558 - //  
559 - //if cooperationProject, err := cooperationProjectRepository.Save(cooperationProject); err != nil {  
560 - // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
561 - //} else {  
562 - // if err := transactionContext.CommitTransaction(); err != nil {  
563 - // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
564 - // }  
565 - // return cooperationProject, nil  
566 - //}  
567 - return nil, nil 543 + cooperationProjectIds, err := utils.SliceAtoi(batchEndCooperationProjectCommand.CooperationProjectIds)
  544 + if err != nil {
  545 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  546 + }
  547 + if count, cooperationProjects, err := cooperationProjectRepository.Find(map[string]interface{}{
  548 + "cooperationProjectIds": cooperationProjectIds,
  549 + }); err != nil {
  550 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  551 + } else {
  552 + if count > 0 {
  553 + for i, _ := range cooperationProjects {
  554 + cooperationProjects[i].Status = 2
  555 + }
  556 + cooperationProjectsEnded, err := cooperationProjectRepository.UpdateMany(cooperationProjects)
  557 + if err != nil {
  558 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  559 + }
  560 + if err := transactionContext.CommitTransaction(); err != nil {
  561 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  562 + }
  563 + return map[string]interface{}{
  564 + "cooperationProjects": cooperationProjectsEnded,
  565 + }, nil
  566 + } else {
  567 + return map[string]interface{}{}, nil
  568 + }
  569 + }
568 } 570 }
569 571
570 func NewCooperationProjectService(options map[string]interface{}) *CooperationProjectService { 572 func NewCooperationProjectService(options map[string]interface{}) *CooperationProjectService {
@@ -46,6 +46,7 @@ type CooperationProject struct { @@ -46,6 +46,7 @@ type CooperationProject struct {
46 46
47 type CooperationProjectRepository interface { 47 type CooperationProjectRepository interface {
48 Save(cooperationProject *CooperationProject) (*CooperationProject, error) 48 Save(cooperationProject *CooperationProject) (*CooperationProject, error)
  49 + UpdateMany(cooperationProjects []*CooperationProject) ([]*CooperationProject, error)
49 Remove(cooperationProject *CooperationProject) (*CooperationProject, error) 50 Remove(cooperationProject *CooperationProject) (*CooperationProject, error)
50 FindOne(queryOptions map[string]interface{}) (*CooperationProject, error) 51 FindOne(queryOptions map[string]interface{}) (*CooperationProject, error)
51 Find(queryOptions map[string]interface{}) (int64, []*CooperationProject, error) 52 Find(queryOptions map[string]interface{}) (int64, []*CooperationProject, error)
@@ -234,6 +234,9 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string @@ -234,6 +234,9 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string
234 if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 { 234 if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
235 query.Where("org->>'orgId' = '?'", orgId) 235 query.Where("org->>'orgId' = '?'", orgId)
236 } 236 }
  237 + if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
  238 + query.Where("org->>'orgId' in (?)", pg.In(orgIds))
  239 + }
237 offsetLimitFlag := true 240 offsetLimitFlag := true
238 if offsetLimit, ok := queryOptions["offsetLimit"]; ok { 241 if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
239 offsetLimitFlag = offsetLimit.(bool) 242 offsetLimitFlag = offsetLimit.(bool)
@@ -155,6 +155,15 @@ func (repository *CooperationContractChangeLogRepository) Find(queryOptions map[ @@ -155,6 +155,15 @@ func (repository *CooperationContractChangeLogRepository) Find(queryOptions map[
155 if offsetLimit, ok := queryOptions["offsetLimit"]; ok { 155 if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
156 offsetLimitFlag = offsetLimit.(bool) 156 offsetLimitFlag = offsetLimit.(bool)
157 } 157 }
  158 + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
  159 + query.Where("company->>'companyId' = '?'", companyId)
  160 + }
  161 + if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
  162 + query.Where("org->>'orgId' = '?'", orgId)
  163 + }
  164 + if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
  165 + query.Where("org->>'orgId' in (?)", pg.In(orgIds))
  166 + }
158 if offsetLimitFlag { 167 if offsetLimitFlag {
159 query.SetOffsetAndLimit(20) 168 query.SetOffsetAndLimit(20)
160 } 169 }
@@ -170,6 +170,15 @@ func (repository *CooperationContractRelevantRepository) Find(queryOptions map[s @@ -170,6 +170,15 @@ func (repository *CooperationContractRelevantRepository) Find(queryOptions map[s
170 var cooperationContractRelevantModels []*models.CooperationContractRelevant 170 var cooperationContractRelevantModels []*models.CooperationContractRelevant
171 cooperationContractRelevants := make([]*domain.CooperationContractRelevant, 0) 171 cooperationContractRelevants := make([]*domain.CooperationContractRelevant, 0)
172 query := sqlbuilder.BuildQuery(tx.Model(&cooperationContractRelevantModels), queryOptions) 172 query := sqlbuilder.BuildQuery(tx.Model(&cooperationContractRelevantModels), queryOptions)
  173 + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
  174 + query.Where("company->>'companyId' = '?'", companyId)
  175 + }
  176 + if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
  177 + query.Where("org->>'orgId' = '?'", orgId)
  178 + }
  179 + if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
  180 + query.Where("org->>'orgId' in (?)", pg.In(orgIds))
  181 + }
173 offsetLimitFlag := true 182 offsetLimitFlag := true
174 if offsetLimit, ok := queryOptions["offsetLimit"]; ok { 183 if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
175 offsetLimitFlag = offsetLimit.(bool) 184 offsetLimitFlag = offsetLimit.(bool)
@@ -647,7 +647,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai @@ -647,7 +647,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
647 } 647 }
648 // 返回新增的合约 648 // 返回新增的合约
649 cooperationContractSaved, err := repository.FindOne(map[string]interface{}{ 649 cooperationContractSaved, err := repository.FindOne(map[string]interface{}{
650 - "cooperationContractId":cooperationContract.CooperationContractId, 650 + "cooperationContractId": cooperationContract.CooperationContractId,
651 }) 651 })
652 if err != nil { 652 if err != nil {
653 return nil, err 653 return nil, err
@@ -910,6 +910,9 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in @@ -910,6 +910,9 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in
910 if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 { 910 if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
911 query.Where("org->>'orgId' = '?'", orgId) 911 query.Where("org->>'orgId' = '?'", orgId)
912 } 912 }
  913 + if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
  914 + query.Where("org->>'orgId' in (?)", pg.In(orgIds))
  915 + }
913 if incentivesType, ok := queryOptions["incentivesType"]; ok && incentivesType.(int32) != 0 { 916 if incentivesType, ok := queryOptions["incentivesType"]; ok && incentivesType.(int32) != 0 {
914 query.Where("incentives_type = ?", incentivesType) 917 query.Where("incentives_type = ?", incentivesType)
915 } 918 }
@@ -181,6 +181,15 @@ func (repository *CooperationContractUndertakerRepository) Find(queryOptions map @@ -181,6 +181,15 @@ func (repository *CooperationContractUndertakerRepository) Find(queryOptions map
181 var cooperationContractUndertakerModels []*models.CooperationContractUndertaker 181 var cooperationContractUndertakerModels []*models.CooperationContractUndertaker
182 cooperationContractUndertakers := make([]*domain.CooperationContractUndertaker, 0) 182 cooperationContractUndertakers := make([]*domain.CooperationContractUndertaker, 0)
183 query := sqlbuilder.BuildQuery(tx.Model(&cooperationContractUndertakerModels), queryOptions) 183 query := sqlbuilder.BuildQuery(tx.Model(&cooperationContractUndertakerModels), queryOptions)
  184 + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
  185 + query.Where("company->>'companyId' = '?'", companyId)
  186 + }
  187 + if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
  188 + query.Where("org->>'orgId' = '?'", orgId)
  189 + }
  190 + if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
  191 + query.Where("org->>'orgId' in (?)", pg.In(orgIds))
  192 + }
184 offsetLimitFlag := true 193 offsetLimitFlag := true
185 if offsetLimit, ok := queryOptions["offsetLimit"]; ok { 194 if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
186 offsetLimitFlag = offsetLimit.(bool) 195 offsetLimitFlag = offsetLimit.(bool)
@@ -178,6 +178,15 @@ func (repository *CooperationModeRepository) Find(queryOptions map[string]interf @@ -178,6 +178,15 @@ func (repository *CooperationModeRepository) Find(queryOptions map[string]interf
178 if organizationName, ok := queryOptions["organizationName"]; ok && organizationName != "" { 178 if organizationName, ok := queryOptions["organizationName"]; ok && organizationName != "" {
179 query.Where("org->>'orgName' like ?", fmt.Sprintf("%%%s%%", organizationName)) 179 query.Where("org->>'orgName' like ?", fmt.Sprintf("%%%s%%", organizationName))
180 } 180 }
  181 + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
  182 + query.Where("company->>'companyId' = '?'", companyId)
  183 + }
  184 + if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
  185 + query.Where("org->>'orgId' = '?'", orgId)
  186 + }
  187 + if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
  188 + query.Where("org->>'orgId' in (?)", pg.In(orgIds))
  189 + }
181 offsetLimitFlag := true 190 offsetLimitFlag := true
182 if offsetLimit, ok := queryOptions["offsetLimit"]; ok { 191 if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
183 offsetLimitFlag = offsetLimit.(bool) 192 offsetLimitFlag = offsetLimit.(bool)
@@ -3,6 +3,7 @@ package repository @@ -3,6 +3,7 @@ package repository
3 import ( 3 import (
4 "fmt" 4 "fmt"
5 "github.com/go-pg/pg/v10" 5 "github.com/go-pg/pg/v10"
  6 + "time"
6 7
7 "github.com/linmadan/egglib-go/persistent/pg/sqlbuilder" 8 "github.com/linmadan/egglib-go/persistent/pg/sqlbuilder"
8 pgTransaction "github.com/linmadan/egglib-go/transaction/pg" 9 pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
@@ -156,6 +157,38 @@ func (repository *CooperationProjectRepository) Save(cooperationProject *domain. @@ -156,6 +157,38 @@ func (repository *CooperationProjectRepository) Save(cooperationProject *domain.
156 return cooperationProject, nil 157 return cooperationProject, nil
157 } 158 }
158 159
  160 +func (repository *CooperationProjectRepository) UpdateMany(cooperationProjects []*domain.CooperationProject) ([]*domain.CooperationProject, error) {
  161 + tx := repository.transactionContext.PgTx
  162 + var cooperationProjectModels []*models.CooperationProject
  163 + for _, cooperationProject := range cooperationProjects {
  164 + cooperationProjectModels = append(cooperationProjectModels, &models.CooperationProject{
  165 + CooperationProjectId: cooperationProject.CooperationProjectId,
  166 + CooperationProjectNumber: cooperationProject.CooperationProjectNumber,
  167 + CooperationProjectDescription: cooperationProject.CooperationProjectDescription,
  168 + CooperationProjectName: cooperationProject.CooperationProjectName,
  169 + CooperationProjectPublishTime: cooperationProject.CooperationProjectPublishTime,
  170 + CooperationProjectPublisher: cooperationProject.CooperationProjectPublisher,
  171 + CooperationProjectSponsor: cooperationProject.CooperationProjectSponsor,
  172 + CooperationModeNumber: cooperationProject.CooperationProjectNumber,
  173 + Department: cooperationProject.Department,
  174 + CooperationProjectUndertakerTypes: cooperationProject.CooperationProjectUndertakerTypes,
  175 + Attachment: cooperationProject.Attachment,
  176 + Org: cooperationProject.Org,
  177 + Company: cooperationProject.Company,
  178 + Operator: cooperationProject.Operator,
  179 + OperateTime: time.Now(),
  180 + Status: cooperationProject.Status,
  181 + UpdatedAt: time.Now(),
  182 + DeletedAt: cooperationProject.DeletedAt,
  183 + CreatedAt: cooperationProject.CreatedAt,
  184 + })
  185 + }
  186 + if _, err := tx.Model(&cooperationProjectModels).WherePK().Update(); err != nil {
  187 + return nil, err
  188 + }
  189 + return cooperationProjects, nil
  190 +}
  191 +
159 func (repository *CooperationProjectRepository) Remove(cooperationProject *domain.CooperationProject) (*domain.CooperationProject, error) { 192 func (repository *CooperationProjectRepository) Remove(cooperationProject *domain.CooperationProject) (*domain.CooperationProject, error) {
160 tx := repository.transactionContext.PgTx 193 tx := repository.transactionContext.PgTx
161 cooperationProjectModel := new(models.CooperationProject) 194 cooperationProjectModel := new(models.CooperationProject)
@@ -199,6 +232,15 @@ func (repository *CooperationProjectRepository) Find(queryOptions map[string]int @@ -199,6 +232,15 @@ func (repository *CooperationProjectRepository) Find(queryOptions map[string]int
199 var cooperationProjectModels []*models.CooperationProject 232 var cooperationProjectModels []*models.CooperationProject
200 cooperationProjects := make([]*domain.CooperationProject, 0) 233 cooperationProjects := make([]*domain.CooperationProject, 0)
201 query := sqlbuilder.BuildQuery(tx.Model(&cooperationProjectModels), queryOptions) 234 query := sqlbuilder.BuildQuery(tx.Model(&cooperationProjectModels), queryOptions)
  235 + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
  236 + query.Where("company->>'companyId' = '?'", companyId)
  237 + }
  238 + if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
  239 + query.Where("org->>'orgId' = '?'", orgId)
  240 + }
  241 + if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
  242 + query.Where("org->>'orgId' in (?)", pg.In(orgIds))
  243 + }
202 if v, ok := queryOptions["status"]; ok && v.(int32) > 0 { 244 if v, ok := queryOptions["status"]; ok && v.(int32) > 0 {
203 query.Where("status =? ", v) 245 query.Where("status =? ", v)
204 } 246 }
@@ -204,6 +204,15 @@ func (repository *CreditAccountRepository) Find(queryOptions map[string]interfac @@ -204,6 +204,15 @@ func (repository *CreditAccountRepository) Find(queryOptions map[string]interfac
204 if paymentStatus, ok := queryOptions["paymentStatus"]; ok && paymentStatus.(int32) != 0 { 204 if paymentStatus, ok := queryOptions["paymentStatus"]; ok && paymentStatus.(int32) != 0 {
205 query.Where("payment_status = ?", paymentStatus) 205 query.Where("payment_status = ?", paymentStatus)
206 } 206 }
  207 + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
  208 + query.Where("company->>'companyId' = '?'", companyId)
  209 + }
  210 + if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
  211 + query.Where("org->>'orgId' = '?'", orgId)
  212 + }
  213 + if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
  214 + query.Where("org->>'orgId' in (?)", pg.In(orgIds))
  215 + }
207 offsetLimitFlag := true 216 offsetLimitFlag := true
208 if offsetLimit, ok := queryOptions["offsetLimit"]; ok { 217 if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
209 offsetLimitFlag = offsetLimit.(bool) 218 offsetLimitFlag = offsetLimit.(bool)
@@ -286,6 +286,15 @@ func (repository *DividendsEstimateRepository) Find(queryOptions map[string]inte @@ -286,6 +286,15 @@ func (repository *DividendsEstimateRepository) Find(queryOptions map[string]inte
286 if dividendsEstimateIds, ok := queryOptions["dividendsEstimateIds"]; ok && len(dividendsEstimateIds.([]int64)) > 0 { 286 if dividendsEstimateIds, ok := queryOptions["dividendsEstimateIds"]; ok && len(dividendsEstimateIds.([]int64)) > 0 {
287 query.Where("dividends_estimate_id IN (?)", pg.In(dividendsEstimateIds)) 287 query.Where("dividends_estimate_id IN (?)", pg.In(dividendsEstimateIds))
288 } 288 }
  289 + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
  290 + query.Where("company->>'companyId' = '?'", companyId)
  291 + }
  292 + if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
  293 + query.Where("org->>'orgId' = '?'", orgId)
  294 + }
  295 + if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
  296 + query.Where("org->>'orgId' in (?)", pg.In(orgIds))
  297 + }
289 offsetLimitFlag := true 298 offsetLimitFlag := true
290 if offsetLimit, ok := queryOptions["offsetLimit"]; ok { 299 if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
291 offsetLimitFlag = offsetLimit.(bool) 300 offsetLimitFlag = offsetLimit.(bool)
@@ -165,6 +165,15 @@ func (repository *DividendsIncentivesRuleRepository) Find(queryOptions map[strin @@ -165,6 +165,15 @@ func (repository *DividendsIncentivesRuleRepository) Find(queryOptions map[strin
165 var dividendsIncentivesRuleModels []*models.DividendsIncentivesRule 165 var dividendsIncentivesRuleModels []*models.DividendsIncentivesRule
166 dividendsIncentivesRules := make([]*domain.DividendsIncentivesRule, 0) 166 dividendsIncentivesRules := make([]*domain.DividendsIncentivesRule, 0)
167 query := sqlbuilder.BuildQuery(tx.Model(&dividendsIncentivesRuleModels), queryOptions) 167 query := sqlbuilder.BuildQuery(tx.Model(&dividendsIncentivesRuleModels), queryOptions)
  168 + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
  169 + query.Where("company->>'companyId' = '?'", companyId)
  170 + }
  171 + if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
  172 + query.Where("org->>'orgId' = '?'", orgId)
  173 + }
  174 + if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
  175 + query.Where("org->>'orgId' in (?)", pg.In(orgIds))
  176 + }
168 offsetLimitFlag := true 177 offsetLimitFlag := true
169 if offsetLimit, ok := queryOptions["offsetLimit"]; ok { 178 if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
170 offsetLimitFlag = offsetLimit.(bool) 179 offsetLimitFlag = offsetLimit.(bool)
@@ -330,6 +330,15 @@ func (repository *DividendsOrderRepository) Find(queryOptions map[string]interfa @@ -330,6 +330,15 @@ func (repository *DividendsOrderRepository) Find(queryOptions map[string]interfa
330 if dividendsOrderIds, ok := queryOptions["dividendsOrderIds"]; ok && len(dividendsOrderIds.([]int64)) > 0 { 330 if dividendsOrderIds, ok := queryOptions["dividendsOrderIds"]; ok && len(dividendsOrderIds.([]int64)) > 0 {
331 query.Where("dividends_order_id IN (?)", pg.In(dividendsOrderIds.([]int64))) 331 query.Where("dividends_order_id IN (?)", pg.In(dividendsOrderIds.([]int64)))
332 } 332 }
  333 + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
  334 + query.Where("company->>'companyId' = '?'", companyId)
  335 + }
  336 + if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
  337 + query.Where("org->>'orgId' = '?'", orgId)
  338 + }
  339 + if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
  340 + query.Where("org->>'orgId' in (?)", pg.In(orgIds))
  341 + }
333 offsetLimitFlag := true 342 offsetLimitFlag := true
334 if offsetLimit, ok := queryOptions["offsetLimit"]; ok { 343 if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
335 offsetLimitFlag = offsetLimit.(bool) 344 offsetLimitFlag = offsetLimit.(bool)
@@ -342,6 +342,15 @@ func (repository *DividendsReturnedOrderRepository) Find(queryOptions map[string @@ -342,6 +342,15 @@ func (repository *DividendsReturnedOrderRepository) Find(queryOptions map[string
342 if dividendsReturnedCustomerName, ok := queryOptions["dividendsReturnedCustomerName"]; ok && dividendsReturnedCustomerName != "" { 342 if dividendsReturnedCustomerName, ok := queryOptions["dividendsReturnedCustomerName"]; ok && dividendsReturnedCustomerName != "" {
343 query.Where("dividends_returned_customer_name like ?", fmt.Sprintf("%%%s%%", dividendsReturnedCustomerName)) 343 query.Where("dividends_returned_customer_name like ?", fmt.Sprintf("%%%s%%", dividendsReturnedCustomerName))
344 } 344 }
  345 + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
  346 + query.Where("company->>'companyId' = '?'", companyId)
  347 + }
  348 + if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
  349 + query.Where("org->>'orgId' = '?'", orgId)
  350 + }
  351 + if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
  352 + query.Where("org->>'orgId' in (?)", pg.In(orgIds))
  353 + }
345 offsetLimitFlag := true 354 offsetLimitFlag := true
346 if offsetLimit, ok := queryOptions["offsetLimit"]; ok { 355 if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
347 offsetLimitFlag = offsetLimit.(bool) 356 offsetLimitFlag = offsetLimit.(bool)
@@ -165,6 +165,15 @@ func (repository *MoneyIncentivesRuleRepository) Find(queryOptions map[string]in @@ -165,6 +165,15 @@ func (repository *MoneyIncentivesRuleRepository) Find(queryOptions map[string]in
165 var moneyIncentivesRuleModels []*models.MoneyIncentivesRule 165 var moneyIncentivesRuleModels []*models.MoneyIncentivesRule
166 moneyIncentivesRules := make([]*domain.MoneyIncentivesRule, 0) 166 moneyIncentivesRules := make([]*domain.MoneyIncentivesRule, 0)
167 query := sqlbuilder.BuildQuery(tx.Model(&moneyIncentivesRuleModels), queryOptions) 167 query := sqlbuilder.BuildQuery(tx.Model(&moneyIncentivesRuleModels), queryOptions)
  168 + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
  169 + query.Where("company->>'companyId' = '?'", companyId)
  170 + }
  171 + if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
  172 + query.Where("org->>'orgId' = '?'", orgId)
  173 + }
  174 + if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
  175 + query.Where("org->>'orgId' in (?)", pg.In(orgIds))
  176 + }
168 offsetLimitFlag := true 177 offsetLimitFlag := true
169 if offsetLimit, ok := queryOptions["offsetLimit"]; ok { 178 if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
170 offsetLimitFlag = offsetLimit.(bool) 179 offsetLimitFlag = offsetLimit.(bool)
@@ -178,6 +178,15 @@ func (repository *OrderGoodRepository) Find(queryOptions map[string]interface{}) @@ -178,6 +178,15 @@ func (repository *OrderGoodRepository) Find(queryOptions map[string]interface{})
178 if orderGoodIds, ok := queryOptions["orderGoodIds"]; ok && len(orderGoodIds.([]int64)) > 0 { 178 if orderGoodIds, ok := queryOptions["orderGoodIds"]; ok && len(orderGoodIds.([]int64)) > 0 {
179 query.Where("order_good_id IN (?)", pg.In(orderGoodIds)) 179 query.Where("order_good_id IN (?)", pg.In(orderGoodIds))
180 } 180 }
  181 + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
  182 + query.Where("company->>'companyId' = '?'", companyId)
  183 + }
  184 + if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
  185 + query.Where("org->>'orgId' = '?'", orgId)
  186 + }
  187 + if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
  188 + query.Where("org->>'orgId' in (?)", pg.In(orgIds))
  189 + }
181 offsetLimitFlag := true 190 offsetLimitFlag := true
182 if offsetLimit, ok := queryOptions["offsetLimit"]; ok { 191 if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
183 offsetLimitFlag = offsetLimit.(bool) 192 offsetLimitFlag = offsetLimit.(bool)