1
|
package service
|
1
|
package service
|
2
|
|
2
|
|
3
|
import (
|
3
|
import (
|
|
|
4
|
+ "bytes"
|
|
|
5
|
+ "encoding/json"
|
|
|
6
|
+ "html/template"
|
|
|
7
|
+ "strings"
|
|
|
8
|
+ "time"
|
|
|
9
|
+
|
4
|
"github.com/linmadan/egglib-go/core/application"
|
10
|
"github.com/linmadan/egglib-go/core/application"
|
5
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/application/factory"
|
11
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/application/factory"
|
6
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/application/noticePersonal/command"
|
12
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/application/noticePersonal/command"
|
7
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/application/noticePersonal/query"
|
13
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/application/noticePersonal/query"
|
|
|
14
|
+ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/domain"
|
8
|
)
|
15
|
)
|
9
|
|
16
|
|
10
|
// 个人消息通知
|
17
|
// 个人消息通知
|
|
@@ -26,6 +33,72 @@ func (noticePersonalService *NoticePersonalService) AgreeJoinCreationProject(agr |
|
@@ -26,6 +33,72 @@ func (noticePersonalService *NoticePersonalService) AgreeJoinCreationProject(agr |
26
|
defer func() {
|
33
|
defer func() {
|
27
|
transactionContext.RollbackTransaction()
|
34
|
transactionContext.RollbackTransaction()
|
28
|
}()
|
35
|
}()
|
|
|
36
|
+ var noticeSettingRepository domain.NoticeSettingRepository
|
|
|
37
|
+ if value, err := factory.CreateNoticeSettingRepository(map[string]interface{}{
|
|
|
38
|
+ "transactionContext": transactionContext,
|
|
|
39
|
+ }); err != nil {
|
|
|
40
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
41
|
+ } else {
|
|
|
42
|
+ noticeSettingRepository = value
|
|
|
43
|
+ }
|
|
|
44
|
+ _, settings, err := noticeSettingRepository.Find(map[string]interface{}{
|
|
|
45
|
+ "orgId": agreeJoinCreationProjectCommand.OrgId,
|
|
|
46
|
+ "moduleAction": domain.Action01_01,
|
|
|
47
|
+ })
|
|
|
48
|
+ if err != nil {
|
|
|
49
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
50
|
+ }
|
|
|
51
|
+ if len(settings) == 0 {
|
|
|
52
|
+ //未设置消息模板
|
|
|
53
|
+ return "未设置对应的消息模板", nil
|
|
|
54
|
+ }
|
|
|
55
|
+ if settings[0].IsPush == domain.NoticeSettingIsNotPush {
|
|
|
56
|
+ return "消息是否推送已设为否", nil
|
|
|
57
|
+ }
|
|
|
58
|
+ noticeContent := settings[0].Content
|
|
|
59
|
+ tpl, err := template.New("AgreeJoinCreationProject").Parse(noticeContent)
|
|
|
60
|
+ if err != nil {
|
|
|
61
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "消息模板解析失败"+err.Error())
|
|
|
62
|
+ }
|
|
|
63
|
+ //数据字段映射
|
|
|
64
|
+ data := map[string]string{
|
|
|
65
|
+ domain.Param01_01_01: agreeJoinCreationProjectCommand.CreationProjectNumber,
|
|
|
66
|
+ domain.Param01_01_02: agreeJoinCreationProjectCommand.CreationProjectName,
|
|
|
67
|
+ }
|
|
|
68
|
+ tplResult := bytes.Buffer{}
|
|
|
69
|
+ err = tpl.Execute(&tplResult, data)
|
|
|
70
|
+ if err != nil {
|
|
|
71
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "消息体生成失败"+err.Error())
|
|
|
72
|
+ }
|
|
|
73
|
+ extendData := map[string]interface{}{
|
|
|
74
|
+ "creationProjectId": agreeJoinCreationProjectCommand.CreationProjectId,
|
|
|
75
|
+ }
|
|
|
76
|
+ extendStr, _ := json.Marshal(extendData)
|
|
|
77
|
+ noticePersonal := domain.NoticePersonal{
|
|
|
78
|
+ CreatedAt: time.Now(),
|
|
|
79
|
+ UpdatedAt: time.Now(),
|
|
|
80
|
+ Extend: string(extendStr),
|
|
|
81
|
+ CompanyId: agreeJoinCreationProjectCommand.CompanyId,
|
|
|
82
|
+ Content: tplResult.String(),
|
|
|
83
|
+ IsRead: domain.NoticePersonalIsNotRead,
|
|
|
84
|
+ Module: domain.Action01_01,
|
|
|
85
|
+ ModuleAction: domain.Action01_01,
|
|
|
86
|
+ UserBaseId: agreeJoinCreationProjectCommand.UserBaseId,
|
|
|
87
|
+ OrgId: agreeJoinCreationProjectCommand.OrgId,
|
|
|
88
|
+ UserId: agreeJoinCreationProjectCommand.UserId,
|
|
|
89
|
+ }
|
|
|
90
|
+ var noticePersonalRepository domain.NoticePersonalRepository
|
|
|
91
|
+ if value, err := factory.CreateNoticePersonalRepository(map[string]interface{}{
|
|
|
92
|
+ "transactionContext": transactionContext,
|
|
|
93
|
+ }); err != nil {
|
|
|
94
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
95
|
+ } else {
|
|
|
96
|
+ noticePersonalRepository = value
|
|
|
97
|
+ }
|
|
|
98
|
+ _, err = noticePersonalRepository.Save(¬icePersonal)
|
|
|
99
|
+ if err != nil {
|
|
|
100
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
101
|
+ }
|
29
|
if err := transactionContext.CommitTransaction(); err != nil {
|
102
|
if err := transactionContext.CommitTransaction(); err != nil {
|
30
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
103
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
31
|
}
|
104
|
}
|
|
@@ -47,6 +120,8 @@ func (noticePersonalService *NoticePersonalService) GetNoticePersonalList(getNot |
|
@@ -47,6 +120,8 @@ func (noticePersonalService *NoticePersonalService) GetNoticePersonalList(getNot |
47
|
defer func() {
|
120
|
defer func() {
|
48
|
transactionContext.RollbackTransaction()
|
121
|
transactionContext.RollbackTransaction()
|
49
|
}()
|
122
|
}()
|
|
|
123
|
+
|
|
|
124
|
+ //TODO
|
50
|
if err := transactionContext.CommitTransaction(); err != nil {
|
125
|
if err := transactionContext.CommitTransaction(); err != nil {
|
51
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
126
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
52
|
}
|
127
|
}
|
|
@@ -68,6 +143,81 @@ func (noticePersonalService *NoticePersonalService) InformExpectedDividends(info |
|
@@ -68,6 +143,81 @@ func (noticePersonalService *NoticePersonalService) InformExpectedDividends(info |
68
|
defer func() {
|
143
|
defer func() {
|
69
|
transactionContext.RollbackTransaction()
|
144
|
transactionContext.RollbackTransaction()
|
70
|
}()
|
145
|
}()
|
|
|
146
|
+ var noticeSettingRepository domain.NoticeSettingRepository
|
|
|
147
|
+ if value, err := factory.CreateNoticeSettingRepository(map[string]interface{}{
|
|
|
148
|
+ "transactionContext": transactionContext,
|
|
|
149
|
+ }); err != nil {
|
|
|
150
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
151
|
+ } else {
|
|
|
152
|
+ noticeSettingRepository = value
|
|
|
153
|
+ }
|
|
|
154
|
+ _, settings, err := noticeSettingRepository.Find(map[string]interface{}{
|
|
|
155
|
+ "orgId": informExpectedDividendsCommand.OrgId,
|
|
|
156
|
+ "moduleAction": domain.Action01_04,
|
|
|
157
|
+ })
|
|
|
158
|
+ if err != nil {
|
|
|
159
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
160
|
+ }
|
|
|
161
|
+ if len(settings) == 0 {
|
|
|
162
|
+ //未设置消息模板
|
|
|
163
|
+ return nil, nil
|
|
|
164
|
+ }
|
|
|
165
|
+ noticeContent := settings[0].Content
|
|
|
166
|
+ tpl, err := template.New("AgreeJoinCreationProject").Parse(noticeContent)
|
|
|
167
|
+ if err != nil {
|
|
|
168
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "消息模板解析失败"+err.Error())
|
|
|
169
|
+ }
|
|
|
170
|
+ // Param01_04_01 = "param01_04_01" //分红预算消息-共创项目编号
|
|
|
171
|
+ // Param01_04_02 = "param01_04_02" //分红预算消息-共创项目名称
|
|
|
172
|
+ // Param01_04_03 = "param01_04_03" //分红预算消息-项目合约编号
|
|
|
173
|
+ // Param01_04_04 = "param01_04_04" //分红预算消息-项目合约名称
|
|
|
174
|
+ // Param01_04_05 = "param01_04_05" //分红预算消息-订单产品信息
|
|
|
175
|
+ // Param01_04_06 = "param01_04_06" //分红预算消息-分红金额
|
|
|
176
|
+ //数据字段映射
|
|
|
177
|
+ data := map[string]string{
|
|
|
178
|
+ domain.Param01_04_01: informExpectedDividendsCommand.CreationProjectNumber,
|
|
|
179
|
+ domain.Param01_04_02: informExpectedDividendsCommand.CreationProjectName,
|
|
|
180
|
+ domain.Param01_04_03: informExpectedDividendsCommand.CreationContractNumber,
|
|
|
181
|
+ domain.Param01_04_04: informExpectedDividendsCommand.CreationContractName,
|
|
|
182
|
+ domain.Param01_04_05: strings.Join(informExpectedDividendsCommand.ProductName, ","),
|
|
|
183
|
+ domain.Param01_04_06: informExpectedDividendsCommand.DividendsAmount,
|
|
|
184
|
+ }
|
|
|
185
|
+ tplResult := bytes.Buffer{}
|
|
|
186
|
+ err = tpl.Execute(&tplResult, data)
|
|
|
187
|
+ if err != nil {
|
|
|
188
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "消息体生成失败"+err.Error())
|
|
|
189
|
+ }
|
|
|
190
|
+ extendData := map[string]interface{}{
|
|
|
191
|
+ "creationProjectId": informExpectedDividendsCommand.CreationProjectId,
|
|
|
192
|
+ "creationContractId": informExpectedDividendsCommand.CreationContractId,
|
|
|
193
|
+ "dividendsEstimateId": informExpectedDividendsCommand.DividendsEstimateId,
|
|
|
194
|
+ }
|
|
|
195
|
+ extendStr, _ := json.Marshal(extendData)
|
|
|
196
|
+ noticePersonal := domain.NoticePersonal{
|
|
|
197
|
+ CreatedAt: time.Now(),
|
|
|
198
|
+ UpdatedAt: time.Now(),
|
|
|
199
|
+ Extend: string(extendStr),
|
|
|
200
|
+ CompanyId: informExpectedDividendsCommand.CompanyId,
|
|
|
201
|
+ Content: tplResult.String(),
|
|
|
202
|
+ IsRead: domain.NoticePersonalIsNotRead,
|
|
|
203
|
+ Module: domain.Action01_01,
|
|
|
204
|
+ ModuleAction: domain.Action01_01,
|
|
|
205
|
+ UserBaseId: informExpectedDividendsCommand.UserBaseId,
|
|
|
206
|
+ OrgId: informExpectedDividendsCommand.OrgId,
|
|
|
207
|
+ UserId: informExpectedDividendsCommand.UserId,
|
|
|
208
|
+ }
|
|
|
209
|
+ var noticePersonalRepository domain.NoticePersonalRepository
|
|
|
210
|
+ if value, err := factory.CreateNoticePersonalRepository(map[string]interface{}{
|
|
|
211
|
+ "transactionContext": transactionContext,
|
|
|
212
|
+ }); err != nil {
|
|
|
213
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
214
|
+ } else {
|
|
|
215
|
+ noticePersonalRepository = value
|
|
|
216
|
+ }
|
|
|
217
|
+ _, err = noticePersonalRepository.Save(¬icePersonal)
|
|
|
218
|
+ if err != nil {
|
|
|
219
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
220
|
+ }
|
71
|
if err := transactionContext.CommitTransaction(); err != nil {
|
221
|
if err := transactionContext.CommitTransaction(); err != nil {
|
72
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
222
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
73
|
}
|
223
|
}
|
|
@@ -89,6 +239,76 @@ func (noticePersonalService *NoticePersonalService) InformJoinCreationContract(i |
|
@@ -89,6 +239,76 @@ func (noticePersonalService *NoticePersonalService) InformJoinCreationContract(i |
89
|
defer func() {
|
239
|
defer func() {
|
90
|
transactionContext.RollbackTransaction()
|
240
|
transactionContext.RollbackTransaction()
|
91
|
}()
|
241
|
}()
|
|
|
242
|
+
|
|
|
243
|
+ //TODO
|
|
|
244
|
+ var noticeSettingRepository domain.NoticeSettingRepository
|
|
|
245
|
+ if value, err := factory.CreateNoticeSettingRepository(map[string]interface{}{
|
|
|
246
|
+ "transactionContext": transactionContext,
|
|
|
247
|
+ }); err != nil {
|
|
|
248
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
249
|
+ } else {
|
|
|
250
|
+ noticeSettingRepository = value
|
|
|
251
|
+ }
|
|
|
252
|
+ _, settings, err := noticeSettingRepository.Find(map[string]interface{}{
|
|
|
253
|
+ "orgId": informJoinCreationContractCommand.OrgId,
|
|
|
254
|
+ "moduleAction": domain.Action01_03,
|
|
|
255
|
+ })
|
|
|
256
|
+ if err != nil {
|
|
|
257
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
258
|
+ }
|
|
|
259
|
+ if len(settings) == 0 {
|
|
|
260
|
+ //未设置消息模板
|
|
|
261
|
+ return nil, nil
|
|
|
262
|
+ }
|
|
|
263
|
+ noticeContent := settings[0].Content
|
|
|
264
|
+ tpl, err := template.New("AgreeJoinCreationProject").Parse(noticeContent)
|
|
|
265
|
+ if err != nil {
|
|
|
266
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "消息模板解析失败"+err.Error())
|
|
|
267
|
+ }
|
|
|
268
|
+ // Param01_03_01 = "param01_03_01" //共创确认-共创项目编号
|
|
|
269
|
+ // Param01_03_02 = "param01_03_02" //共创确认-共创项目名称
|
|
|
270
|
+ // Param01_03_03 = "param01_03_03" //共创确认-项目合约编号
|
|
|
271
|
+ // Param01_03_04 = "param01_03_04" //共创确认-项目合约名称
|
|
|
272
|
+ //数据字段映射
|
|
|
273
|
+ data := map[string]string{
|
|
|
274
|
+ domain.Param01_03_01: informJoinCreationContractCommand.CreationProjectNumber,
|
|
|
275
|
+ domain.Param01_03_02: informJoinCreationContractCommand.CreationProjectName,
|
|
|
276
|
+ domain.Param01_03_03: informJoinCreationContractCommand.CreationContractNumber,
|
|
|
277
|
+ domain.Param01_03_04: informJoinCreationContractCommand.CreationContractName,
|
|
|
278
|
+ }
|
|
|
279
|
+ tplResult := bytes.Buffer{}
|
|
|
280
|
+ err = tpl.Execute(&tplResult, data)
|
|
|
281
|
+ if err != nil {
|
|
|
282
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "消息体生成失败"+err.Error())
|
|
|
283
|
+ }
|
|
|
284
|
+ extendData := map[string]interface{}{}
|
|
|
285
|
+ extendStr, _ := json.Marshal(extendData)
|
|
|
286
|
+ noticePersonal := domain.NoticePersonal{
|
|
|
287
|
+ CreatedAt: time.Now(),
|
|
|
288
|
+ UpdatedAt: time.Now(),
|
|
|
289
|
+ Extend: string(extendStr),
|
|
|
290
|
+ CompanyId: informJoinCreationContractCommand.CompanyId,
|
|
|
291
|
+ Content: tplResult.String(),
|
|
|
292
|
+ IsRead: domain.NoticePersonalIsNotRead,
|
|
|
293
|
+ Module: domain.Action01_01,
|
|
|
294
|
+ ModuleAction: domain.Action01_01,
|
|
|
295
|
+ UserBaseId: informJoinCreationContractCommand.UserBaseId,
|
|
|
296
|
+ OrgId: informJoinCreationContractCommand.OrgId,
|
|
|
297
|
+ UserId: informJoinCreationContractCommand.UserId,
|
|
|
298
|
+ }
|
|
|
299
|
+ var noticePersonalRepository domain.NoticePersonalRepository
|
|
|
300
|
+ if value, err := factory.CreateNoticePersonalRepository(map[string]interface{}{
|
|
|
301
|
+ "transactionContext": transactionContext,
|
|
|
302
|
+ }); err != nil {
|
|
|
303
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
304
|
+ } else {
|
|
|
305
|
+ noticePersonalRepository = value
|
|
|
306
|
+ }
|
|
|
307
|
+ _, err = noticePersonalRepository.Save(¬icePersonal)
|
|
|
308
|
+ if err != nil {
|
|
|
309
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
310
|
+ }
|
|
|
311
|
+
|
92
|
if err := transactionContext.CommitTransaction(); err != nil {
|
312
|
if err := transactionContext.CommitTransaction(); err != nil {
|
93
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
313
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
94
|
}
|
314
|
}
|
|
@@ -110,6 +330,9 @@ func (noticePersonalService *NoticePersonalService) RefuseJoinCreationProject(re |
|
@@ -110,6 +330,9 @@ func (noticePersonalService *NoticePersonalService) RefuseJoinCreationProject(re |
110
|
defer func() {
|
330
|
defer func() {
|
111
|
transactionContext.RollbackTransaction()
|
331
|
transactionContext.RollbackTransaction()
|
112
|
}()
|
332
|
}()
|
|
|
333
|
+
|
|
|
334
|
+ //TODO
|
|
|
335
|
+
|
113
|
if err := transactionContext.CommitTransaction(); err != nil {
|
336
|
if err := transactionContext.CommitTransaction(); err != nil {
|
114
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
337
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
115
|
}
|
338
|
}
|