作者 陈志颖

Merge branch 'dev-chenzhiying' into dev

  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 + "github.com/beego/beego/v2/core/validation"
  6 + "reflect"
  7 + "strings"
  8 +)
  9 +
  10 +type CancelCooperationApplicationCommand struct {
  11 + // 共创申请ID
  12 + CooperationApplicationId int64 `cname:"共创申请ID" json:"cooperationApplicationId,string" valid:"Required"`
  13 + // 公司ID,通过集成REST上下文获取
  14 + CompanyId int64 `cname:"公司ID" json:"companyId,string" valid:"Required"`
  15 + // 组织机构id
  16 + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"`
  17 + // 菜单编码,APP端必须
  18 + Code string `cname:"菜单编码" json:"code" valid:"Required"`
  19 + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
  20 + UserId int64 `cname:"用户ID" json:"userId,string" valid:"Required"`
  21 + // 用户基础数据id
  22 + UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId,string" valid:"Required"`
  23 +}
  24 +
  25 +func (cancelCooperationApplicationCommand *CancelCooperationApplicationCommand) Valid(validation *validation.Validation) {
  26 + //validation.SetError("CustomValid", "未实现的自定义认证")
  27 +}
  28 +
  29 +func (cancelCooperationApplicationCommand *CancelCooperationApplicationCommand) ValidateCommand() error {
  30 + valid := validation.Validation{}
  31 + b, err := valid.Valid(cancelCooperationApplicationCommand)
  32 + if err != nil {
  33 + return err
  34 + }
  35 + if !b {
  36 + elem := reflect.TypeOf(cancelCooperationApplicationCommand).Elem()
  37 + for _, validErr := range valid.Errors {
  38 + field, isExist := elem.FieldByName(validErr.Field)
  39 + if isExist {
  40 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  41 + } else {
  42 + return fmt.Errorf(validErr.Message)
  43 + }
  44 + }
  45 + }
  46 + return nil
  47 +}
@@ -424,10 +424,27 @@ func (cooperationApplicationService *CooperationApplicationService) SearchCooper @@ -424,10 +424,27 @@ func (cooperationApplicationService *CooperationApplicationService) SearchCooper
424 defer func() { 424 defer func() {
425 _ = transactionContext.RollbackTransaction() 425 _ = transactionContext.RollbackTransaction()
426 }() 426 }()
427 - if err := transactionContext.CommitTransaction(); err != nil {  
428 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 427 + var cooperationApplicationRepository domain.CooperationApplicationRepository
  428 + if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{
  429 + "transactionContext": transactionContext,
  430 + }); err != nil {
  431 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  432 + } else {
  433 + cooperationApplicationRepository = value
  434 + }
  435 + if count, cooperationApplications, err := cooperationApplicationRepository.Find(tool_funs.SimpleStructToMap(searchCooperationApplicationQuery)); err != nil {
  436 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  437 + } else {
  438 + if err := transactionContext.CommitTransaction(); err != nil {
  439 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  440 + }
  441 + return map[string]interface{}{
  442 + "grid": map[string]interface{}{
  443 + "total": count,
  444 + "list": cooperationApplications,
  445 + },
  446 + }, nil
429 } 447 }
430 - return nil, nil  
431 } 448 }
432 449
433 // UpdateCooperationApplication 更新共创申请服务 450 // UpdateCooperationApplication 更新共创申请服务
@@ -473,6 +490,53 @@ func (cooperationApplicationService *CooperationApplicationService) UpdateCooper @@ -473,6 +490,53 @@ func (cooperationApplicationService *CooperationApplicationService) UpdateCooper
473 } 490 }
474 } 491 }
475 492
  493 +// CancelCooperationApplication 取消共创申请
  494 +func (cooperationApplicationService *CooperationApplicationService) CancelCooperationApplication(cancelCooperationApplicationCommand *command.CancelCooperationApplicationCommand) (interface{}, error) {
  495 + if err := cancelCooperationApplicationCommand.ValidateCommand(); err != nil {
  496 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  497 + }
  498 + transactionContext, err := factory.CreateTransactionContext(nil)
  499 + if err != nil {
  500 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  501 + }
  502 + if err := transactionContext.StartTransaction(); err != nil {
  503 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  504 + }
  505 + defer func() {
  506 + _ = transactionContext.RollbackTransaction()
  507 + }()
  508 + //TODO 校验用户菜单模块权限
  509 +
  510 + var cooperationApplicationRepository domain.CooperationApplicationRepository
  511 + if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{
  512 + "transactionContext": transactionContext,
  513 + }); err != nil {
  514 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  515 + } else {
  516 + cooperationApplicationRepository = value
  517 + }
  518 + cooperationApplication, err := cooperationApplicationRepository.FindOne(map[string]interface{}{"cooperationApplicationId": cancelCooperationApplicationCommand.CooperationApplicationId})
  519 + if err != nil {
  520 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  521 + }
  522 + if cooperationApplication == nil {
  523 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(cancelCooperationApplicationCommand.CooperationApplicationId, 10)))
  524 + }
  525 + if err := cooperationApplication.Update(map[string]interface{}{
  526 + "isCanceled": true,
  527 + }); err != nil {
  528 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  529 + }
  530 + if cooperationApplication, err := cooperationApplicationRepository.Save(cooperationApplication); err != nil {
  531 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  532 + } else {
  533 + if err := transactionContext.CommitTransaction(); err != nil {
  534 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  535 + }
  536 + return cooperationApplication, nil
  537 + }
  538 +}
  539 +
476 func NewCooperationApplicationService(options map[string]interface{}) *CooperationApplicationService { 540 func NewCooperationApplicationService(options map[string]interface{}) *CooperationApplicationService {
477 newCooperationApplicationService := &CooperationApplicationService{} 541 newCooperationApplicationService := &CooperationApplicationService{}
478 return newCooperationApplicationService 542 return newCooperationApplicationService
@@ -13,9 +13,7 @@ type UpdateCooperationContractCommand struct { @@ -13,9 +13,7 @@ type UpdateCooperationContractCommand struct {
13 CooperationContractId string `cname:"共创合约id" json:"cooperationContractId" valid:"Required"` 13 CooperationContractId string `cname:"共创合约id" json:"cooperationContractId" valid:"Required"`
14 // 共创合约描述 14 // 共创合约描述
15 CooperationContractDescription string `cname:"共创合约描述" json:"cooperationContractDescription" valid:"Required"` 15 CooperationContractDescription string `cname:"共创合约描述" json:"cooperationContractDescription" valid:"Required"`
16 - // 共创合约编号  
17 - CooperationContractNumber string `cname:"共创合约编号" json:"cooperationContractNumber" valid:"Required"`  
18 - // 共创项目编号,自生成,生成规则:XM+6位年月日+#+3位流水,例XM210601#001 16 + // 共创项目编号
19 CooperationProjectNumber string `cname:"共创项目编号" json:"cooperationProjectNumber" valid:"Required"` 17 CooperationProjectNumber string `cname:"共创项目编号" json:"cooperationProjectNumber" valid:"Required"`
20 // 部门编码 18 // 部门编码
21 DepartmentId string `cname:"部门ID" json:"departmentId" valid:"Required"` 19 DepartmentId string `cname:"部门ID" json:"departmentId" valid:"Required"`
  1 +package dto
  2 +
  3 +import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
  4 +
  5 +type CooperationContractDto struct {
  6 + *domain.CooperationContract
  7 + // 可以去除勾选的共创项目承接对象列表
  8 + UndertakerTypesUncheckedAvailable []int32 `json:"undertakerTypesUncheckedAvailable"`
  9 +}
  10 +
  11 +func (dto *CooperationContractDto) LoadDto(contract *domain.CooperationContract, undertakerTypesUncheckedAvailable []int32) error {
  12 + dto.CooperationContract = contract
  13 + dto.UndertakerTypesUncheckedAvailable = undertakerTypesUncheckedAvailable
  14 + return nil
  15 +}
@@ -5,6 +5,7 @@ import ( @@ -5,6 +5,7 @@ import (
5 "github.com/linmadan/egglib-go/core/application" 5 "github.com/linmadan/egglib-go/core/application"
6 "github.com/linmadan/egglib-go/utils/tool_funs" 6 "github.com/linmadan/egglib-go/utils/tool_funs"
7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContract/command" 7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContract/command"
  8 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContract/dto"
8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContract/query" 9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContract/query"
9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory" 10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" 11 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
@@ -319,10 +320,31 @@ func (cooperationContractService *CooperationContractService) GetCooperationCont @@ -319,10 +320,31 @@ func (cooperationContractService *CooperationContractService) GetCooperationCont
319 if cooperationContract == nil { 320 if cooperationContract == nil {
320 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(getCooperationContractQuery.CooperationContractId, 10))) 321 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(getCooperationContractQuery.CooperationContractId, 10)))
321 } else { 322 } else {
  323 + // 共创合约DAO初始化
  324 + var cooperationContractDao *dao.CooperationContractDao
  325 + if value, err := factory.CreateCooperationContractDao(map[string]interface{}{
  326 + "transactionContext": transactionContext,
  327 + }); err != nil {
  328 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  329 + } else {
  330 + cooperationContractDao = value
  331 + }
  332 + //TODO 获取可删除的承接对象类型
  333 + undertakerTypesUncheckedAvailable, err := cooperationContractDao.CheckUndertakerTypesUncheckedAvailable(map[string]interface{}{
  334 + "cooperationContractNumber": cooperationContract.CooperationContractNumber,
  335 + "cooperationContractUndertakerTypes": cooperationContract.CooperationContractUndertakerTypes,
  336 + })
  337 + if err != nil {
  338 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  339 + }
  340 + cooperationContractDto := &dto.CooperationContractDto{}
  341 + if err := cooperationContractDto.LoadDto(cooperationContract, undertakerTypesUncheckedAvailable); err != nil {
  342 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  343 + }
322 if err := transactionContext.CommitTransaction(); err != nil { 344 if err := transactionContext.CommitTransaction(); err != nil {
323 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 345 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
324 } 346 }
325 - return cooperationContract, nil 347 + return cooperationContractDto, nil
326 } 348 }
327 } 349 }
328 350
@@ -16,7 +16,7 @@ type UpdateCooperationProjectCommand struct { @@ -16,7 +16,7 @@ type UpdateCooperationProjectCommand struct {
16 // 共创模式编码 16 // 共创模式编码
17 CooperationModeNumber string `cname:"共创模式编码" json:"cooperationModeNumber" valid:"Required"` 17 CooperationModeNumber string `cname:"共创模式编码" json:"cooperationModeNumber" valid:"Required"`
18 // 承接对象,1员工,2共创用户,3公开,可以多选 18 // 承接对象,1员工,2共创用户,3公开,可以多选
19 - CooperationProjectUndertakerType []int32 `cname:"承接对象" json:"cooperationProjectUndertakerType" valid:"Required"` 19 + CooperationProjectUndertakerTypes []int32 `cname:"承接对象" json:"cooperationProjectUndertakerTypes" valid:"Required"`
20 // 共创项目发起人uid 20 // 共创项目发起人uid
21 SponsorUid string `cname:"共创项目发起人UID" json:"sponsorUid" valid:"Required"` 21 SponsorUid string `cname:"共创项目发起人UID" json:"sponsorUid" valid:"Required"`
22 // 共创项目发布人uid 22 // 共创项目发布人uid
@@ -237,7 +237,7 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec @@ -237,7 +237,7 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
237 } else { 237 } else {
238 cooperationProjectDao = value 238 cooperationProjectDao = value
239 } 239 }
240 - //TODO 获取可删除的承接对象类型 240 + // 获取可删除的承接对象类型
241 undertakerTypesUncheckedAvailable, err := cooperationProjectDao.CheckUndertakerTypesUncheckedAvailable(map[string]interface{}{ 241 undertakerTypesUncheckedAvailable, err := cooperationProjectDao.CheckUndertakerTypesUncheckedAvailable(map[string]interface{}{
242 "cooperationProjectNumber": cooperationProject.CooperationProjectNumber, 242 "cooperationProjectNumber": cooperationProject.CooperationProjectNumber,
243 "cooperationProjectUndertakerTypes": cooperationProject.CooperationProjectUndertakerTypes, 243 "cooperationProjectUndertakerTypes": cooperationProject.CooperationProjectUndertakerTypes,
@@ -252,7 +252,7 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec @@ -252,7 +252,7 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
252 if err := transactionContext.CommitTransaction(); err != nil { 252 if err := transactionContext.CommitTransaction(); err != nil {
253 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 253 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
254 } 254 }
255 - return cooperationProject, nil 255 + return cooperationProjectDto, nil
256 } 256 }
257 } 257 }
258 258
@@ -53,17 +53,8 @@ func (cooperationApplication *CooperationApplication) Identify() interface{} { @@ -53,17 +53,8 @@ func (cooperationApplication *CooperationApplication) Identify() interface{} {
53 } 53 }
54 54
55 func (cooperationApplication *CooperationApplication) Update(data map[string]interface{}) error { 55 func (cooperationApplication *CooperationApplication) Update(data map[string]interface{}) error {
56 - if userId, ok := data["userId"]; ok {  
57 - cooperationApplication.CooperationApplicationApplicant.UserId = userId.(int64)  
58 - }  
59 - if userBaseId, ok := data["userBaseId"]; ok {  
60 - cooperationApplication.CooperationApplicationApplicant.UserBaseId = userBaseId.(int64)  
61 - }  
62 - if orgs, ok := data["orgs"]; ok {  
63 - cooperationApplication.CooperationApplicationApplicant.Orgs = orgs.([]*Org)  
64 - }  
65 - if status, ok := data["status"]; ok {  
66 - cooperationApplication.CooperationApplicationApplicant.Status = status.(int32) 56 + if isCanceled, ok := data["isCanceled"]; ok {
  57 + cooperationApplication.IsCanceled = isCanceled.(bool)
67 } 58 }
68 if cooperationApplicationAttachment, ok := data["cooperationApplicationAttachment"]; ok { 59 if cooperationApplicationAttachment, ok := data["cooperationApplicationAttachment"]; ok {
69 cooperationApplication.CooperationApplicationAttachment = cooperationApplicationAttachment.([]*Attachment) 60 cooperationApplication.CooperationApplicationAttachment = cooperationApplicationAttachment.([]*Attachment)
@@ -71,90 +71,9 @@ func (cooperationProject *CooperationProject) Update(data map[string]interface{} @@ -71,90 +71,9 @@ func (cooperationProject *CooperationProject) Update(data map[string]interface{}
71 if cooperationProjectPublishTime, ok := data["cooperationProjectPublishTime"]; ok { 71 if cooperationProjectPublishTime, ok := data["cooperationProjectPublishTime"]; ok {
72 cooperationProject.CooperationProjectPublishTime = cooperationProjectPublishTime.(time.Time) 72 cooperationProject.CooperationProjectPublishTime = cooperationProjectPublishTime.(time.Time)
73 } 73 }
74 - //if userId, ok := data["userId"]; ok {  
75 - // cooperationProject.CooperationProjectPublisher.UserId = userId.(int64)  
76 - //}  
77 - //if userBaseId, ok := data["userBaseId"]; ok {  
78 - // cooperationProject.CooperationProjectPublisher.UserBaseId = userBaseId.(int64)  
79 - //}  
80 - //if orgId, ok := data["orgId"]; ok {  
81 - // cooperationProject.CooperationProjectPublisher.Org.OrgId = orgId.(int64)  
82 - //}  
83 - //if orgName, ok := data["orgName"]; ok {  
84 - // cooperationProject.CooperationProjectPublisher.Org.OrgName = orgName.(string)  
85 - //}  
86 - //if companyId, ok := data["companyId"]; ok {  
87 - // cooperationProject.CooperationProjectPublisher.Org.Company.CompanyId = companyId.(int64)  
88 - //}  
89 - //if companyLogo, ok := data["companyLogo"]; ok {  
90 - // cooperationProject.CooperationProjectPublisher.Org.Company.CompanyLogo = companyLogo.(string)  
91 - //}  
92 - //if companyName, ok := data["companyName"]; ok {  
93 - // cooperationProject.CooperationProjectPublisher.Org.Company.CompanyName = companyName.(string)  
94 - //}  
95 - //if orgs, ok := data["orgs"]; ok {  
96 - // cooperationProject.CooperationProjectPublisher.Orgs = orgs.([]*Org)  
97 - //}  
98 - //if departmentId, ok := data["departmentId"]; ok {  
99 - // cooperationProject.CooperationProjectPublisher.Department.DepartmentId = departmentId.(int64)  
100 - //}  
101 - //if departmentName, ok := data["departmentName"]; ok {  
102 - // cooperationProject.CooperationProjectPublisher.Department.DepartmentName = departmentName.(string)  
103 - //}  
104 - //if departmentNumber, ok := data["departmentNumber"]; ok {  
105 - // cooperationProject.CooperationProjectPublisher.Department.DepartmentNumber = departmentNumber.(string)  
106 - //}  
107 - //if isOrganization, ok := data["isOrganization"]; ok {  
108 - // cooperationProject.CooperationProjectPublisher.Department.IsOrganization = isOrganization.(bool)  
109 - //}  
110 - //if userAvatar, ok := data["userAvatar"]; ok {  
111 - // cooperationProject.CooperationProjectPublisher.UserInfo.UserAvatar = userAvatar.(string)  
112 - //}  
113 - //if userEmail, ok := data["userEmail"]; ok {  
114 - // cooperationProject.CooperationProjectPublisher.UserInfo.UserEmail = userEmail.(string)  
115 - //}  
116 - //if userName, ok := data["userName"]; ok {  
117 - // cooperationProject.CooperationProjectPublisher.UserInfo.UserName = userName.(string)  
118 - //}  
119 - //if userPhone, ok := data["userPhone"]; ok {  
120 - // cooperationProject.CooperationProjectPublisher.UserInfo.UserPhone = userPhone.(string)  
121 - //}  
122 - //if userAccount, ok := data["userAccount"]; ok {  
123 - // cooperationProject.CooperationProjectPublisher.UserInfo.UserAccount = userAccount.(string)  
124 - //}  
125 - //if userType, ok := data["userType"]; ok {  
126 - // cooperationProject.CooperationProjectPublisher.UserType = userType.(int32)  
127 - //}  
128 - //if status, ok := data["status"]; ok {  
129 - // cooperationProject.CooperationProjectPublisher.Status = status.(int32)  
130 - //}  
131 - //if companyId, ok := data["companyId"]; ok {  
132 - // cooperationProject.CooperationProjectPublisher.Company.CompanyId = companyId.(int64)  
133 - //}  
134 - //if companyLogo, ok := data["companyLogo"]; ok {  
135 - // cooperationProject.CooperationProjectPublisher.Company.CompanyLogo = companyLogo.(string)  
136 - //}  
137 - //if companyName, ok := data["companyName"]; ok {  
138 - // cooperationProject.CooperationProjectPublisher.Company.CompanyName = companyName.(string)  
139 - //}  
140 - //if userId, ok := data["userId"]; ok {  
141 - // cooperationProject.CooperationProjectSponsor.UserId = userId.(int64)  
142 - //}  
143 - //if userBaseId, ok := data["userBaseId"]; ok {  
144 - // cooperationProject.CooperationProjectSponsor.UserBaseId = userBaseId.(int64)  
145 - //}  
146 - //if orgId, ok := data["orgId"]; ok {  
147 - // cooperationProject.CooperationProjectSponsor.Org.OrgId = orgId.(int64)  
148 - //}  
149 - //if orgName, ok := data["orgName"]; ok {  
150 - // cooperationProject.CooperationProjectSponsor.Org.OrgName = orgName.(string)  
151 - //}  
152 - //if companyId, ok := data["companyId"]; ok {  
153 - // cooperationProject.CooperationProjectSponsor.Company.CompanyId = companyId.(int64)  
154 - //}  
155 - //if cooperationProjectUndertakerType, ok := data["cooperationProjectUndertakerType"]; ok {  
156 - // cooperationProject.CooperationProjectUndertakerTypes = cooperationProjectUndertakerType.([]int32)  
157 - //} 74 + if cooperationProjectUndertakerTypes, ok := data["cooperationProjectUndertakerTypes"]; ok {
  75 + cooperationProject.CooperationProjectUndertakerTypes = cooperationProjectUndertakerTypes.([]int32)
  76 + }
158 if operateTime, ok := data["operateTime"]; ok { 77 if operateTime, ok := data["operateTime"]; ok {
159 cooperationProject.OperateTime = operateTime.(time.Time) 78 cooperationProject.OperateTime = operateTime.(time.Time)
160 } 79 }
@@ -35,6 +35,12 @@ func (dao *CooperationContractDao) GenerateContractNumber() (string, error) { @@ -35,6 +35,12 @@ func (dao *CooperationContractDao) GenerateContractNumber() (string, error) {
35 } 35 }
36 } 36 }
37 37
  38 +// CheckUndertakerTypesUncheckedAvailable TODO 校验合约承接对象是否可以删除
  39 +func (dao *CooperationContractDao) CheckUndertakerTypesUncheckedAvailable(queryOptions map[string]interface{}) ([]int32, error) {
  40 +
  41 + return []int32{}, nil
  42 +}
  43 +
38 // CheckContractNumberAvailable 检验合约编号唯一性 44 // CheckContractNumberAvailable 检验合约编号唯一性
39 func (dao *CooperationContractDao) CheckContractNumberAvailable(queryOptions map[string]interface{}) (bool, error) { 45 func (dao *CooperationContractDao) CheckContractNumberAvailable(queryOptions map[string]interface{}) (bool, error) {
40 tx := dao.transactionContext.PgTx 46 tx := dao.transactionContext.PgTx
@@ -37,6 +37,7 @@ func (dao *CooperationProjectDao) GenerateProjectNumber() (string, error) { @@ -37,6 +37,7 @@ func (dao *CooperationProjectDao) GenerateProjectNumber() (string, error) {
37 37
38 // CheckUndertakerTypesUncheckedAvailable TODO 校验项目承接对象是否可以删除 38 // CheckUndertakerTypesUncheckedAvailable TODO 校验项目承接对象是否可以删除
39 func (dao *CooperationProjectDao) CheckUndertakerTypesUncheckedAvailable(queryOptions map[string]interface{}) ([]int32, error) { 39 func (dao *CooperationProjectDao) CheckUndertakerTypesUncheckedAvailable(queryOptions map[string]interface{}) ([]int32, error) {
  40 +
40 return []int32{}, nil 41 return []int32{}, nil
41 } 42 }
42 43
@@ -181,6 +181,21 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string @@ -181,6 +181,21 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string
181 var cooperationApplicationModels []*models.CooperationApplication 181 var cooperationApplicationModels []*models.CooperationApplication
182 cooperationApplications := make([]*domain.CooperationApplication, 0) 182 cooperationApplications := make([]*domain.CooperationApplication, 0)
183 query := sqlbuilder.BuildQuery(tx.Model(&cooperationApplicationModels), queryOptions) 183 query := sqlbuilder.BuildQuery(tx.Model(&cooperationApplicationModels), queryOptions)
  184 + if cooperationProjectNumber, ok := queryOptions["cooperationProjectNumber"]; ok && cooperationProjectNumber != "" {
  185 + query.Where("cooperation_project_number like ?", fmt.Sprintf("%%%s%%", cooperationProjectNumber))
  186 + }
  187 + //TODO 共创项目名称查询
  188 + if cooperationProjectName, ok := queryOptions["cooperationProjectName"]; ok && cooperationProjectName != "" {
  189 + query.Join("LEFT JOIN cooperation_projects AS a").
  190 + JoinOn("a.cooperation_project_number = cooperation_application.cooperation_project_number").
  191 + Where("a.cooperation_project_name like ?", fmt.Sprintf("%%%s%%", cooperationProjectName))
  192 + }
  193 + if applicantName, ok := queryOptions["applicantName"]; ok && applicantName != "" {
  194 + query.Where(`(cooperation_application.cooperation_application_applicant->>'userName')::text LIKE ?`, fmt.Sprintf("%%%s%%", applicantName))
  195 + }
  196 + if cooperationApplicationStatus, ok := queryOptions["cooperationApplicationStatus"]; ok && cooperationApplicationStatus.(int32) != 0 {
  197 +
  198 + }
184 query.SetOffsetAndLimit(20) 199 query.SetOffsetAndLimit(20)
185 query.SetOrderDirect("cooperation_application_id", "DESC") 200 query.SetOrderDirect("cooperation_application_id", "DESC")
186 if count, err := query.SelectAndCount(); err != nil { 201 if count, err := query.SelectAndCount(); err != nil {
@@ -166,6 +166,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai @@ -166,6 +166,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
166 if _, err := tx.Model(&dividendsIncentivesRulesModel).Insert(); err != nil { 166 if _, err := tx.Model(&dividendsIncentivesRulesModel).Insert(); err != nil {
167 return nil, err 167 return nil, err
168 } 168 }
  169 +
169 // 新增金额激励规则 170 // 新增金额激励规则
170 var moneyIncentivesRulesModel []*models.MoneyIncentivesRule 171 var moneyIncentivesRulesModel []*models.MoneyIncentivesRule
171 for _, rule := range cooperationContract.MoneyIncentivesRules { 172 for _, rule := range cooperationContract.MoneyIncentivesRules {
@@ -685,7 +686,6 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in @@ -685,7 +686,6 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in
685 query.Where("cooperation_contract_number like ?", fmt.Sprintf("%%%s%%", cooperationContractNumber)) 686 query.Where("cooperation_contract_number like ?", fmt.Sprintf("%%%s%%", cooperationContractNumber))
686 } 687 }
687 if sponsorName, ok := queryOptions["sponsorName"]; ok && sponsorName != "" { 688 if sponsorName, ok := queryOptions["sponsorName"]; ok && sponsorName != "" {
688 - //query.Where(`cooperation_contract.cooperation_contract_sponsor->'userName' LIKE ?`, fmt.Sprintf("%%%s%%", sponsorName))  
689 query.Where(`(cooperation_contract.cooperation_contract_sponsor->>'userName')::text LIKE ?`, fmt.Sprintf("%%%s%%", sponsorName)) 689 query.Where(`(cooperation_contract.cooperation_contract_sponsor->>'userName')::text LIKE ?`, fmt.Sprintf("%%%s%%", sponsorName))
690 } 690 }
691 query.SetOffsetAndLimit(20) 691 query.SetOffsetAndLimit(20)
@@ -170,6 +170,9 @@ func (repository *CooperationProjectRepository) FindOne(queryOptions map[string] @@ -170,6 +170,9 @@ func (repository *CooperationProjectRepository) FindOne(queryOptions map[string]
170 tx := repository.transactionContext.PgTx 170 tx := repository.transactionContext.PgTx
171 cooperationProjectModel := new(models.CooperationProject) 171 cooperationProjectModel := new(models.CooperationProject)
172 query := sqlbuilder.BuildQuery(tx.Model(cooperationProjectModel), queryOptions) 172 query := sqlbuilder.BuildQuery(tx.Model(cooperationProjectModel), queryOptions)
  173 + if cooperationProjectNumber, ok := queryOptions["cooperationProjectNumber"]; ok && cooperationProjectNumber != "" {
  174 + query.Where("cooperation_project_number = ?", cooperationProjectNumber)
  175 + }
173 query.SetWhereByQueryOption("cooperation_project.cooperation_project_id = ?", "cooperationProjectId") 176 query.SetWhereByQueryOption("cooperation_project.cooperation_project_id = ?", "cooperationProjectId")
174 if err := query.First(); err != nil { 177 if err := query.First(); err != nil {
175 if err.Error() == "pg: no rows in result set" { 178 if err.Error() == "pg: no rows in result set" {
@@ -25,14 +25,27 @@ func (controller *CooperationApplicationController) ApplyForCooperation() { @@ -25,14 +25,27 @@ func (controller *CooperationApplicationController) ApplyForCooperation() {
25 25
26 func (controller *CooperationApplicationController) ApprovalCooperationApplication() { 26 func (controller *CooperationApplicationController) ApprovalCooperationApplication() {
27 cooperationApplicationService := service.NewCooperationApplicationService(nil) 27 cooperationApplicationService := service.NewCooperationApplicationService(nil)
28 - agreeCooperationApplicationCommand := &command.ApprovalCooperationApplicationCommand{}  
29 - _ = controller.Unmarshal(agreeCooperationApplicationCommand) 28 + approvalCooperationApplicationCommand := &command.ApprovalCooperationApplicationCommand{}
  29 + _ = controller.Unmarshal(approvalCooperationApplicationCommand)
30 header := controller.GetRequestHeader(controller.Ctx) 30 header := controller.GetRequestHeader(controller.Ctx)
31 - agreeCooperationApplicationCommand.CompanyId = header.CompanyId  
32 - agreeCooperationApplicationCommand.OrgId = header.OrgId  
33 - agreeCooperationApplicationCommand.UserId = header.UserId  
34 - agreeCooperationApplicationCommand.UserBaseId = header.UserBaseId  
35 - data, err := cooperationApplicationService.ApprovalCooperationApplication(agreeCooperationApplicationCommand) 31 + approvalCooperationApplicationCommand.CompanyId = header.CompanyId
  32 + approvalCooperationApplicationCommand.OrgId = header.OrgId
  33 + approvalCooperationApplicationCommand.UserId = header.UserId
  34 + approvalCooperationApplicationCommand.UserBaseId = header.UserBaseId
  35 + data, err := cooperationApplicationService.ApprovalCooperationApplication(approvalCooperationApplicationCommand)
  36 + controller.Response(data, err)
  37 +}
  38 +
  39 +func (controller *CooperationApplicationController) CancelCooperationApplication() {
  40 + cooperationApplicationService := service.NewCooperationApplicationService(nil)
  41 + cancelCooperationApplicationCommand := &command.CancelCooperationApplicationCommand{}
  42 + _ = controller.Unmarshal(cancelCooperationApplicationCommand)
  43 + header := controller.GetRequestHeader(controller.Ctx)
  44 + cancelCooperationApplicationCommand.CompanyId = header.CompanyId
  45 + cancelCooperationApplicationCommand.OrgId = header.OrgId
  46 + cancelCooperationApplicationCommand.UserId = header.UserId
  47 + cancelCooperationApplicationCommand.UserBaseId = header.UserBaseId
  48 + data, err := cooperationApplicationService.CancelCooperationApplication(cancelCooperationApplicationCommand)
36 controller.Response(data, err) 49 controller.Response(data, err)
37 } 50 }
38 51
@@ -6,7 +6,8 @@ import ( @@ -6,7 +6,8 @@ import (
6 ) 6 )
7 7
8 func init() { 8 func init() {
9 - web.Router("/cooperation-applications/apply-for-cooperation", &controllers.CooperationApplicationController{}, "Post:ApplyForCooperation") // 申请共创 9 + web.Router("/cooperation-applications/apply-for-cooperation", &controllers.CooperationApplicationController{}, "Post:ApplyForCooperation") // 申请共创
  10 + web.Router("/cooperation-applications/cancel-application", &controllers.CooperationApplicationController{}, "Post:CancelCooperationApplication")
10 web.Router("/cooperation-applications/agree-cooperation-application", &controllers.CooperationApplicationController{}, "Post:ApprovalCooperationApplication") // 同意共创申请 11 web.Router("/cooperation-applications/agree-cooperation-application", &controllers.CooperationApplicationController{}, "Post:ApprovalCooperationApplication") // 同意共创申请
11 web.Router("/cooperation-applications/batch-approval", &controllers.CooperationContractController{}, "Post:BatchApprovalCooperationApplication") // 一键审核 12 web.Router("/cooperation-applications/batch-approval", &controllers.CooperationContractController{}, "Post:BatchApprovalCooperationApplication") // 一键审核
12 web.Router("/cooperation-applications/", &controllers.CooperationApplicationController{}, "Post:CreateCooperationApplication") // 新增共创申请 13 web.Router("/cooperation-applications/", &controllers.CooperationApplicationController{}, "Post:CreateCooperationApplication") // 新增共创申请