作者 陈志颖

feat:应用服务集成REST服务

@@ -8,13 +8,15 @@ import ( @@ -8,13 +8,15 @@ import (
8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/contractUndertakerFeedback/query" 8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/contractUndertakerFeedback/query"
9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory" 9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" 10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
  11 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
  12 + "time"
11 ) 13 )
12 14
13 -// 共创合约反馈服务 15 +// ContractUndertakerFeedbackService 共创合约反馈服务
14 type ContractUndertakerFeedbackService struct { 16 type ContractUndertakerFeedbackService struct {
15 } 17 }
16 18
17 -// 创建共创合约反馈服务 19 +// CreateContractUndertakerFeedback 创建共创合约反馈服务
18 func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) CreateContractUndertakerFeedback(createContractUndertakerFeedbackCommand *command.CreateContractUndertakerFeedbackCommand) (interface{}, error) { 20 func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) CreateContractUndertakerFeedback(createContractUndertakerFeedbackCommand *command.CreateContractUndertakerFeedbackCommand) (interface{}, error) {
19 if err := createContractUndertakerFeedbackCommand.ValidateCommand(); err != nil { 21 if err := createContractUndertakerFeedbackCommand.ValidateCommand(); err != nil {
20 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 22 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -27,17 +29,69 @@ func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) Crea @@ -27,17 +29,69 @@ func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) Crea
27 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 29 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
28 } 30 }
29 defer func() { 31 defer func() {
30 - transactionContext.RollbackTransaction() 32 + _ = transactionContext.RollbackTransaction()
31 }() 33 }()
  34 +
  35 + // 用户REST服务初始化
  36 + var userService service.UserService
  37 + if value, err := factory.CreateUserService(map[string]interface{}{}); err != nil {
  38 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  39 + } else {
  40 + userService = value
  41 + }
  42 +
  43 + // 获取承接人
  44 + var undertaker *domain.Undertaker
  45 + if data, err := userService.UndertakerFrom(createContractUndertakerFeedbackCommand.CompanyId, createContractUndertakerFeedbackCommand.OrgId, createContractUndertakerFeedbackCommand.UserId); err != nil {
  46 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  47 + } else {
  48 + undertaker = data
  49 + }
  50 +
  51 + // 公司REST服务初始化
  52 + var companyService service.CompanyService
  53 + if value, err := factory.CreateCompanyService(map[string]interface{}{}); err != nil {
  54 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  55 + } else {
  56 + companyService = value
  57 + }
  58 +
  59 + // 获取公司信息
  60 + var company *domain.Company
  61 + if data, err := companyService.CompanyFrom(createContractUndertakerFeedbackCommand.CompanyId); err != nil {
  62 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  63 + } else {
  64 + company = data
  65 + }
  66 +
  67 + // 组织机构REST服务初始化
  68 + var organizationService service.OrgService
  69 + if value, err := factory.CreateOrganizationService(map[string]interface{}{}); err != nil {
  70 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  71 + } else {
  72 + organizationService = value
  73 + }
  74 +
  75 + // 获取组织机构信息
  76 + var organization *domain.Org
  77 + if data, err := organizationService.OrgFrom(createContractUndertakerFeedbackCommand.CompanyId, createContractUndertakerFeedbackCommand.OrgId); err != nil {
  78 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  79 + } else {
  80 + organization = data
  81 + }
  82 +
32 newContractUndertakerFeedback := &domain.ContractUndertakerFeedback{ 83 newContractUndertakerFeedback := &domain.ContractUndertakerFeedback{
33 FeedbackAttachment: createContractUndertakerFeedbackCommand.FeedbackAttachment, 84 FeedbackAttachment: createContractUndertakerFeedbackCommand.FeedbackAttachment,
34 FeedbackContent: createContractUndertakerFeedbackCommand.FeedbackContent, 85 FeedbackContent: createContractUndertakerFeedbackCommand.FeedbackContent,
35 CooperationContractNumber: createContractUndertakerFeedbackCommand.CooperationContractNumber, 86 CooperationContractNumber: createContractUndertakerFeedbackCommand.CooperationContractNumber,
36 - //UnderTakerUid: createContractUndertakerFeedbackCommand.UnderTakerUid,  
37 - //CompanyId: createContractUndertakerFeedbackCommand.CompanyId,  
38 - //OrgId: createContractUndertakerFeedbackCommand.OrgId,  
39 - //UserId: createContractUndertakerFeedbackCommand.UserId, 87 + ContractUndertaker: undertaker,
  88 + Company: company,
  89 + Org: organization,
  90 + UpdatedAt: time.Time{},
  91 + DeletedAt: time.Time{},
  92 + CreatedAt: time.Now(),
40 } 93 }
  94 +
41 var contractUndertakerFeedbackRepository domain.ContractUndertakerFeedbackRepository 95 var contractUndertakerFeedbackRepository domain.ContractUndertakerFeedbackRepository
42 if value, err := factory.CreateContractUndertakerFeedbackRepository(map[string]interface{}{ 96 if value, err := factory.CreateContractUndertakerFeedbackRepository(map[string]interface{}{
43 "transactionContext": transactionContext, 97 "transactionContext": transactionContext,
@@ -56,7 +110,7 @@ func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) Crea @@ -56,7 +110,7 @@ func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) Crea
56 } 110 }
57 } 111 }
58 112
59 -// 返回共创合约反馈服务 113 +// GetContractUndertakerFeedback 返回共创合约反馈服务
60 func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) GetContractUndertakerFeedback(getContractUndertakerFeedbackQuery *query.GetContractUndertakerFeedbackQuery) (interface{}, error) { 114 func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) GetContractUndertakerFeedback(getContractUndertakerFeedbackQuery *query.GetContractUndertakerFeedbackQuery) (interface{}, error) {
61 if err := getContractUndertakerFeedbackQuery.ValidateQuery(); err != nil { 115 if err := getContractUndertakerFeedbackQuery.ValidateQuery(); err != nil {
62 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 116 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -69,7 +123,7 @@ func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) GetC @@ -69,7 +123,7 @@ func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) GetC
69 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 123 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
70 } 124 }
71 defer func() { 125 defer func() {
72 - transactionContext.RollbackTransaction() 126 + _ = transactionContext.RollbackTransaction()
73 }() 127 }()
74 var contractUndertakerFeedbackRepository domain.ContractUndertakerFeedbackRepository 128 var contractUndertakerFeedbackRepository domain.ContractUndertakerFeedbackRepository
75 if value, err := factory.CreateContractUndertakerFeedbackRepository(map[string]interface{}{ 129 if value, err := factory.CreateContractUndertakerFeedbackRepository(map[string]interface{}{
@@ -93,7 +147,7 @@ func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) GetC @@ -93,7 +147,7 @@ func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) GetC
93 } 147 }
94 } 148 }
95 149
96 -// 返回共创合约反馈服务列表 150 +// ListContractUndertakerFeedback 返回共创合约反馈服务列表
97 func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) ListContractUndertakerFeedback(listContractUndertakerFeedbackQuery *query.ListContractUndertakerFeedbackQuery) (interface{}, error) { 151 func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) ListContractUndertakerFeedback(listContractUndertakerFeedbackQuery *query.ListContractUndertakerFeedbackQuery) (interface{}, error) {
98 if err := listContractUndertakerFeedbackQuery.ValidateQuery(); err != nil { 152 if err := listContractUndertakerFeedbackQuery.ValidateQuery(); err != nil {
99 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 153 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -106,7 +160,7 @@ func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) List @@ -106,7 +160,7 @@ func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) List
106 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 160 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
107 } 161 }
108 defer func() { 162 defer func() {
109 - transactionContext.RollbackTransaction() 163 + _ = transactionContext.RollbackTransaction()
110 }() 164 }()
111 var contractUndertakerFeedbackRepository domain.ContractUndertakerFeedbackRepository 165 var contractUndertakerFeedbackRepository domain.ContractUndertakerFeedbackRepository
112 if value, err := factory.CreateContractUndertakerFeedbackRepository(map[string]interface{}{ 166 if value, err := factory.CreateContractUndertakerFeedbackRepository(map[string]interface{}{
@@ -129,7 +183,7 @@ func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) List @@ -129,7 +183,7 @@ func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) List
129 } 183 }
130 } 184 }
131 185
132 -// 移除共创合约反馈服务 186 +// RemoveContractUndertakerFeedback 移除共创合约反馈服务
133 func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) RemoveContractUndertakerFeedback(removeContractUndertakerFeedbackCommand *command.RemoveContractUndertakerFeedbackCommand) (interface{}, error) { 187 func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) RemoveContractUndertakerFeedback(removeContractUndertakerFeedbackCommand *command.RemoveContractUndertakerFeedbackCommand) (interface{}, error) {
134 if err := removeContractUndertakerFeedbackCommand.ValidateCommand(); err != nil { 188 if err := removeContractUndertakerFeedbackCommand.ValidateCommand(); err != nil {
135 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 189 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -142,7 +196,7 @@ func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) Remo @@ -142,7 +196,7 @@ func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) Remo
142 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 196 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
143 } 197 }
144 defer func() { 198 defer func() {
145 - transactionContext.RollbackTransaction() 199 + _ = transactionContext.RollbackTransaction()
146 }() 200 }()
147 var contractUndertakerFeedbackRepository domain.ContractUndertakerFeedbackRepository 201 var contractUndertakerFeedbackRepository domain.ContractUndertakerFeedbackRepository
148 if value, err := factory.CreateContractUndertakerFeedbackRepository(map[string]interface{}{ 202 if value, err := factory.CreateContractUndertakerFeedbackRepository(map[string]interface{}{
@@ -169,7 +223,7 @@ func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) Remo @@ -169,7 +223,7 @@ func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) Remo
169 } 223 }
170 } 224 }
171 225
172 -// 查询共创承接方反馈信息 226 +// SearchContractUndertakerFeedback 查询共创承接方反馈信息
173 func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) SearchContractUndertakerFeedback(searchContractUndertakerFeedbackQuery *query.SearchContractUndertakerFeedbackQuery) (interface{}, error) { 227 func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) SearchContractUndertakerFeedback(searchContractUndertakerFeedbackQuery *query.SearchContractUndertakerFeedbackQuery) (interface{}, error) {
174 if err := searchContractUndertakerFeedbackQuery.ValidateQuery(); err != nil { 228 if err := searchContractUndertakerFeedbackQuery.ValidateQuery(); err != nil {
175 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 229 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -182,7 +236,7 @@ func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) Sear @@ -182,7 +236,7 @@ func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) Sear
182 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 236 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
183 } 237 }
184 defer func() { 238 defer func() {
185 - transactionContext.RollbackTransaction() 239 + _ = transactionContext.RollbackTransaction()
186 }() 240 }()
187 if err := transactionContext.CommitTransaction(); err != nil { 241 if err := transactionContext.CommitTransaction(); err != nil {
188 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 242 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -190,7 +244,7 @@ func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) Sear @@ -190,7 +244,7 @@ func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) Sear
190 return nil, nil 244 return nil, nil
191 } 245 }
192 246
193 -// 更新共创合约反馈服务 247 +// UpdateContractUndertakerFeedback 更新共创合约反馈服务
194 func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) UpdateContractUndertakerFeedback(updateContractUndertakerFeedbackCommand *command.UpdateContractUndertakerFeedbackCommand) (interface{}, error) { 248 func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) UpdateContractUndertakerFeedback(updateContractUndertakerFeedbackCommand *command.UpdateContractUndertakerFeedbackCommand) (interface{}, error) {
195 if err := updateContractUndertakerFeedbackCommand.ValidateCommand(); err != nil { 249 if err := updateContractUndertakerFeedbackCommand.ValidateCommand(); err != nil {
196 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 250 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -203,7 +257,7 @@ func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) Upda @@ -203,7 +257,7 @@ func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) Upda
203 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 257 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
204 } 258 }
205 defer func() { 259 defer func() {
206 - transactionContext.RollbackTransaction() 260 + _ = transactionContext.RollbackTransaction()
207 }() 261 }()
208 var contractUndertakerFeedbackRepository domain.ContractUndertakerFeedbackRepository 262 var contractUndertakerFeedbackRepository domain.ContractUndertakerFeedbackRepository
209 if value, err := factory.CreateContractUndertakerFeedbackRepository(map[string]interface{}{ 263 if value, err := factory.CreateContractUndertakerFeedbackRepository(map[string]interface{}{
@@ -8,6 +8,7 @@ import ( @@ -8,6 +8,7 @@ import (
8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationApplication/query" 8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationApplication/query"
9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory" 9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" 10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
  11 + "strconv"
11 ) 12 )
12 13
13 // CooperationApplicationService 共创申请服务 14 // CooperationApplicationService 共创申请服务
@@ -27,7 +28,7 @@ func (cooperationApplicationService *CooperationApplicationService) AgreeCoopera @@ -27,7 +28,7 @@ func (cooperationApplicationService *CooperationApplicationService) AgreeCoopera
27 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 28 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
28 } 29 }
29 defer func() { 30 defer func() {
30 - transactionContext.RollbackTransaction() 31 + _ = transactionContext.RollbackTransaction()
31 }() 32 }()
32 if err := transactionContext.CommitTransaction(); err != nil { 33 if err := transactionContext.CommitTransaction(); err != nil {
33 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 34 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -48,7 +49,7 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop @@ -48,7 +49,7 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop
48 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 49 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
49 } 50 }
50 defer func() { 51 defer func() {
51 - transactionContext.RollbackTransaction() 52 + _ = transactionContext.RollbackTransaction()
52 }() 53 }()
53 if err := transactionContext.CommitTransaction(); err != nil { 54 if err := transactionContext.CommitTransaction(); err != nil {
54 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 55 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -69,7 +70,7 @@ func (cooperationApplicationService *CooperationApplicationService) BatchApprova @@ -69,7 +70,7 @@ func (cooperationApplicationService *CooperationApplicationService) BatchApprova
69 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 70 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
70 } 71 }
71 defer func() { 72 defer func() {
72 - transactionContext.RollbackTransaction() 73 + _ = transactionContext.RollbackTransaction()
73 }() 74 }()
74 if err := transactionContext.CommitTransaction(); err != nil { 75 if err := transactionContext.CommitTransaction(); err != nil {
75 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 76 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -90,7 +91,7 @@ func (cooperationApplicationService *CooperationApplicationService) CreateCooper @@ -90,7 +91,7 @@ func (cooperationApplicationService *CooperationApplicationService) CreateCooper
90 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 91 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
91 } 92 }
92 defer func() { 93 defer func() {
93 - transactionContext.RollbackTransaction() 94 + _ = transactionContext.RollbackTransaction()
94 }() 95 }()
95 newCooperationApplication := &domain.CooperationApplication{ 96 newCooperationApplication := &domain.CooperationApplication{
96 //ApplicantUid: createCooperationApplicationCommand.ApplicantUid, 97 //ApplicantUid: createCooperationApplicationCommand.ApplicantUid,
@@ -132,7 +133,7 @@ func (cooperationApplicationService *CooperationApplicationService) GetCooperati @@ -132,7 +133,7 @@ func (cooperationApplicationService *CooperationApplicationService) GetCooperati
132 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 133 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
133 } 134 }
134 defer func() { 135 defer func() {
135 - transactionContext.RollbackTransaction() 136 + _ = transactionContext.RollbackTransaction()
136 }() 137 }()
137 var cooperationApplicationRepository domain.CooperationApplicationRepository 138 var cooperationApplicationRepository domain.CooperationApplicationRepository
138 if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{ 139 if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{
@@ -147,7 +148,7 @@ func (cooperationApplicationService *CooperationApplicationService) GetCooperati @@ -147,7 +148,7 @@ func (cooperationApplicationService *CooperationApplicationService) GetCooperati
147 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 148 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
148 } 149 }
149 if cooperationApplication == nil { 150 if cooperationApplication == nil {
150 - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getCooperationApplicationQuery.CooperationApplicationId))) 151 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(getCooperationApplicationQuery.CooperationApplicationId, 10)))
151 } else { 152 } else {
152 if err := transactionContext.CommitTransaction(); err != nil { 153 if err := transactionContext.CommitTransaction(); err != nil {
153 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 154 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -169,7 +170,7 @@ func (cooperationApplicationService *CooperationApplicationService) ListCooperat @@ -169,7 +170,7 @@ func (cooperationApplicationService *CooperationApplicationService) ListCooperat
169 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 170 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
170 } 171 }
171 defer func() { 172 defer func() {
172 - transactionContext.RollbackTransaction() 173 + _ = transactionContext.RollbackTransaction()
173 }() 174 }()
174 var cooperationApplicationRepository domain.CooperationApplicationRepository 175 var cooperationApplicationRepository domain.CooperationApplicationRepository
175 if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{ 176 if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{
@@ -205,7 +206,7 @@ func (cooperationApplicationService *CooperationApplicationService) RejectCooper @@ -205,7 +206,7 @@ func (cooperationApplicationService *CooperationApplicationService) RejectCooper
205 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 206 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
206 } 207 }
207 defer func() { 208 defer func() {
208 - transactionContext.RollbackTransaction() 209 + _ = transactionContext.RollbackTransaction()
209 }() 210 }()
210 if err := transactionContext.CommitTransaction(); err != nil { 211 if err := transactionContext.CommitTransaction(); err != nil {
211 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 212 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -226,7 +227,7 @@ func (cooperationApplicationService *CooperationApplicationService) RemoveCooper @@ -226,7 +227,7 @@ func (cooperationApplicationService *CooperationApplicationService) RemoveCooper
226 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 227 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
227 } 228 }
228 defer func() { 229 defer func() {
229 - transactionContext.RollbackTransaction() 230 + _ = transactionContext.RollbackTransaction()
230 }() 231 }()
231 var cooperationApplicationRepository domain.CooperationApplicationRepository 232 var cooperationApplicationRepository domain.CooperationApplicationRepository
232 if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{ 233 if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{
@@ -241,7 +242,7 @@ func (cooperationApplicationService *CooperationApplicationService) RemoveCooper @@ -241,7 +242,7 @@ func (cooperationApplicationService *CooperationApplicationService) RemoveCooper
241 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 242 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
242 } 243 }
243 if cooperationApplication == nil { 244 if cooperationApplication == nil {
244 - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(removeCooperationApplicationCommand.CooperationApplicationId))) 245 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(removeCooperationApplicationCommand.CooperationApplicationId, 10)))
245 } 246 }
246 if cooperationApplication, err := cooperationApplicationRepository.Remove(cooperationApplication); err != nil { 247 if cooperationApplication, err := cooperationApplicationRepository.Remove(cooperationApplication); err != nil {
247 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 248 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -266,7 +267,7 @@ func (cooperationApplicationService *CooperationApplicationService) SearchCooper @@ -266,7 +267,7 @@ func (cooperationApplicationService *CooperationApplicationService) SearchCooper
266 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 267 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
267 } 268 }
268 defer func() { 269 defer func() {
269 - transactionContext.RollbackTransaction() 270 + _ = transactionContext.RollbackTransaction()
270 }() 271 }()
271 if err := transactionContext.CommitTransaction(); err != nil { 272 if err := transactionContext.CommitTransaction(); err != nil {
272 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 273 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -287,7 +288,7 @@ func (cooperationApplicationService *CooperationApplicationService) UpdateCooper @@ -287,7 +288,7 @@ func (cooperationApplicationService *CooperationApplicationService) UpdateCooper
287 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 288 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
288 } 289 }
289 defer func() { 290 defer func() {
290 - transactionContext.RollbackTransaction() 291 + _ = transactionContext.RollbackTransaction()
291 }() 292 }()
292 var cooperationApplicationRepository domain.CooperationApplicationRepository 293 var cooperationApplicationRepository domain.CooperationApplicationRepository
293 if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{ 294 if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{
@@ -27,7 +27,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC @@ -27,7 +27,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
27 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 27 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
28 } 28 }
29 defer func() { 29 defer func() {
30 - transactionContext.RollbackTransaction() 30 + _ = transactionContext.RollbackTransaction()
31 }() 31 }()
32 32
33 //userServiceGateway, err := factory.CreateUserServiceGateway(nil) 33 //userServiceGateway, err := factory.CreateUserServiceGateway(nil)
@@ -8,13 +8,16 @@ import ( @@ -8,13 +8,16 @@ import (
8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContractChangeLog/query" 8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContractChangeLog/query"
9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory" 9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" 10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
  11 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
  12 + "strconv"
  13 + "time"
11 ) 14 )
12 15
13 -// 共创合约变更日志 16 +// CooperationContractChangeLogService 共创合约变更日志
14 type CooperationContractChangeLogService struct { 17 type CooperationContractChangeLogService struct {
15 } 18 }
16 19
17 -// 创建共创合约变更日志 20 +// CreateCooperationContractChangeLog 创建共创合约变更日志
18 func (cooperationContractChangeLogService *CooperationContractChangeLogService) CreateCooperationContractChangeLog(createCooperationContractChangeLogCommand *command.CreateCooperationContractChangeLogCommand) (interface{}, error) { 21 func (cooperationContractChangeLogService *CooperationContractChangeLogService) CreateCooperationContractChangeLog(createCooperationContractChangeLogCommand *command.CreateCooperationContractChangeLogCommand) (interface{}, error) {
19 if err := createCooperationContractChangeLogCommand.ValidateCommand(); err != nil { 22 if err := createCooperationContractChangeLogCommand.ValidateCommand(); err != nil {
20 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 23 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -27,17 +30,52 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService) @@ -27,17 +30,52 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService)
27 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 30 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
28 } 31 }
29 defer func() { 32 defer func() {
30 - transactionContext.RollbackTransaction() 33 + _ = transactionContext.RollbackTransaction()
31 }() 34 }()
  35 +
  36 + // 公司REST服务初始化
  37 + var companyService service.CompanyService
  38 + if value, err := factory.CreateCompanyService(map[string]interface{}{}); err != nil {
  39 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  40 + } else {
  41 + companyService = value
  42 + }
  43 +
  44 + // 获取公司信息
  45 + var company *domain.Company
  46 + if data, err := companyService.CompanyFrom(createCooperationContractChangeLogCommand.CompanyId); err != nil {
  47 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  48 + } else {
  49 + company = data
  50 + }
  51 +
  52 + // 用户REST服务初始化
  53 + var userService service.UserService
  54 + if value, err := factory.CreateUserService(map[string]interface{}{}); err != nil {
  55 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  56 + } else {
  57 + userService = value
  58 + }
  59 +
  60 + // 获取操作者
  61 + var operator *domain.User
  62 + if data, err := userService.OperatorFrom(createCooperationContractChangeLogCommand.CompanyId, createCooperationContractChangeLogCommand.OrgId, createCooperationContractChangeLogCommand.UserId); err != nil {
  63 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  64 + } else {
  65 + operator = data
  66 + }
  67 +
32 newCooperationContractChangeLog := &domain.CooperationContractChangeLog{ 68 newCooperationContractChangeLog := &domain.CooperationContractChangeLog{
33 IncentivesRule: createCooperationContractChangeLogCommand.IncentivesRule, 69 IncentivesRule: createCooperationContractChangeLogCommand.IncentivesRule,
34 IncentivesRuleDetail: createCooperationContractChangeLogCommand.IncentivesRuleDetail, 70 IncentivesRuleDetail: createCooperationContractChangeLogCommand.IncentivesRuleDetail,
35 OperationType: createCooperationContractChangeLogCommand.OperationType, 71 OperationType: createCooperationContractChangeLogCommand.OperationType,
36 Undertakers: createCooperationContractChangeLogCommand.Undertakers, 72 Undertakers: createCooperationContractChangeLogCommand.Undertakers,
37 CooperationContractNumber: createCooperationContractChangeLogCommand.CooperationContractNumber, 73 CooperationContractNumber: createCooperationContractChangeLogCommand.CooperationContractNumber,
38 - //CompanyId: createCooperationContractChangeLogCommand.CompanyId,  
39 - //OrgId: createCooperationContractChangeLogCommand.OrgId,  
40 - //UserId: createCooperationContractChangeLogCommand.UserId, 74 + Company: company,
  75 + Operator: operator,
  76 + UpdatedAt: time.Time{},
  77 + DeletedAt: time.Time{},
  78 + CreatedAt: time.Now(),
41 } 79 }
42 var cooperationContractChangeLogRepository domain.CooperationContractChangeLogRepository 80 var cooperationContractChangeLogRepository domain.CooperationContractChangeLogRepository
43 if value, err := factory.CreateCooperationContractChangeLogRepository(map[string]interface{}{ 81 if value, err := factory.CreateCooperationContractChangeLogRepository(map[string]interface{}{
@@ -57,7 +95,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService) @@ -57,7 +95,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService)
57 } 95 }
58 } 96 }
59 97
60 -// 返回共创合约变更日志 98 +// GetCooperationContractChangeLog 返回共创合约变更日志
61 func (cooperationContractChangeLogService *CooperationContractChangeLogService) GetCooperationContractChangeLog(getCooperationContractChangeLogQuery *query.GetCooperationContractChangeLogQuery) (interface{}, error) { 99 func (cooperationContractChangeLogService *CooperationContractChangeLogService) GetCooperationContractChangeLog(getCooperationContractChangeLogQuery *query.GetCooperationContractChangeLogQuery) (interface{}, error) {
62 if err := getCooperationContractChangeLogQuery.ValidateQuery(); err != nil { 100 if err := getCooperationContractChangeLogQuery.ValidateQuery(); err != nil {
63 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 101 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -70,7 +108,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService) @@ -70,7 +108,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService)
70 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 108 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
71 } 109 }
72 defer func() { 110 defer func() {
73 - transactionContext.RollbackTransaction() 111 + _ = transactionContext.RollbackTransaction()
74 }() 112 }()
75 var cooperationContractChangeLogRepository domain.CooperationContractChangeLogRepository 113 var cooperationContractChangeLogRepository domain.CooperationContractChangeLogRepository
76 if value, err := factory.CreateCooperationContractChangeLogRepository(map[string]interface{}{ 114 if value, err := factory.CreateCooperationContractChangeLogRepository(map[string]interface{}{
@@ -85,7 +123,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService) @@ -85,7 +123,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService)
85 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 123 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
86 } 124 }
87 if cooperationContractChangeLog == nil { 125 if cooperationContractChangeLog == nil {
88 - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getCooperationContractChangeLogQuery.CooperationContractChangeLogId))) 126 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(getCooperationContractChangeLogQuery.CooperationContractChangeLogId, 10)))
89 } else { 127 } else {
90 if err := transactionContext.CommitTransaction(); err != nil { 128 if err := transactionContext.CommitTransaction(); err != nil {
91 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 129 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -94,7 +132,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService) @@ -94,7 +132,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService)
94 } 132 }
95 } 133 }
96 134
97 -// 返回共创合约变更日志列表 135 +// ListCooperationContractChangeLog 返回共创合约变更日志列表
98 func (cooperationContractChangeLogService *CooperationContractChangeLogService) ListCooperationContractChangeLog(listCooperationContractChangeLogQuery *query.ListCooperationContractChangeLogQuery) (interface{}, error) { 136 func (cooperationContractChangeLogService *CooperationContractChangeLogService) ListCooperationContractChangeLog(listCooperationContractChangeLogQuery *query.ListCooperationContractChangeLogQuery) (interface{}, error) {
99 if err := listCooperationContractChangeLogQuery.ValidateQuery(); err != nil { 137 if err := listCooperationContractChangeLogQuery.ValidateQuery(); err != nil {
100 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 138 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -107,7 +145,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService) @@ -107,7 +145,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService)
107 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 145 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
108 } 146 }
109 defer func() { 147 defer func() {
110 - transactionContext.RollbackTransaction() 148 + _ = transactionContext.RollbackTransaction()
111 }() 149 }()
112 var cooperationContractChangeLogRepository domain.CooperationContractChangeLogRepository 150 var cooperationContractChangeLogRepository domain.CooperationContractChangeLogRepository
113 if value, err := factory.CreateCooperationContractChangeLogRepository(map[string]interface{}{ 151 if value, err := factory.CreateCooperationContractChangeLogRepository(map[string]interface{}{
@@ -130,7 +168,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService) @@ -130,7 +168,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService)
130 } 168 }
131 } 169 }
132 170
133 -// 移除共创合约变更日志 171 +// RemoveCooperationContractChangeLog 移除共创合约变更日志
134 func (cooperationContractChangeLogService *CooperationContractChangeLogService) RemoveCooperationContractChangeLog(removeCooperationContractChangeLogCommand *command.RemoveCooperationContractChangeLogCommand) (interface{}, error) { 172 func (cooperationContractChangeLogService *CooperationContractChangeLogService) RemoveCooperationContractChangeLog(removeCooperationContractChangeLogCommand *command.RemoveCooperationContractChangeLogCommand) (interface{}, error) {
135 if err := removeCooperationContractChangeLogCommand.ValidateCommand(); err != nil { 173 if err := removeCooperationContractChangeLogCommand.ValidateCommand(); err != nil {
136 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 174 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -143,7 +181,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService) @@ -143,7 +181,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService)
143 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 181 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
144 } 182 }
145 defer func() { 183 defer func() {
146 - transactionContext.RollbackTransaction() 184 + _ = transactionContext.RollbackTransaction()
147 }() 185 }()
148 var cooperationContractChangeLogRepository domain.CooperationContractChangeLogRepository 186 var cooperationContractChangeLogRepository domain.CooperationContractChangeLogRepository
149 if value, err := factory.CreateCooperationContractChangeLogRepository(map[string]interface{}{ 187 if value, err := factory.CreateCooperationContractChangeLogRepository(map[string]interface{}{
@@ -158,7 +196,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService) @@ -158,7 +196,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService)
158 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 196 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
159 } 197 }
160 if cooperationContractChangeLog == nil { 198 if cooperationContractChangeLog == nil {
161 - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(removeCooperationContractChangeLogCommand.CooperationContractChangeLogId))) 199 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(removeCooperationContractChangeLogCommand.CooperationContractChangeLogId, 10)))
162 } 200 }
163 if cooperationContractChangeLog, err := cooperationContractChangeLogRepository.Remove(cooperationContractChangeLog); err != nil { 201 if cooperationContractChangeLog, err := cooperationContractChangeLogRepository.Remove(cooperationContractChangeLog); err != nil {
164 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 202 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -170,7 +208,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService) @@ -170,7 +208,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService)
170 } 208 }
171 } 209 }
172 210
173 -// 共创合约变更记录搜索 211 +// SearchCooperationContractChangeLog 共创合约变更记录搜索
174 func (cooperationContractChangeLogService *CooperationContractChangeLogService) SearchCooperationContractChangeLog(searchCooperationContractChangeLogQuery *query.SearchCooperationContractChangeLogQuery) (interface{}, error) { 212 func (cooperationContractChangeLogService *CooperationContractChangeLogService) SearchCooperationContractChangeLog(searchCooperationContractChangeLogQuery *query.SearchCooperationContractChangeLogQuery) (interface{}, error) {
175 if err := searchCooperationContractChangeLogQuery.ValidateQuery(); err != nil { 213 if err := searchCooperationContractChangeLogQuery.ValidateQuery(); err != nil {
176 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 214 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -183,7 +221,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService) @@ -183,7 +221,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService)
183 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 221 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
184 } 222 }
185 defer func() { 223 defer func() {
186 - transactionContext.RollbackTransaction() 224 + _ = transactionContext.RollbackTransaction()
187 }() 225 }()
188 if err := transactionContext.CommitTransaction(); err != nil { 226 if err := transactionContext.CommitTransaction(); err != nil {
189 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 227 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -191,7 +229,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService) @@ -191,7 +229,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService)
191 return nil, nil 229 return nil, nil
192 } 230 }
193 231
194 -// 更新共创合约变更日志 232 +// UpdateCooperationContractChangeLog 更新共创合约变更日志
195 func (cooperationContractChangeLogService *CooperationContractChangeLogService) UpdateCooperationContractChangeLog(updateCooperationContractChangeLogCommand *command.UpdateCooperationContractChangeLogCommand) (interface{}, error) { 233 func (cooperationContractChangeLogService *CooperationContractChangeLogService) UpdateCooperationContractChangeLog(updateCooperationContractChangeLogCommand *command.UpdateCooperationContractChangeLogCommand) (interface{}, error) {
196 if err := updateCooperationContractChangeLogCommand.ValidateCommand(); err != nil { 234 if err := updateCooperationContractChangeLogCommand.ValidateCommand(); err != nil {
197 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 235 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -204,7 +242,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService) @@ -204,7 +242,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService)
204 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 242 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
205 } 243 }
206 defer func() { 244 defer func() {
207 - transactionContext.RollbackTransaction() 245 + _ = transactionContext.RollbackTransaction()
208 }() 246 }()
209 var cooperationContractChangeLogRepository domain.CooperationContractChangeLogRepository 247 var cooperationContractChangeLogRepository domain.CooperationContractChangeLogRepository
210 if value, err := factory.CreateCooperationContractChangeLogRepository(map[string]interface{}{ 248 if value, err := factory.CreateCooperationContractChangeLogRepository(map[string]interface{}{
@@ -8,13 +8,16 @@ import ( @@ -8,13 +8,16 @@ import (
8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationMode/query" 8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationMode/query"
9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory" 9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" 10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
  11 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
  12 + "strconv"
  13 + "time"
11 ) 14 )
12 15
13 -// 共创模式服务 16 +// CooperationModeService 共创模式服务
14 type CooperationModeService struct { 17 type CooperationModeService struct {
15 } 18 }
16 19
17 -// 创建共创模式服务 20 +// CreateCooperationMode 创建共创模式服务
18 func (cooperationModeService *CooperationModeService) CreateCooperationMode(createCooperationModeCommand *command.CreateCooperationModeCommand) (interface{}, error) { 21 func (cooperationModeService *CooperationModeService) CreateCooperationMode(createCooperationModeCommand *command.CreateCooperationModeCommand) (interface{}, error) {
19 if err := createCooperationModeCommand.ValidateCommand(); err != nil { 22 if err := createCooperationModeCommand.ValidateCommand(); err != nil {
20 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 23 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -27,15 +30,68 @@ func (cooperationModeService *CooperationModeService) CreateCooperationMode(crea @@ -27,15 +30,68 @@ func (cooperationModeService *CooperationModeService) CreateCooperationMode(crea
27 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 30 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
28 } 31 }
29 defer func() { 32 defer func() {
30 - transactionContext.RollbackTransaction() 33 + _ = transactionContext.RollbackTransaction()
31 }() 34 }()
  35 +
  36 + // 用户REST服务初始化
  37 + var userService service.UserService
  38 + if value, err := factory.CreateUserService(map[string]interface{}{}); err != nil {
  39 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  40 + } else {
  41 + userService = value
  42 + }
  43 +
  44 + // 获取承接人
  45 + var operator *domain.User
  46 + if data, err := userService.OperatorFrom(createCooperationModeCommand.CompanyId, createCooperationModeCommand.OrgId, createCooperationModeCommand.UserId); err != nil {
  47 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  48 + } else {
  49 + operator = data
  50 + }
  51 +
  52 + // 公司REST服务初始化
  53 + var companyService service.CompanyService
  54 + if value, err := factory.CreateCompanyService(map[string]interface{}{}); err != nil {
  55 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  56 + } else {
  57 + companyService = value
  58 + }
  59 +
  60 + // 获取公司信息
  61 + var company *domain.Company
  62 + if data, err := companyService.CompanyFrom(createCooperationModeCommand.CompanyId); err != nil {
  63 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  64 + } else {
  65 + company = data
  66 + }
  67 +
  68 + // 组织机构REST服务初始化
  69 + var organizationService service.OrgService
  70 + if value, err := factory.CreateOrganizationService(map[string]interface{}{}); err != nil {
  71 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  72 + } else {
  73 + organizationService = value
  74 + }
  75 +
  76 + // 获取组织机构信息
  77 + var organization *domain.Org
  78 + if data, err := organizationService.OrgFrom(createCooperationModeCommand.CompanyId, createCooperationModeCommand.OrgId); err != nil {
  79 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  80 + } else {
  81 + organization = data
  82 + }
  83 +
32 newCooperationMode := &domain.CooperationMode{ 84 newCooperationMode := &domain.CooperationMode{
33 CooperationModeName: createCooperationModeCommand.CooperationModeName, 85 CooperationModeName: createCooperationModeCommand.CooperationModeName,
34 CooperationModeNumber: createCooperationModeCommand.CooperationModeNumber, 86 CooperationModeNumber: createCooperationModeCommand.CooperationModeNumber,
35 Remarks: createCooperationModeCommand.Remarks, 87 Remarks: createCooperationModeCommand.Remarks,
36 - //CompanyId: createCooperationModeCommand.CompanyId,  
37 - //OrgId: createCooperationModeCommand.OrgId,  
38 - //UserId: createCooperationModeCommand.UserId, 88 + Company: company,
  89 + Org: organization,
  90 + Operator: operator,
  91 + OperateTime: time.Now(),
  92 + UpdatedAt: time.Time{},
  93 + DeletedAt: time.Time{},
  94 + CreatedAt: time.Now(),
39 } 95 }
40 var cooperationModeRepository domain.CooperationModeRepository 96 var cooperationModeRepository domain.CooperationModeRepository
41 if value, err := factory.CreateCooperationModeRepository(map[string]interface{}{ 97 if value, err := factory.CreateCooperationModeRepository(map[string]interface{}{
@@ -55,7 +111,7 @@ func (cooperationModeService *CooperationModeService) CreateCooperationMode(crea @@ -55,7 +111,7 @@ func (cooperationModeService *CooperationModeService) CreateCooperationMode(crea
55 } 111 }
56 } 112 }
57 113
58 -// 返回共创模式服务 114 +// GetCooperationMode 返回共创模式服务
59 func (cooperationModeService *CooperationModeService) GetCooperationMode(getCooperationModeQuery *query.GetCooperationModeQuery) (interface{}, error) { 115 func (cooperationModeService *CooperationModeService) GetCooperationMode(getCooperationModeQuery *query.GetCooperationModeQuery) (interface{}, error) {
60 if err := getCooperationModeQuery.ValidateQuery(); err != nil { 116 if err := getCooperationModeQuery.ValidateQuery(); err != nil {
61 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 117 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -68,7 +124,7 @@ func (cooperationModeService *CooperationModeService) GetCooperationMode(getCoop @@ -68,7 +124,7 @@ func (cooperationModeService *CooperationModeService) GetCooperationMode(getCoop
68 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 124 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
69 } 125 }
70 defer func() { 126 defer func() {
71 - transactionContext.RollbackTransaction() 127 + _ = transactionContext.RollbackTransaction()
72 }() 128 }()
73 var cooperationModeRepository domain.CooperationModeRepository 129 var cooperationModeRepository domain.CooperationModeRepository
74 if value, err := factory.CreateCooperationModeRepository(map[string]interface{}{ 130 if value, err := factory.CreateCooperationModeRepository(map[string]interface{}{
@@ -83,7 +139,7 @@ func (cooperationModeService *CooperationModeService) GetCooperationMode(getCoop @@ -83,7 +139,7 @@ func (cooperationModeService *CooperationModeService) GetCooperationMode(getCoop
83 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 139 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
84 } 140 }
85 if cooperationMode == nil { 141 if cooperationMode == nil {
86 - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getCooperationModeQuery.CooperationModeId))) 142 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(getCooperationModeQuery.CooperationModeId, 10)))
87 } else { 143 } else {
88 if err := transactionContext.CommitTransaction(); err != nil { 144 if err := transactionContext.CommitTransaction(); err != nil {
89 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 145 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -92,7 +148,7 @@ func (cooperationModeService *CooperationModeService) GetCooperationMode(getCoop @@ -92,7 +148,7 @@ func (cooperationModeService *CooperationModeService) GetCooperationMode(getCoop
92 } 148 }
93 } 149 }
94 150
95 -// 返回共创模式服务列表 151 +// ListCooperationMode 返回共创模式服务列表
96 func (cooperationModeService *CooperationModeService) ListCooperationMode(listCooperationModeQuery *query.ListCooperationModeQuery) (interface{}, error) { 152 func (cooperationModeService *CooperationModeService) ListCooperationMode(listCooperationModeQuery *query.ListCooperationModeQuery) (interface{}, error) {
97 if err := listCooperationModeQuery.ValidateQuery(); err != nil { 153 if err := listCooperationModeQuery.ValidateQuery(); err != nil {
98 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 154 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -105,7 +161,7 @@ func (cooperationModeService *CooperationModeService) ListCooperationMode(listCo @@ -105,7 +161,7 @@ func (cooperationModeService *CooperationModeService) ListCooperationMode(listCo
105 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 161 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
106 } 162 }
107 defer func() { 163 defer func() {
108 - transactionContext.RollbackTransaction() 164 + _ = transactionContext.RollbackTransaction()
109 }() 165 }()
110 var cooperationModeRepository domain.CooperationModeRepository 166 var cooperationModeRepository domain.CooperationModeRepository
111 if value, err := factory.CreateCooperationModeRepository(map[string]interface{}{ 167 if value, err := factory.CreateCooperationModeRepository(map[string]interface{}{
@@ -128,7 +184,7 @@ func (cooperationModeService *CooperationModeService) ListCooperationMode(listCo @@ -128,7 +184,7 @@ func (cooperationModeService *CooperationModeService) ListCooperationMode(listCo
128 } 184 }
129 } 185 }
130 186
131 -// 移除共创模式服务 187 +// RemoveCooperationMode 移除共创模式服务
132 func (cooperationModeService *CooperationModeService) RemoveCooperationMode(removeCooperationModeCommand *command.RemoveCooperationModeCommand) (interface{}, error) { 188 func (cooperationModeService *CooperationModeService) RemoveCooperationMode(removeCooperationModeCommand *command.RemoveCooperationModeCommand) (interface{}, error) {
133 if err := removeCooperationModeCommand.ValidateCommand(); err != nil { 189 if err := removeCooperationModeCommand.ValidateCommand(); err != nil {
134 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 190 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -141,7 +197,7 @@ func (cooperationModeService *CooperationModeService) RemoveCooperationMode(remo @@ -141,7 +197,7 @@ func (cooperationModeService *CooperationModeService) RemoveCooperationMode(remo
141 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 197 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
142 } 198 }
143 defer func() { 199 defer func() {
144 - transactionContext.RollbackTransaction() 200 + _ = transactionContext.RollbackTransaction()
145 }() 201 }()
146 var cooperationModeRepository domain.CooperationModeRepository 202 var cooperationModeRepository domain.CooperationModeRepository
147 if value, err := factory.CreateCooperationModeRepository(map[string]interface{}{ 203 if value, err := factory.CreateCooperationModeRepository(map[string]interface{}{
@@ -156,7 +212,7 @@ func (cooperationModeService *CooperationModeService) RemoveCooperationMode(remo @@ -156,7 +212,7 @@ func (cooperationModeService *CooperationModeService) RemoveCooperationMode(remo
156 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 212 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
157 } 213 }
158 if cooperationMode == nil { 214 if cooperationMode == nil {
159 - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(removeCooperationModeCommand.CooperationModeId))) 215 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(removeCooperationModeCommand.CooperationModeId, 10)))
160 } 216 }
161 if cooperationMode, err := cooperationModeRepository.Remove(cooperationMode); err != nil { 217 if cooperationMode, err := cooperationModeRepository.Remove(cooperationMode); err != nil {
162 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 218 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -168,7 +224,7 @@ func (cooperationModeService *CooperationModeService) RemoveCooperationMode(remo @@ -168,7 +224,7 @@ func (cooperationModeService *CooperationModeService) RemoveCooperationMode(remo
168 } 224 }
169 } 225 }
170 226
171 -// 查询共创模式 227 +// SearchCooperationMode 查询共创模式
172 func (cooperationModeService *CooperationModeService) SearchCooperationMode(searchCooperationModeQuery *query.SearchCooperationModeQuery) (interface{}, error) { 228 func (cooperationModeService *CooperationModeService) SearchCooperationMode(searchCooperationModeQuery *query.SearchCooperationModeQuery) (interface{}, error) {
173 if err := searchCooperationModeQuery.ValidateQuery(); err != nil { 229 if err := searchCooperationModeQuery.ValidateQuery(); err != nil {
174 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 230 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -181,7 +237,7 @@ func (cooperationModeService *CooperationModeService) SearchCooperationMode(sear @@ -181,7 +237,7 @@ func (cooperationModeService *CooperationModeService) SearchCooperationMode(sear
181 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 237 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
182 } 238 }
183 defer func() { 239 defer func() {
184 - transactionContext.RollbackTransaction() 240 + _ = transactionContext.RollbackTransaction()
185 }() 241 }()
186 if err := transactionContext.CommitTransaction(); err != nil { 242 if err := transactionContext.CommitTransaction(); err != nil {
187 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 243 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -189,7 +245,7 @@ func (cooperationModeService *CooperationModeService) SearchCooperationMode(sear @@ -189,7 +245,7 @@ func (cooperationModeService *CooperationModeService) SearchCooperationMode(sear
189 return nil, nil 245 return nil, nil
190 } 246 }
191 247
192 -// 更新共创模式服务 248 +// UpdateCooperationMode 更新共创模式服务
193 func (cooperationModeService *CooperationModeService) UpdateCooperationMode(updateCooperationModeCommand *command.UpdateCooperationModeCommand) (interface{}, error) { 249 func (cooperationModeService *CooperationModeService) UpdateCooperationMode(updateCooperationModeCommand *command.UpdateCooperationModeCommand) (interface{}, error) {
194 if err := updateCooperationModeCommand.ValidateCommand(); err != nil { 250 if err := updateCooperationModeCommand.ValidateCommand(); err != nil {
195 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 251 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -202,7 +258,7 @@ func (cooperationModeService *CooperationModeService) UpdateCooperationMode(upda @@ -202,7 +258,7 @@ func (cooperationModeService *CooperationModeService) UpdateCooperationMode(upda
202 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 258 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
203 } 259 }
204 defer func() { 260 defer func() {
205 - transactionContext.RollbackTransaction() 261 + _ = transactionContext.RollbackTransaction()
206 }() 262 }()
207 var cooperationModeRepository domain.CooperationModeRepository 263 var cooperationModeRepository domain.CooperationModeRepository
208 if value, err := factory.CreateCooperationModeRepository(map[string]interface{}{ 264 if value, err := factory.CreateCooperationModeRepository(map[string]interface{}{
@@ -8,6 +8,9 @@ import ( @@ -8,6 +8,9 @@ import (
8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationProject/query" 8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationProject/query"
9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory" 9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" 10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
  11 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
  12 + "strconv"
  13 + "time"
11 ) 14 )
12 15
13 // CooperationProjectService 共创项目服务 16 // CooperationProjectService 共创项目服务
@@ -27,7 +30,7 @@ func (cooperationProjectService *CooperationProjectService) CheckUndertaker(chec @@ -27,7 +30,7 @@ func (cooperationProjectService *CooperationProjectService) CheckUndertaker(chec
27 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 30 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
28 } 31 }
29 defer func() { 32 defer func() {
30 - transactionContext.RollbackTransaction() 33 + _ = transactionContext.RollbackTransaction()
31 }() 34 }()
32 if err := transactionContext.CommitTransaction(); err != nil { 35 if err := transactionContext.CommitTransaction(); err != nil {
33 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 36 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -48,17 +51,88 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro @@ -48,17 +51,88 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro
48 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 51 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
49 } 52 }
50 defer func() { 53 defer func() {
51 - transactionContext.RollbackTransaction() 54 + _ = transactionContext.RollbackTransaction()
52 }() 55 }()
  56 +
  57 + // 用户REST服务初始化
  58 + var userService service.UserService
  59 + if value, err := factory.CreateUserService(map[string]interface{}{}); err != nil {
  60 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  61 + } else {
  62 + userService = value
  63 + }
  64 +
  65 + // 获取操作人
  66 + var operator *domain.User
  67 + if data, err := userService.OperatorFrom(createCooperationProjectCommand.CompanyId, createCooperationProjectCommand.OrgId, createCooperationProjectCommand.UserId); err != nil {
  68 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  69 + } else {
  70 + operator = data
  71 + }
  72 +
  73 + // Sponsor
  74 + var sponsor *domain.User
  75 + if data, err := userService.UserFrom(createCooperationProjectCommand.CompanyId, createCooperationProjectCommand.OrgId, createCooperationProjectCommand.UserId); err != nil {
  76 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  77 + } else {
  78 + sponsor = data
  79 + }
  80 +
  81 + // Publisher
  82 + var publisher *domain.User
  83 + if data, err := userService.UserFrom(createCooperationProjectCommand.CompanyId, createCooperationProjectCommand.OrgId, createCooperationProjectCommand.UserId); err != nil {
  84 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  85 + } else {
  86 + publisher = data
  87 + }
  88 +
  89 + // 公司REST服务初始化
  90 + var companyService service.CompanyService
  91 + if value, err := factory.CreateCompanyService(map[string]interface{}{}); err != nil {
  92 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  93 + } else {
  94 + companyService = value
  95 + }
  96 +
  97 + // 获取公司信息
  98 + var company *domain.Company
  99 + if data, err := companyService.CompanyFrom(createCooperationProjectCommand.CompanyId); err != nil {
  100 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  101 + } else {
  102 + company = data
  103 + }
  104 +
  105 + // 组织机构REST服务初始化
  106 + var organizationService service.OrgService
  107 + if value, err := factory.CreateOrganizationService(map[string]interface{}{}); err != nil {
  108 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  109 + } else {
  110 + organizationService = value
  111 + }
  112 +
  113 + // 获取组织机构信息
  114 + var organization *domain.Org
  115 + if data, err := organizationService.OrgFrom(createCooperationProjectCommand.CompanyId, createCooperationProjectCommand.OrgId); err != nil {
  116 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  117 + } else {
  118 + organization = data
  119 + }
  120 +
53 newCooperationProject := &domain.CooperationProject{ 121 newCooperationProject := &domain.CooperationProject{
  122 + CooperationProjectNumber: "",
54 CooperationProjectName: createCooperationProjectCommand.CooperationProjectName, 123 CooperationProjectName: createCooperationProjectCommand.CooperationProjectName,
55 CooperationProjectUndertakerType: createCooperationProjectCommand.CooperationProjectUndertakerType, 124 CooperationProjectUndertakerType: createCooperationProjectCommand.CooperationProjectUndertakerType,
56 - //SponsorUid: createCooperationProjectCommand.SponsorUid,  
57 - //PublisherUid: createCooperationProjectCommand.PublisherUid,  
58 - CooperationProjectDescription: createCooperationProjectCommand.CooperationProjectDescription,  
59 - //CompanyId: createCooperationProjectCommand.CompanyId,  
60 - //OrgId: createCooperationProjectCommand.OrgId,  
61 - //UserId: createCooperationProjectCommand.UserId, 125 + CooperationProjectSponsor: sponsor,
  126 + CooperationProjectPublisher: publisher,
  127 + CooperationProjectDescription: createCooperationProjectCommand.CooperationProjectDescription,
  128 + Company: company,
  129 + Org: organization,
  130 + Operator: operator,
  131 + OperateTime: time.Now(),
  132 + Status: 0,
  133 + UpdatedAt: time.Time{},
  134 + DeletedAt: time.Time{},
  135 + CreatedAt: time.Now(),
62 } 136 }
63 var cooperationProjectRepository domain.CooperationProjectRepository 137 var cooperationProjectRepository domain.CooperationProjectRepository
64 if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{ 138 if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
@@ -91,7 +165,7 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec @@ -91,7 +165,7 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
91 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 165 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
92 } 166 }
93 defer func() { 167 defer func() {
94 - transactionContext.RollbackTransaction() 168 + _ = transactionContext.RollbackTransaction()
95 }() 169 }()
96 var cooperationProjectRepository domain.CooperationProjectRepository 170 var cooperationProjectRepository domain.CooperationProjectRepository
97 if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{ 171 if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
@@ -106,7 +180,7 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec @@ -106,7 +180,7 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
106 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 180 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
107 } 181 }
108 if cooperationProject == nil { 182 if cooperationProject == nil {
109 - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getCooperationProjectQuery.CooperationProjectId))) 183 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(getCooperationProjectQuery.CooperationProjectId, 10)))
110 } else { 184 } else {
111 if err := transactionContext.CommitTransaction(); err != nil { 185 if err := transactionContext.CommitTransaction(); err != nil {
112 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 186 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -128,7 +202,7 @@ func (cooperationProjectService *CooperationProjectService) ListCooperationProje @@ -128,7 +202,7 @@ func (cooperationProjectService *CooperationProjectService) ListCooperationProje
128 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 202 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
129 } 203 }
130 defer func() { 204 defer func() {
131 - transactionContext.RollbackTransaction() 205 + _ = transactionContext.RollbackTransaction()
132 }() 206 }()
133 var cooperationProjectRepository domain.CooperationProjectRepository 207 var cooperationProjectRepository domain.CooperationProjectRepository
134 if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{ 208 if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
@@ -164,7 +238,7 @@ func (cooperationProjectService *CooperationProjectService) ReleaseCooperationPr @@ -164,7 +238,7 @@ func (cooperationProjectService *CooperationProjectService) ReleaseCooperationPr
164 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 238 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
165 } 239 }
166 defer func() { 240 defer func() {
167 - transactionContext.RollbackTransaction() 241 + _ = transactionContext.RollbackTransaction()
168 }() 242 }()
169 if err := transactionContext.CommitTransaction(); err != nil { 243 if err := transactionContext.CommitTransaction(); err != nil {
170 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 244 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -185,7 +259,7 @@ func (cooperationProjectService *CooperationProjectService) RemoveCooperationPro @@ -185,7 +259,7 @@ func (cooperationProjectService *CooperationProjectService) RemoveCooperationPro
185 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 259 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
186 } 260 }
187 defer func() { 261 defer func() {
188 - transactionContext.RollbackTransaction() 262 + _ = transactionContext.RollbackTransaction()
189 }() 263 }()
190 var cooperationProjectRepository domain.CooperationProjectRepository 264 var cooperationProjectRepository domain.CooperationProjectRepository
191 if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{ 265 if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
@@ -200,7 +274,7 @@ func (cooperationProjectService *CooperationProjectService) RemoveCooperationPro @@ -200,7 +274,7 @@ func (cooperationProjectService *CooperationProjectService) RemoveCooperationPro
200 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 274 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
201 } 275 }
202 if cooperationProject == nil { 276 if cooperationProject == nil {
203 - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(removeCooperationProjectCommand.CooperationProjectId))) 277 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(removeCooperationProjectCommand.CooperationProjectId, 10)))
204 } 278 }
205 if cooperationProject, err := cooperationProjectRepository.Remove(cooperationProject); err != nil { 279 if cooperationProject, err := cooperationProjectRepository.Remove(cooperationProject); err != nil {
206 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 280 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -225,7 +299,7 @@ func (cooperationProjectService *CooperationProjectService) SearchCooperationPro @@ -225,7 +299,7 @@ func (cooperationProjectService *CooperationProjectService) SearchCooperationPro
225 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 299 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
226 } 300 }
227 defer func() { 301 defer func() {
228 - transactionContext.RollbackTransaction() 302 + _ = transactionContext.RollbackTransaction()
229 }() 303 }()
230 if err := transactionContext.CommitTransaction(); err != nil { 304 if err := transactionContext.CommitTransaction(); err != nil {
231 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 305 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -246,7 +320,7 @@ func (cooperationProjectService *CooperationProjectService) UpdateCooperationPro @@ -246,7 +320,7 @@ func (cooperationProjectService *CooperationProjectService) UpdateCooperationPro
246 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 320 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
247 } 321 }
248 defer func() { 322 defer func() {
249 - transactionContext.RollbackTransaction() 323 + _ = transactionContext.RollbackTransaction()
250 }() 324 }()
251 var cooperationProjectRepository domain.CooperationProjectRepository 325 var cooperationProjectRepository domain.CooperationProjectRepository
252 if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{ 326 if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
@@ -8,13 +8,16 @@ import ( @@ -8,13 +8,16 @@ import (
8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/creditAccount/query" 8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/creditAccount/query"
9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory" 9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" 10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
  11 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
  12 + "strconv"
  13 + "time"
11 ) 14 )
12 15
13 -// 账期结算单服务 16 +// CreditAccountService 账期结算单服务
14 type CreditAccountService struct { 17 type CreditAccountService struct {
15 } 18 }
16 19
17 -// 创建账期结算单服务 20 +// CreateCreditAccount 创建账期结算单服务
18 func (creditAccountService *CreditAccountService) CreateCreditAccount(createCreditAccountCommand *command.CreateCreditAccountCommand) (interface{}, error) { 21 func (creditAccountService *CreditAccountService) CreateCreditAccount(createCreditAccountCommand *command.CreateCreditAccountCommand) (interface{}, error) {
19 if err := createCreditAccountCommand.ValidateCommand(); err != nil { 22 if err := createCreditAccountCommand.ValidateCommand(); err != nil {
20 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 23 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -27,13 +30,76 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred @@ -27,13 +30,76 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred
27 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 30 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
28 } 31 }
29 defer func() { 32 defer func() {
30 - transactionContext.RollbackTransaction() 33 + _ = transactionContext.RollbackTransaction()
31 }() 34 }()
  35 +
  36 + // 公司REST服务初始化
  37 + var companyService service.CompanyService
  38 + if value, err := factory.CreateCompanyService(map[string]interface{}{}); err != nil {
  39 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  40 + } else {
  41 + companyService = value
  42 + }
  43 +
  44 + // 获取公司信息
  45 + var company *domain.Company
  46 + if data, err := companyService.CompanyFrom(createCreditAccountCommand.CompanyId); err != nil {
  47 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  48 + } else {
  49 + company = data
  50 + }
  51 +
  52 + // 组织机构REST服务初始化
  53 + var organizationService service.OrgService
  54 + if value, err := factory.CreateOrganizationService(map[string]interface{}{}); err != nil {
  55 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  56 + } else {
  57 + organizationService = value
  58 + }
  59 +
  60 + // 获取组织机构信息
  61 + var organization *domain.Org
  62 + if data, err := organizationService.OrgFrom(createCreditAccountCommand.CompanyId, createCreditAccountCommand.OrgId); err != nil {
  63 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  64 + } else {
  65 + organization = data
  66 + }
  67 +
  68 + // 用户REST服务初始化
  69 + var userService service.UserService
  70 + if value, err := factory.CreateUserService(map[string]interface{}{}); err != nil {
  71 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  72 + } else {
  73 + userService = value
  74 + }
  75 +
  76 + // 获取操作人
  77 + var operator *domain.User
  78 + if data, err := userService.OperatorFrom(createCreditAccountCommand.CompanyId, createCreditAccountCommand.OrgId, createCreditAccountCommand.UserId); err != nil {
  79 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  80 + } else {
  81 + operator = data
  82 + }
  83 +
32 newCreditAccount := &domain.CreditAccount{ 84 newCreditAccount := &domain.CreditAccount{
33 - //CompanyId: createCreditAccountCommand.CompanyId,  
34 - //OrgId: createCreditAccountCommand.OrgId,  
35 - //UserId: createCreditAccountCommand.UserId, 85 + ActuallyPaidAmount: 0,
  86 + CreditAccountOrderNum: "",
  87 + PaymentStatus: 0,
  88 + PaymentTime: time.Time{},
  89 + SettlementAmount: 0,
  90 + SettlementTime: time.Time{},
  91 + CooperationContractNumber: "",
  92 + Participator: nil,
  93 + PaymentDocumentAttachment: nil,
  94 + Org: organization,
  95 + Company: company,
  96 + Operator: operator,
  97 + OperateTime: time.Now(),
  98 + CreatedAt: time.Now(),
  99 + DeletedAt: time.Time{},
  100 + UpdatedAt: time.Time{},
36 } 101 }
  102 +
37 var creditAccountRepository domain.CreditAccountRepository 103 var creditAccountRepository domain.CreditAccountRepository
38 if value, err := factory.CreateCreditAccountRepository(map[string]interface{}{ 104 if value, err := factory.CreateCreditAccountRepository(map[string]interface{}{
39 "transactionContext": transactionContext, 105 "transactionContext": transactionContext,
@@ -52,7 +118,7 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred @@ -52,7 +118,7 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred
52 } 118 }
53 } 119 }
54 120
55 -// 账期结算单排名 121 +// CreditAccountRanking 账期结算单排名
56 func (creditAccountService *CreditAccountService) CreditAccountRanking(creditAccountRankingQuery *query.CreditAccountRankingQuery) (interface{}, error) { 122 func (creditAccountService *CreditAccountService) CreditAccountRanking(creditAccountRankingQuery *query.CreditAccountRankingQuery) (interface{}, error) {
57 if err := creditAccountRankingQuery.ValidateQuery(); err != nil { 123 if err := creditAccountRankingQuery.ValidateQuery(); err != nil {
58 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 124 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -65,7 +131,7 @@ func (creditAccountService *CreditAccountService) CreditAccountRanking(creditAcc @@ -65,7 +131,7 @@ func (creditAccountService *CreditAccountService) CreditAccountRanking(creditAcc
65 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 131 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
66 } 132 }
67 defer func() { 133 defer func() {
68 - transactionContext.RollbackTransaction() 134 + _ = transactionContext.RollbackTransaction()
69 }() 135 }()
70 if err := transactionContext.CommitTransaction(); err != nil { 136 if err := transactionContext.CommitTransaction(); err != nil {
71 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 137 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -73,7 +139,7 @@ func (creditAccountService *CreditAccountService) CreditAccountRanking(creditAcc @@ -73,7 +139,7 @@ func (creditAccountService *CreditAccountService) CreditAccountRanking(creditAcc
73 return nil, nil 139 return nil, nil
74 } 140 }
75 141
76 -// 返回账期结算单服务 142 +// GetCreditAccount 返回账期结算单服务
77 func (creditAccountService *CreditAccountService) GetCreditAccount(getCreditAccountQuery *query.GetCreditAccountQuery) (interface{}, error) { 143 func (creditAccountService *CreditAccountService) GetCreditAccount(getCreditAccountQuery *query.GetCreditAccountQuery) (interface{}, error) {
78 if err := getCreditAccountQuery.ValidateQuery(); err != nil { 144 if err := getCreditAccountQuery.ValidateQuery(); err != nil {
79 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 145 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -86,7 +152,7 @@ func (creditAccountService *CreditAccountService) GetCreditAccount(getCreditAcco @@ -86,7 +152,7 @@ func (creditAccountService *CreditAccountService) GetCreditAccount(getCreditAcco
86 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 152 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
87 } 153 }
88 defer func() { 154 defer func() {
89 - transactionContext.RollbackTransaction() 155 + _ = transactionContext.RollbackTransaction()
90 }() 156 }()
91 var creditAccountRepository domain.CreditAccountRepository 157 var creditAccountRepository domain.CreditAccountRepository
92 if value, err := factory.CreateCreditAccountRepository(map[string]interface{}{ 158 if value, err := factory.CreateCreditAccountRepository(map[string]interface{}{
@@ -101,7 +167,7 @@ func (creditAccountService *CreditAccountService) GetCreditAccount(getCreditAcco @@ -101,7 +167,7 @@ func (creditAccountService *CreditAccountService) GetCreditAccount(getCreditAcco
101 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 167 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
102 } 168 }
103 if creditAccount == nil { 169 if creditAccount == nil {
104 - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getCreditAccountQuery.CreditAccountId))) 170 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(getCreditAccountQuery.CreditAccountId, 10)))
105 } else { 171 } else {
106 if err := transactionContext.CommitTransaction(); err != nil { 172 if err := transactionContext.CommitTransaction(); err != nil {
107 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 173 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -110,7 +176,7 @@ func (creditAccountService *CreditAccountService) GetCreditAccount(getCreditAcco @@ -110,7 +176,7 @@ func (creditAccountService *CreditAccountService) GetCreditAccount(getCreditAcco
110 } 176 }
111 } 177 }
112 178
113 -// 返回账期结算单服务列表 179 +// ListCreditAccount 返回账期结算单服务列表
114 func (creditAccountService *CreditAccountService) ListCreditAccount(listCreditAccountQuery *query.ListCreditAccountQuery) (interface{}, error) { 180 func (creditAccountService *CreditAccountService) ListCreditAccount(listCreditAccountQuery *query.ListCreditAccountQuery) (interface{}, error) {
115 if err := listCreditAccountQuery.ValidateQuery(); err != nil { 181 if err := listCreditAccountQuery.ValidateQuery(); err != nil {
116 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 182 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -123,7 +189,7 @@ func (creditAccountService *CreditAccountService) ListCreditAccount(listCreditAc @@ -123,7 +189,7 @@ func (creditAccountService *CreditAccountService) ListCreditAccount(listCreditAc
123 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 189 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
124 } 190 }
125 defer func() { 191 defer func() {
126 - transactionContext.RollbackTransaction() 192 + _ = transactionContext.RollbackTransaction()
127 }() 193 }()
128 var creditAccountRepository domain.CreditAccountRepository 194 var creditAccountRepository domain.CreditAccountRepository
129 if value, err := factory.CreateCreditAccountRepository(map[string]interface{}{ 195 if value, err := factory.CreateCreditAccountRepository(map[string]interface{}{
@@ -146,7 +212,7 @@ func (creditAccountService *CreditAccountService) ListCreditAccount(listCreditAc @@ -146,7 +212,7 @@ func (creditAccountService *CreditAccountService) ListCreditAccount(listCreditAc
146 } 212 }
147 } 213 }
148 214
149 -// 支付账期结算(支付分红) 215 +// PayCreditAccount 支付账期结算(支付分红)
150 func (creditAccountService *CreditAccountService) PayCreditAccount(payCreditAccountCommand *command.PayCreditAccountCommand) (interface{}, error) { 216 func (creditAccountService *CreditAccountService) PayCreditAccount(payCreditAccountCommand *command.PayCreditAccountCommand) (interface{}, error) {
151 if err := payCreditAccountCommand.ValidateCommand(); err != nil { 217 if err := payCreditAccountCommand.ValidateCommand(); err != nil {
152 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 218 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -159,7 +225,7 @@ func (creditAccountService *CreditAccountService) PayCreditAccount(payCreditAcco @@ -159,7 +225,7 @@ func (creditAccountService *CreditAccountService) PayCreditAccount(payCreditAcco
159 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 225 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
160 } 226 }
161 defer func() { 227 defer func() {
162 - transactionContext.RollbackTransaction() 228 + _ = transactionContext.RollbackTransaction()
163 }() 229 }()
164 if err := transactionContext.CommitTransaction(); err != nil { 230 if err := transactionContext.CommitTransaction(); err != nil {
165 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 231 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -167,7 +233,7 @@ func (creditAccountService *CreditAccountService) PayCreditAccount(payCreditAcco @@ -167,7 +233,7 @@ func (creditAccountService *CreditAccountService) PayCreditAccount(payCreditAcco
167 return nil, nil 233 return nil, nil
168 } 234 }
169 235
170 -// 移除账期结算单服务 236 +// RemoveCreditAccount 移除账期结算单服务
171 func (creditAccountService *CreditAccountService) RemoveCreditAccount(removeCreditAccountCommand *command.RemoveCreditAccountCommand) (interface{}, error) { 237 func (creditAccountService *CreditAccountService) RemoveCreditAccount(removeCreditAccountCommand *command.RemoveCreditAccountCommand) (interface{}, error) {
172 if err := removeCreditAccountCommand.ValidateCommand(); err != nil { 238 if err := removeCreditAccountCommand.ValidateCommand(); err != nil {
173 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 239 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -180,7 +246,7 @@ func (creditAccountService *CreditAccountService) RemoveCreditAccount(removeCred @@ -180,7 +246,7 @@ func (creditAccountService *CreditAccountService) RemoveCreditAccount(removeCred
180 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 246 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
181 } 247 }
182 defer func() { 248 defer func() {
183 - transactionContext.RollbackTransaction() 249 + _ = transactionContext.RollbackTransaction()
184 }() 250 }()
185 var creditAccountRepository domain.CreditAccountRepository 251 var creditAccountRepository domain.CreditAccountRepository
186 if value, err := factory.CreateCreditAccountRepository(map[string]interface{}{ 252 if value, err := factory.CreateCreditAccountRepository(map[string]interface{}{
@@ -195,7 +261,7 @@ func (creditAccountService *CreditAccountService) RemoveCreditAccount(removeCred @@ -195,7 +261,7 @@ func (creditAccountService *CreditAccountService) RemoveCreditAccount(removeCred
195 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 261 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
196 } 262 }
197 if creditAccount == nil { 263 if creditAccount == nil {
198 - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(removeCreditAccountCommand.CreditAccountId))) 264 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(removeCreditAccountCommand.CreditAccountId, 10)))
199 } 265 }
200 if creditAccount, err := creditAccountRepository.Remove(creditAccount); err != nil { 266 if creditAccount, err := creditAccountRepository.Remove(creditAccount); err != nil {
201 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 267 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -207,7 +273,7 @@ func (creditAccountService *CreditAccountService) RemoveCreditAccount(removeCred @@ -207,7 +273,7 @@ func (creditAccountService *CreditAccountService) RemoveCreditAccount(removeCred
207 } 273 }
208 } 274 }
209 275
210 -// 查询账期结算单 276 +// SearchCreditAccount 查询账期结算单
211 func (creditAccountService *CreditAccountService) SearchCreditAccount(searchCreditAccountQuery *query.SearchCreditAccountQuery) (interface{}, error) { 277 func (creditAccountService *CreditAccountService) SearchCreditAccount(searchCreditAccountQuery *query.SearchCreditAccountQuery) (interface{}, error) {
212 if err := searchCreditAccountQuery.ValidateQuery(); err != nil { 278 if err := searchCreditAccountQuery.ValidateQuery(); err != nil {
213 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 279 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -220,7 +286,7 @@ func (creditAccountService *CreditAccountService) SearchCreditAccount(searchCred @@ -220,7 +286,7 @@ func (creditAccountService *CreditAccountService) SearchCreditAccount(searchCred
220 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 286 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
221 } 287 }
222 defer func() { 288 defer func() {
223 - transactionContext.RollbackTransaction() 289 + _ = transactionContext.RollbackTransaction()
224 }() 290 }()
225 if err := transactionContext.CommitTransaction(); err != nil { 291 if err := transactionContext.CommitTransaction(); err != nil {
226 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 292 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -228,7 +294,7 @@ func (creditAccountService *CreditAccountService) SearchCreditAccount(searchCred @@ -228,7 +294,7 @@ func (creditAccountService *CreditAccountService) SearchCreditAccount(searchCred
228 return nil, nil 294 return nil, nil
229 } 295 }
230 296
231 -// 更新账期结算单服务 297 +// UpdateCreditAccount 更新账期结算单服务
232 func (creditAccountService *CreditAccountService) UpdateCreditAccount(updateCreditAccountCommand *command.UpdateCreditAccountCommand) (interface{}, error) { 298 func (creditAccountService *CreditAccountService) UpdateCreditAccount(updateCreditAccountCommand *command.UpdateCreditAccountCommand) (interface{}, error) {
233 if err := updateCreditAccountCommand.ValidateCommand(); err != nil { 299 if err := updateCreditAccountCommand.ValidateCommand(); err != nil {
234 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 300 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -241,7 +307,7 @@ func (creditAccountService *CreditAccountService) UpdateCreditAccount(updateCred @@ -241,7 +307,7 @@ func (creditAccountService *CreditAccountService) UpdateCreditAccount(updateCred
241 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 307 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
242 } 308 }
243 defer func() { 309 defer func() {
244 - transactionContext.RollbackTransaction() 310 + _ = transactionContext.RollbackTransaction()
245 }() 311 }()
246 var creditAccountRepository domain.CreditAccountRepository 312 var creditAccountRepository domain.CreditAccountRepository
247 if value, err := factory.CreateCreditAccountRepository(map[string]interface{}{ 313 if value, err := factory.CreateCreditAccountRepository(map[string]interface{}{
@@ -256,7 +322,7 @@ func (creditAccountService *CreditAccountService) UpdateCreditAccount(updateCred @@ -256,7 +322,7 @@ func (creditAccountService *CreditAccountService) UpdateCreditAccount(updateCred
256 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 322 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
257 } 323 }
258 if creditAccount == nil { 324 if creditAccount == nil {
259 - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateCreditAccountCommand.CreditAccountId))) 325 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(updateCreditAccountCommand.CreditAccountId, 10)))
260 } 326 }
261 if err := creditAccount.Update(tool_funs.SimpleStructToMap(updateCreditAccountCommand)); err != nil { 327 if err := creditAccount.Update(tool_funs.SimpleStructToMap(updateCreditAccountCommand)); err != nil {
262 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 328 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
@@ -8,6 +8,9 @@ import ( @@ -8,6 +8,9 @@ import (
8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsEstimate/query" 8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsEstimate/query"
9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory" 9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" 10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
  11 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
  12 + "strconv"
  13 + "time"
11 ) 14 )
12 15
13 // DividendsEstimateService 分红预算服务 16 // DividendsEstimateService 分红预算服务
@@ -27,7 +30,7 @@ func (dividendsEstimateService *DividendsEstimateService) CancelDividendsEstimat @@ -27,7 +30,7 @@ func (dividendsEstimateService *DividendsEstimateService) CancelDividendsEstimat
27 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 30 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
28 } 31 }
29 defer func() { 32 defer func() {
30 - transactionContext.RollbackTransaction() 33 + _ = transactionContext.RollbackTransaction()
31 }() 34 }()
32 if err := transactionContext.CommitTransaction(); err != nil { 35 if err := transactionContext.CommitTransaction(); err != nil {
33 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 36 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -48,13 +51,77 @@ func (dividendsEstimateService *DividendsEstimateService) CreateDividendsEstimat @@ -48,13 +51,77 @@ func (dividendsEstimateService *DividendsEstimateService) CreateDividendsEstimat
48 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 51 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
49 } 52 }
50 defer func() { 53 defer func() {
51 - transactionContext.RollbackTransaction() 54 + _ = transactionContext.RollbackTransaction()
52 }() 55 }()
  56 +
  57 + // 公司REST服务初始化
  58 + var companyService service.CompanyService
  59 + if value, err := factory.CreateCompanyService(map[string]interface{}{}); err != nil {
  60 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  61 + } else {
  62 + companyService = value
  63 + }
  64 +
  65 + // 获取公司信息
  66 + var company *domain.Company
  67 + if data, err := companyService.CompanyFrom(createDividendsEstimateCommand.CompanyId); err != nil {
  68 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  69 + } else {
  70 + company = data
  71 + }
  72 +
  73 + // 组织机构REST服务初始化
  74 + var organizationService service.OrgService
  75 + if value, err := factory.CreateOrganizationService(map[string]interface{}{}); err != nil {
  76 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  77 + } else {
  78 + organizationService = value
  79 + }
  80 +
  81 + // 获取组织机构信息
  82 + var organization *domain.Org
  83 + if data, err := organizationService.OrgFrom(createDividendsEstimateCommand.CompanyId, createDividendsEstimateCommand.OrgId); err != nil {
  84 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  85 + } else {
  86 + organization = data
  87 + }
  88 +
  89 + // 用户REST服务初始化
  90 + var userService service.UserService
  91 + if value, err := factory.CreateUserService(map[string]interface{}{}); err != nil {
  92 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  93 + } else {
  94 + userService = value
  95 + }
  96 +
  97 + // 获取操作人
  98 + var operator *domain.User
  99 + if data, err := userService.OperatorFrom(createDividendsEstimateCommand.CompanyId, createDividendsEstimateCommand.OrgId, createDividendsEstimateCommand.UserId); err != nil {
  100 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  101 + } else {
  102 + operator = data
  103 + }
  104 +
53 newDividendsEstimate := &domain.DividendsEstimate{ 105 newDividendsEstimate := &domain.DividendsEstimate{
54 - //CompanyId: createDividendsEstimateCommand.CompanyId,  
55 - //OrgId: createDividendsEstimateCommand.OrgId,  
56 - //UserId: createDividendsEstimateCommand.UserId, 106 + DividendsEstimateId: 0,
  107 + DividendsAccountStatus: 0,
  108 + DividendsAmount: 0,
  109 + DividendsEstimateOrderNumber: "",
  110 + DividendsEstimateTime: time.Time{},
  111 + DividendsParticipateType: 0,
  112 + DividendsType: 0,
  113 + OrderOrReturnedOrderNum: "",
  114 + CooperationProjectNumber: "",
  115 + DividendsUser: nil,
  116 + Org: organization,
  117 + Company: company,
  118 + Operator: operator,
  119 + OperateTime: time.Time{},
  120 + CreatedAt: time.Now(),
  121 + DeletedAt: time.Time{},
  122 + UpdatedAt: time.Time{},
57 } 123 }
  124 +
58 var dividendsEstimateRepository domain.DividendsEstimateRepository 125 var dividendsEstimateRepository domain.DividendsEstimateRepository
59 if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{ 126 if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{
60 "transactionContext": transactionContext, 127 "transactionContext": transactionContext,
@@ -86,7 +153,7 @@ func (dividendsEstimateService *DividendsEstimateService) EstimateDividendsIncen @@ -86,7 +153,7 @@ func (dividendsEstimateService *DividendsEstimateService) EstimateDividendsIncen
86 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 153 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
87 } 154 }
88 defer func() { 155 defer func() {
89 - transactionContext.RollbackTransaction() 156 + _ = transactionContext.RollbackTransaction()
90 }() 157 }()
91 if err := transactionContext.CommitTransaction(); err != nil { 158 if err := transactionContext.CommitTransaction(); err != nil {
92 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 159 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -107,7 +174,7 @@ func (dividendsEstimateService *DividendsEstimateService) EstimateMoneyIncentive @@ -107,7 +174,7 @@ func (dividendsEstimateService *DividendsEstimateService) EstimateMoneyIncentive
107 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 174 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
108 } 175 }
109 defer func() { 176 defer func() {
110 - transactionContext.RollbackTransaction() 177 + _ = transactionContext.RollbackTransaction()
111 }() 178 }()
112 if err := transactionContext.CommitTransaction(); err != nil { 179 if err := transactionContext.CommitTransaction(); err != nil {
113 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 180 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -128,7 +195,7 @@ func (dividendsEstimateService *DividendsEstimateService) GetDividendsEstimate(g @@ -128,7 +195,7 @@ func (dividendsEstimateService *DividendsEstimateService) GetDividendsEstimate(g
128 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 195 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
129 } 196 }
130 defer func() { 197 defer func() {
131 - transactionContext.RollbackTransaction() 198 + _ = transactionContext.RollbackTransaction()
132 }() 199 }()
133 var dividendsEstimateRepository domain.DividendsEstimateRepository 200 var dividendsEstimateRepository domain.DividendsEstimateRepository
134 if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{ 201 if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{
@@ -165,7 +232,7 @@ func (dividendsEstimateService *DividendsEstimateService) ListDividendsEstimate( @@ -165,7 +232,7 @@ func (dividendsEstimateService *DividendsEstimateService) ListDividendsEstimate(
165 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 232 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
166 } 233 }
167 defer func() { 234 defer func() {
168 - transactionContext.RollbackTransaction() 235 + _ = transactionContext.RollbackTransaction()
169 }() 236 }()
170 var dividendsEstimateRepository domain.DividendsEstimateRepository 237 var dividendsEstimateRepository domain.DividendsEstimateRepository
171 if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{ 238 if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{
@@ -201,7 +268,7 @@ func (dividendsEstimateService *DividendsEstimateService) ListDividendsIncentive @@ -201,7 +268,7 @@ func (dividendsEstimateService *DividendsEstimateService) ListDividendsIncentive
201 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 268 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
202 } 269 }
203 defer func() { 270 defer func() {
204 - transactionContext.RollbackTransaction() 271 + _ = transactionContext.RollbackTransaction()
205 }() 272 }()
206 if err := transactionContext.CommitTransaction(); err != nil { 273 if err := transactionContext.CommitTransaction(); err != nil {
207 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 274 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -222,7 +289,7 @@ func (dividendsEstimateService *DividendsEstimateService) ListMoneyIncentives(li @@ -222,7 +289,7 @@ func (dividendsEstimateService *DividendsEstimateService) ListMoneyIncentives(li
222 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 289 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
223 } 290 }
224 defer func() { 291 defer func() {
225 - transactionContext.RollbackTransaction() 292 + _ = transactionContext.RollbackTransaction()
226 }() 293 }()
227 if err := transactionContext.CommitTransaction(); err != nil { 294 if err := transactionContext.CommitTransaction(); err != nil {
228 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 295 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -243,7 +310,7 @@ func (dividendsEstimateService *DividendsEstimateService) RemoveDividendsEstimat @@ -243,7 +310,7 @@ func (dividendsEstimateService *DividendsEstimateService) RemoveDividendsEstimat
243 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 310 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
244 } 311 }
245 defer func() { 312 defer func() {
246 - transactionContext.RollbackTransaction() 313 + _ = transactionContext.RollbackTransaction()
247 }() 314 }()
248 var dividendsEstimateRepository domain.DividendsEstimateRepository 315 var dividendsEstimateRepository domain.DividendsEstimateRepository
249 if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{ 316 if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{
@@ -258,7 +325,7 @@ func (dividendsEstimateService *DividendsEstimateService) RemoveDividendsEstimat @@ -258,7 +325,7 @@ func (dividendsEstimateService *DividendsEstimateService) RemoveDividendsEstimat
258 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 325 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
259 } 326 }
260 if dividendsEstimate == nil { 327 if dividendsEstimate == nil {
261 - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(removeDividendsEstimateCommand.DividendsEstimateId))) 328 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(removeDividendsEstimateCommand.DividendsEstimateId, 10)))
262 } 329 }
263 if dividendsEstimate, err := dividendsEstimateRepository.Remove(dividendsEstimate); err != nil { 330 if dividendsEstimate, err := dividendsEstimateRepository.Remove(dividendsEstimate); err != nil {
264 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 331 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -283,7 +350,7 @@ func (dividendsEstimateService *DividendsEstimateService) SearchDividendsEstimat @@ -283,7 +350,7 @@ func (dividendsEstimateService *DividendsEstimateService) SearchDividendsEstimat
283 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 350 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
284 } 351 }
285 defer func() { 352 defer func() {
286 - transactionContext.RollbackTransaction() 353 + _ = transactionContext.RollbackTransaction()
287 }() 354 }()
288 if err := transactionContext.CommitTransaction(); err != nil { 355 if err := transactionContext.CommitTransaction(); err != nil {
289 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 356 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -304,7 +371,7 @@ func (dividendsEstimateService *DividendsEstimateService) SearchDividendsIncenti @@ -304,7 +371,7 @@ func (dividendsEstimateService *DividendsEstimateService) SearchDividendsIncenti
304 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 371 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
305 } 372 }
306 defer func() { 373 defer func() {
307 - transactionContext.RollbackTransaction() 374 + _ = transactionContext.RollbackTransaction()
308 }() 375 }()
309 if err := transactionContext.CommitTransaction(); err != nil { 376 if err := transactionContext.CommitTransaction(); err != nil {
310 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 377 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -325,7 +392,7 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentives( @@ -325,7 +392,7 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentives(
325 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 392 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
326 } 393 }
327 defer func() { 394 defer func() {
328 - transactionContext.RollbackTransaction() 395 + _ = transactionContext.RollbackTransaction()
329 }() 396 }()
330 if err := transactionContext.CommitTransaction(); err != nil { 397 if err := transactionContext.CommitTransaction(); err != nil {
331 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 398 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -346,7 +413,7 @@ func (dividendsEstimateService *DividendsEstimateService) UpdateDividendsEstimat @@ -346,7 +413,7 @@ func (dividendsEstimateService *DividendsEstimateService) UpdateDividendsEstimat
346 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 413 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
347 } 414 }
348 defer func() { 415 defer func() {
349 - transactionContext.RollbackTransaction() 416 + _ = transactionContext.RollbackTransaction()
350 }() 417 }()
351 var dividendsEstimateRepository domain.DividendsEstimateRepository 418 var dividendsEstimateRepository domain.DividendsEstimateRepository
352 if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{ 419 if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{
@@ -361,7 +428,7 @@ func (dividendsEstimateService *DividendsEstimateService) UpdateDividendsEstimat @@ -361,7 +428,7 @@ func (dividendsEstimateService *DividendsEstimateService) UpdateDividendsEstimat
361 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 428 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
362 } 429 }
363 if dividendsEstimate == nil { 430 if dividendsEstimate == nil {
364 - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateDividendsEstimateCommand.DividendsEstimateId))) 431 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(updateDividendsEstimateCommand.DividendsEstimateId, 10)))
365 } 432 }
366 if err := dividendsEstimate.Update(tool_funs.SimpleStructToMap(updateDividendsEstimateCommand)); err != nil { 433 if err := dividendsEstimate.Update(tool_funs.SimpleStructToMap(updateDividendsEstimateCommand)); err != nil {
367 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 434 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
@@ -8,6 +8,9 @@ import ( @@ -8,6 +8,9 @@ import (
8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsOrder/query" 8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsOrder/query"
9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory" 9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" 10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
  11 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
  12 + "strconv"
  13 + "time"
11 ) 14 )
12 15
13 // DividendsOrderService 分红订单实体对象 16 // DividendsOrderService 分红订单实体对象
@@ -27,22 +30,86 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD @@ -27,22 +30,86 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD
27 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 30 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
28 } 31 }
29 defer func() { 32 defer func() {
30 - transactionContext.RollbackTransaction() 33 + _ = transactionContext.RollbackTransaction()
31 }() 34 }()
  35 +
  36 + // 公司REST服务初始化
  37 + var companyService service.CompanyService
  38 + if value, err := factory.CreateCompanyService(map[string]interface{}{}); err != nil {
  39 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  40 + } else {
  41 + companyService = value
  42 + }
  43 +
  44 + // 获取公司信息
  45 + var company *domain.Company
  46 + if data, err := companyService.CompanyFrom(createDividendsOrderCommand.CompanyId); err != nil {
  47 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  48 + } else {
  49 + company = data
  50 + }
  51 +
  52 + // 组织机构REST服务初始化
  53 + var organizationService service.OrgService
  54 + if value, err := factory.CreateOrganizationService(map[string]interface{}{}); err != nil {
  55 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  56 + } else {
  57 + organizationService = value
  58 + }
  59 +
  60 + // 获取组织机构信息
  61 + var organization *domain.Org
  62 + if data, err := organizationService.OrgFrom(createDividendsOrderCommand.CompanyId, createDividendsOrderCommand.OrgId); err != nil {
  63 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  64 + } else {
  65 + organization = data
  66 + }
  67 +
  68 + // 用户REST服务初始化
  69 + var userService service.UserService
  70 + if value, err := factory.CreateUserService(map[string]interface{}{}); err != nil {
  71 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  72 + } else {
  73 + userService = value
  74 + }
  75 +
  76 + // 获取操作人
  77 + var operator *domain.User
  78 + if data, err := userService.OperatorFrom(createDividendsOrderCommand.CompanyId, createDividendsOrderCommand.OrgId, createDividendsOrderCommand.UserId); err != nil {
  79 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  80 + } else {
  81 + operator = data
  82 + }
  83 +
  84 + // 获取业务员
  85 + commandSalesmanUid, _ := strconv.ParseInt(createDividendsOrderCommand.SalesmanUid, 10, 64)
  86 + var salesman *domain.Salesman
  87 + if data, err := userService.SalesmanFrom(createDividendsOrderCommand.CompanyId, createDividendsOrderCommand.OrgId, commandSalesmanUid); err != nil {
  88 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  89 + } else {
  90 + salesman = data
  91 + }
  92 +
32 newDividendsOrder := &domain.DividendsOrder{ 93 newDividendsOrder := &domain.DividendsOrder{
33 - CustomerName: createDividendsOrderCommand.CustomerName,  
34 - DividendsOrderAmount: createDividendsOrderCommand.DividendsOrderAmount,  
35 - DividendsOrderNumber: createDividendsOrderCommand.DividendsOrderNumber, 94 + DividendsOrderNumber: "",
36 DividendsOriginalOrderNum: createDividendsOrderCommand.DividendsOriginalOrderNum, 95 DividendsOriginalOrderNum: createDividendsOrderCommand.DividendsOriginalOrderNum,
37 - OrderTime: createDividendsOrderCommand.OrderTime,  
38 - //Remarks: createDividendsOrderCommand.Remarks,  
39 - //SalesmanUid: createDividendsOrderCommand.SalesmanUid,  
40 - //OperatorUid: createDividendsOrderCommand.OperatorUid,  
41 - //OrderGoods: createDividendsOrderCommand.OrderGoods,  
42 - //CompanyId: createDividendsOrderCommand.CompanyId,  
43 - //OrgId: createDividendsOrderCommand.OrgId,  
44 - //UserId: createDividendsOrderCommand.UserId, 96 + DividendsOrderAmount: createDividendsOrderCommand.DividendsOrderAmount,
  97 + OrderSalesman: salesman,
  98 + OrderTime: time.Time{},
  99 + DividendTime: time.Time{},
  100 + DividendStatus: 0,
  101 + Region: nil,
  102 + CustomerName: "",
  103 + Goods: nil,
  104 + Org: organization,
  105 + Company: company,
  106 + CreatedAt: time.Now(),
  107 + DeletedAt: time.Time{},
  108 + UpdatedAt: time.Time{},
  109 + OperateTime: time.Time{},
  110 + Operator: operator,
45 } 111 }
  112 +
46 var dividendsOrderRepository domain.DividendsOrderRepository 113 var dividendsOrderRepository domain.DividendsOrderRepository
47 if value, err := factory.CreateDividendsOrderRepository(map[string]interface{}{ 114 if value, err := factory.CreateDividendsOrderRepository(map[string]interface{}{
48 "transactionContext": transactionContext, 115 "transactionContext": transactionContext,
@@ -74,7 +141,7 @@ func (dividendsOrderService *DividendsOrderService) GetDividendsOrder(getDividen @@ -74,7 +141,7 @@ func (dividendsOrderService *DividendsOrderService) GetDividendsOrder(getDividen
74 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 141 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
75 } 142 }
76 defer func() { 143 defer func() {
77 - transactionContext.RollbackTransaction() 144 + _ = transactionContext.RollbackTransaction()
78 }() 145 }()
79 var dividendsOrderRepository domain.DividendsOrderRepository 146 var dividendsOrderRepository domain.DividendsOrderRepository
80 if value, err := factory.CreateDividendsOrderRepository(map[string]interface{}{ 147 if value, err := factory.CreateDividendsOrderRepository(map[string]interface{}{
@@ -89,7 +156,7 @@ func (dividendsOrderService *DividendsOrderService) GetDividendsOrder(getDividen @@ -89,7 +156,7 @@ func (dividendsOrderService *DividendsOrderService) GetDividendsOrder(getDividen
89 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 156 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
90 } 157 }
91 if dividendsOrder == nil { 158 if dividendsOrder == nil {
92 - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getDividendsOrderQuery.DividendsOrderId))) 159 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(getDividendsOrderQuery.DividendsOrderId, 10)))
93 } else { 160 } else {
94 if err := transactionContext.CommitTransaction(); err != nil { 161 if err := transactionContext.CommitTransaction(); err != nil {
95 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 162 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -111,7 +178,7 @@ func (dividendsOrderService *DividendsOrderService) ListDividendsOrders(listDivi @@ -111,7 +178,7 @@ func (dividendsOrderService *DividendsOrderService) ListDividendsOrders(listDivi
111 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 178 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
112 } 179 }
113 defer func() { 180 defer func() {
114 - transactionContext.RollbackTransaction() 181 + _ = transactionContext.RollbackTransaction()
115 }() 182 }()
116 if err := transactionContext.CommitTransaction(); err != nil { 183 if err := transactionContext.CommitTransaction(); err != nil {
117 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 184 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -132,7 +199,7 @@ func (dividendsOrderService *DividendsOrderService) RemoveDividendsOrder(removeD @@ -132,7 +199,7 @@ func (dividendsOrderService *DividendsOrderService) RemoveDividendsOrder(removeD
132 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 199 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
133 } 200 }
134 defer func() { 201 defer func() {
135 - transactionContext.RollbackTransaction() 202 + _ = transactionContext.RollbackTransaction()
136 }() 203 }()
137 var dividendsOrderRepository domain.DividendsOrderRepository 204 var dividendsOrderRepository domain.DividendsOrderRepository
138 if value, err := factory.CreateDividendsOrderRepository(map[string]interface{}{ 205 if value, err := factory.CreateDividendsOrderRepository(map[string]interface{}{
@@ -172,7 +239,7 @@ func (dividendsOrderService *DividendsOrderService) SearchDividendsOrder(searchD @@ -172,7 +239,7 @@ func (dividendsOrderService *DividendsOrderService) SearchDividendsOrder(searchD
172 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 239 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
173 } 240 }
174 defer func() { 241 defer func() {
175 - transactionContext.RollbackTransaction() 242 + _ = transactionContext.RollbackTransaction()
176 }() 243 }()
177 if err := transactionContext.CommitTransaction(); err != nil { 244 if err := transactionContext.CommitTransaction(); err != nil {
178 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 245 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -193,7 +260,7 @@ func (dividendsOrderService *DividendsOrderService) SearchDividendsOrderNumber(s @@ -193,7 +260,7 @@ func (dividendsOrderService *DividendsOrderService) SearchDividendsOrderNumber(s
193 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 260 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
194 } 261 }
195 defer func() { 262 defer func() {
196 - transactionContext.RollbackTransaction() 263 + _ = transactionContext.RollbackTransaction()
197 }() 264 }()
198 if err := transactionContext.CommitTransaction(); err != nil { 265 if err := transactionContext.CommitTransaction(); err != nil {
199 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 266 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -214,7 +281,7 @@ func (dividendsOrderService *DividendsOrderService) UpdateDividendsOrder(updateD @@ -214,7 +281,7 @@ func (dividendsOrderService *DividendsOrderService) UpdateDividendsOrder(updateD
214 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 281 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
215 } 282 }
216 defer func() { 283 defer func() {
217 - transactionContext.RollbackTransaction() 284 + _ = transactionContext.RollbackTransaction()
218 }() 285 }()
219 var dividendsOrderRepository domain.DividendsOrderRepository 286 var dividendsOrderRepository domain.DividendsOrderRepository
220 if value, err := factory.CreateDividendsOrderRepository(map[string]interface{}{ 287 if value, err := factory.CreateDividendsOrderRepository(map[string]interface{}{
@@ -8,6 +8,8 @@ import ( @@ -8,6 +8,8 @@ import (
8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsReturnedOrder/query" 8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsReturnedOrder/query"
9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory" 9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" 10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
  11 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
  12 + "time"
11 ) 13 )
12 14
13 // DividendsReturnedOrderService 分红退货单服务 15 // DividendsReturnedOrderService 分红退货单服务
@@ -27,20 +29,78 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) CreateDivide @@ -27,20 +29,78 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) CreateDivide
27 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 29 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
28 } 30 }
29 defer func() { 31 defer func() {
30 - transactionContext.RollbackTransaction() 32 + _ = transactionContext.RollbackTransaction()
31 }() 33 }()
  34 +
  35 + // 公司REST服务初始化
  36 + var companyService service.CompanyService
  37 + if value, err := factory.CreateCompanyService(map[string]interface{}{}); err != nil {
  38 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  39 + } else {
  40 + companyService = value
  41 + }
  42 +
  43 + // 获取公司信息
  44 + var company *domain.Company
  45 + if data, err := companyService.CompanyFrom(createDividendsReturnedOrderCommand.CompanyId); err != nil {
  46 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  47 + } else {
  48 + company = data
  49 + }
  50 +
  51 + // 组织机构REST服务初始化
  52 + var organizationService service.OrgService
  53 + if value, err := factory.CreateOrganizationService(map[string]interface{}{}); err != nil {
  54 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  55 + } else {
  56 + organizationService = value
  57 + }
  58 +
  59 + // 获取组织机构信息
  60 + var organization *domain.Org
  61 + if data, err := organizationService.OrgFrom(createDividendsReturnedOrderCommand.CompanyId, createDividendsReturnedOrderCommand.OrgId); err != nil {
  62 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  63 + } else {
  64 + organization = data
  65 + }
  66 +
  67 + // 用户REST服务初始化
  68 + var userService service.UserService
  69 + if value, err := factory.CreateUserService(map[string]interface{}{}); err != nil {
  70 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  71 + } else {
  72 + userService = value
  73 + }
  74 +
  75 + // 获取操作人
  76 + var operator *domain.User
  77 + if data, err := userService.OperatorFrom(createDividendsReturnedOrderCommand.CompanyId, createDividendsReturnedOrderCommand.OrgId, createDividendsReturnedOrderCommand.UserId); err != nil {
  78 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  79 + } else {
  80 + operator = data
  81 + }
  82 +
32 newDividendsReturnedOrder := &domain.DividendsReturnedOrder{ 83 newDividendsReturnedOrder := &domain.DividendsReturnedOrder{
33 - DividendsReturnedOrderRefund: createDividendsReturnedOrderCommand.DividendsReturnedOrderRefund,  
34 - DividendsReturnedCustomerName: createDividendsReturnedOrderCommand.DividendsReturnedCustomerName,  
35 - OriginalOrderNum: createDividendsReturnedOrderCommand.OriginalOrderNum,  
36 - Remarks: createDividendsReturnedOrderCommand.Remarks,  
37 - DividendsReturnedDate: createDividendsReturnedOrderCommand.DividendsReturnedDate,  
38 - //RegionName: createDividendsReturnedOrderCommand.RegionName,  
39 - //OrderGoods: createDividendsReturnedOrderCommand.OrderGoods,  
40 - //CompanyId: createDividendsReturnedOrderCommand.CompanyId,  
41 - //OrgId: createDividendsReturnedOrderCommand.OrgId,  
42 - //UserId: createDividendsReturnedOrderCommand.UserId, 84 + DividendsReturnedOrderNumber: "",
  85 + DividendsReturnedOrderRefund: 0,
  86 + OriginalOrderNum: "",
  87 + DividendsOrderNumber: 0,
  88 + DividendsReturnedCustomerName: "",
  89 + DividendsReturnedDate: time.Time{},
  90 + Region: nil,
  91 + Goods: nil,
  92 + Remarks: "",
  93 + DividendStatus: 0,
  94 + DividendTime: time.Time{},
  95 + Org: organization,
  96 + Company: company,
  97 + CreatedAt: time.Now(),
  98 + DeletedAt: time.Time{},
  99 + UpdatedAt: time.Time{},
  100 + Operator: operator,
  101 + OperateTime: time.Time{},
43 } 102 }
  103 +
44 var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository 104 var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository
45 if value, err := factory.CreateDividendsReturnedOrderRepository(map[string]interface{}{ 105 if value, err := factory.CreateDividendsReturnedOrderRepository(map[string]interface{}{
46 "transactionContext": transactionContext, 106 "transactionContext": transactionContext,
@@ -72,7 +132,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) GetDividends @@ -72,7 +132,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) GetDividends
72 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 132 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
73 } 133 }
74 defer func() { 134 defer func() {
75 - transactionContext.RollbackTransaction() 135 + _ = transactionContext.RollbackTransaction()
76 }() 136 }()
77 var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository 137 var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository
78 if value, err := factory.CreateDividendsReturnedOrderRepository(map[string]interface{}{ 138 if value, err := factory.CreateDividendsReturnedOrderRepository(map[string]interface{}{
@@ -109,7 +169,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide @@ -109,7 +169,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
109 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 169 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
110 } 170 }
111 defer func() { 171 defer func() {
112 - transactionContext.RollbackTransaction() 172 + _ = transactionContext.RollbackTransaction()
113 }() 173 }()
114 if err := transactionContext.CommitTransaction(); err != nil { 174 if err := transactionContext.CommitTransaction(); err != nil {
115 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 175 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -130,7 +190,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ListDividend @@ -130,7 +190,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ListDividend
130 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 190 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
131 } 191 }
132 defer func() { 192 defer func() {
133 - transactionContext.RollbackTransaction() 193 + _ = transactionContext.RollbackTransaction()
134 }() 194 }()
135 var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository 195 var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository
136 if value, err := factory.CreateDividendsReturnedOrderRepository(map[string]interface{}{ 196 if value, err := factory.CreateDividendsReturnedOrderRepository(map[string]interface{}{
@@ -166,7 +226,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) RemoveDivide @@ -166,7 +226,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) RemoveDivide
166 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 226 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
167 } 227 }
168 defer func() { 228 defer func() {
169 - transactionContext.RollbackTransaction() 229 + _ = transactionContext.RollbackTransaction()
170 }() 230 }()
171 var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository 231 var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository
172 if value, err := factory.CreateDividendsReturnedOrderRepository(map[string]interface{}{ 232 if value, err := factory.CreateDividendsReturnedOrderRepository(map[string]interface{}{
@@ -206,7 +266,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) SearchDivide @@ -206,7 +266,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) SearchDivide
206 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 266 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
207 } 267 }
208 defer func() { 268 defer func() {
209 - transactionContext.RollbackTransaction() 269 + _ = transactionContext.RollbackTransaction()
210 }() 270 }()
211 if err := transactionContext.CommitTransaction(); err != nil { 271 if err := transactionContext.CommitTransaction(); err != nil {
212 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 272 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -227,7 +287,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) UpdateDivide @@ -227,7 +287,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) UpdateDivide
227 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 287 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
228 } 288 }
229 defer func() { 289 defer func() {
230 - transactionContext.RollbackTransaction() 290 + _ = transactionContext.RollbackTransaction()
231 }() 291 }()
232 var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository 292 var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository
233 if value, err := factory.CreateDividendsReturnedOrderRepository(map[string]interface{}{ 293 if value, err := factory.CreateDividendsReturnedOrderRepository(map[string]interface{}{
@@ -17,6 +17,6 @@ func CreateDepartmentService(options map[string]interface{}) (service.Department @@ -17,6 +17,6 @@ func CreateDepartmentService(options map[string]interface{}) (service.Department
17 return domain_service.NewDepartmentService() 17 return domain_service.NewDepartmentService()
18 } 18 }
19 19
20 -func CreateOrganization(options map[string]interface{}) (service.OrgService, error) { 20 +func CreateOrganizationService(options map[string]interface{}) (service.OrgService, error) {
21 return domain_service.NewOrganizationService() 21 return domain_service.NewOrganizationService()
22 } 22 }
@@ -13,7 +13,7 @@ type ContractUndertakerFeedback struct { @@ -13,7 +13,7 @@ type ContractUndertakerFeedback struct {
13 // 共创合约编号 13 // 共创合约编号
14 CooperationContractNumber string `json:"cooperationContractNumber"` 14 CooperationContractNumber string `json:"cooperationContractNumber"`
15 // 共创合约承接人 15 // 共创合约承接人
16 - ContractUndertaker *User `json:"contractUndertaker"` 16 + ContractUndertaker *Undertaker `json:"contractUndertaker"`
17 // 共创模式 17 // 共创模式
18 CooperationMode *CooperationMode `json:"cooperationMode"` 18 CooperationMode *CooperationMode `json:"cooperationMode"`
19 // 数据所属组织机构 19 // 数据所属组织机构
@@ -13,7 +13,7 @@ type DividendsOrder struct { @@ -13,7 +13,7 @@ type DividendsOrder struct {
13 // 分红订单金额 13 // 分红订单金额
14 DividendsOrderAmount float64 `json:"dividendsOrderAmount"` 14 DividendsOrderAmount float64 `json:"dividendsOrderAmount"`
15 // 订单业务员 15 // 订单业务员
16 - OrderSalesman *User `json:"orderSalesman"` 16 + OrderSalesman *Salesman `json:"orderSalesman"`
17 // 订单产生时间 17 // 订单产生时间
18 OrderTime time.Time `json:"orderTime"` 18 OrderTime time.Time `json:"orderTime"`
19 // 分红订单分红时间 19 // 分红订单分红时间
@@ -3,9 +3,10 @@ package service @@ -3,9 +3,10 @@ package service
3 import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" 3 import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
4 4
5 type UserService interface { 5 type UserService interface {
6 - ReferrerFrom(companyId int64, orgId int64, userId int64) (*domain.Referrer, error)  
7 - UndertakerFrom(companyId int64, orgId int64, userId int64) (*domain.Undertaker, error)  
8 - RelevantFrom(companyId int64, orgId int64, userId int64) (*domain.Relevant, error)  
9 - SalesmanFrom(companyId int64, orgId int64, userId int64) (*domain.Salesman, error)  
10 - OperatorFrom(companyId int64, orgId int64, userId int64) (*domain.User, error) 6 + UserFrom(companyId int64, orgId int64, userId int64) (*domain.User, error) // 获取用户
  7 + ReferrerFrom(companyId int64, orgId int64, userId int64) (*domain.Referrer, error) // 获取推荐人
  8 + UndertakerFrom(companyId int64, orgId int64, userId int64) (*domain.Undertaker, error) // 获取承接人
  9 + RelevantFrom(companyId int64, orgId int64, userId int64) (*domain.Relevant, error) // 获取相关人
  10 + SalesmanFrom(companyId int64, orgId int64, userId int64) (*domain.Salesman, error) // 获取业务员
  11 + OperatorFrom(companyId int64, orgId int64, userId int64) (*domain.User, error) // 获取操作人
11 } 12 }
@@ -9,6 +9,26 @@ import ( @@ -9,6 +9,26 @@ import (
9 type UserService struct { 9 type UserService struct {
10 } 10 }
11 11
  12 +// UserFrom 获取普通用户
  13 +func (service *UserService) UserFrom(companyId int64, orgId int64, userId int64) (*domain.User, error) {
  14 + var returnData *domain.User
  15 + if userAdaptor, err := adaptor.NewUserAdaptor(); err != nil {
  16 + return nil, err
  17 + } else {
  18 + if user, err := userAdaptor.ToParticipator(companyId, orgId, userId, "User"); err != nil {
  19 + return nil, err
  20 + } else {
  21 + if user != nil {
  22 + err := json.Unmarshal(user.([]byte), returnData)
  23 + if err != nil {
  24 + return nil, err
  25 + }
  26 + }
  27 + return returnData, nil
  28 + }
  29 + }
  30 +}
  31 +
12 // ReferrerFrom 获取推荐人 32 // ReferrerFrom 获取推荐人
13 func (service *UserService) ReferrerFrom(companyId int64, orgId int64, userId int64) (*domain.Referrer, error) { 33 func (service *UserService) ReferrerFrom(companyId int64, orgId int64, userId int64) (*domain.Referrer, error) {
14 var returnData *domain.Referrer 34 var returnData *domain.Referrer
@@ -223,15 +223,15 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai @@ -223,15 +223,15 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
223 return nil, err 223 return nil, err
224 } 224 }
225 225
226 - var cooperationContractRelevantModelsUpdate []*models.CooperationContractRelevant // 待更新的相关人  
227 - var cooperationContractRelevantModelsDelete []*models.CooperationContractRelevant // 待删除的相关人  
228 - var cooperationContractRelevantModelsCreate []*models.CooperationContractRelevant // 待增加的相关人  
229 -  
230 - for _, cooperationContractRelevantModels := range cooperationContractRelevantModels {  
231 - for _, cooperationContractRelevantDomain := range cooperationContract.RelevantPeople {  
232 -  
233 - }  
234 - } 226 + //var cooperationContractRelevantModelsUpdate []*models.CooperationContractRelevant // 待更新的相关人
  227 + //var cooperationContractRelevantModelsDelete []*models.CooperationContractRelevant // 待删除的相关人
  228 + //var cooperationContractRelevantModelsCreate []*models.CooperationContractRelevant // 待增加的相关人
  229 + //
  230 + //for _, cooperationContractRelevantModels := range cooperationContractRelevantModels {
  231 + // for _, cooperationContractRelevantDomain := range cooperationContract.RelevantPeople {
  232 + //
  233 + // }
  234 + //}
235 235
236 // 更新的相关人 236 // 更新的相关人
237 237
@@ -49,6 +49,12 @@ func (adaptor *UserAdaptor) ToParticipator(companyId int64, orgId int64, userId @@ -49,6 +49,12 @@ func (adaptor *UserAdaptor) ToParticipator(companyId int64, orgId int64, userId
49 return map[string]interface{}{}, nil 49 return map[string]interface{}{}, nil
50 } 50 }
51 return operator, nil 51 return operator, nil
  52 + case "User":
  53 + user, err := userTranslator.ToUserFromRepresentation(response)
  54 + if err != nil {
  55 + return map[string]interface{}{}, nil
  56 + }
  57 + return user, nil
52 } 58 }
53 } 59 }
54 } 60 }
@@ -79,6 +79,21 @@ func (translator *UserTranslator) ToOperatorFromRepresentation(data map[string]i @@ -79,6 +79,21 @@ func (translator *UserTranslator) ToOperatorFromRepresentation(data map[string]i
79 }, nil 79 }, nil
80 } 80 }
81 81
  82 +func (translator *UserTranslator) ToUserFromRepresentation(data map[string]interface{}) (*domain.User, error) {
  83 + return &domain.User{
  84 + UserId: 0,
  85 + UserBaseId: 0,
  86 + Org: nil,
  87 + Orgs: nil,
  88 + Department: nil,
  89 + Role: nil,
  90 + UserInfo: nil,
  91 + UserType: 0,
  92 + Status: 0,
  93 + Company: nil,
  94 + }, nil
  95 +}
  96 +
82 func NewUserTranslator() (*UserTranslator, error) { 97 func NewUserTranslator() (*UserTranslator, error) {
83 return &UserTranslator{}, nil 98 return &UserTranslator{}, nil
84 } 99 }