...
|
...
|
@@ -102,7 +102,7 @@ func (noticePersonalService *NoticePersonalService) AgreeJoinCreationProject(agr |
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return nil, nil
|
|
|
return noticePersonal, nil
|
|
|
}
|
|
|
|
|
|
// 获取消息列表
|
...
|
...
|
@@ -160,12 +160,10 @@ func (noticePersonalService *NoticePersonalService) InformExpectedDividends(info |
|
|
}
|
|
|
if len(settings) == 0 {
|
|
|
//未设置消息模板
|
|
|
return nil, nil
|
|
|
return "未设置对应的消息模板", nil
|
|
|
}
|
|
|
noticeContent := settings[0].Content
|
|
|
tpl, err := template.New("AgreeJoinCreationProject").Parse(noticeContent)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "消息模板解析失败"+err.Error())
|
|
|
if settings[0].IsPush == domain.NoticeSettingIsNotPush {
|
|
|
return "消息是否推送已设为否", nil
|
|
|
}
|
|
|
// Param01_04_01 = "param01_04_01" //分红预算消息-共创项目编号
|
|
|
// Param01_04_02 = "param01_04_02" //分红预算消息-共创项目名称
|
...
|
...
|
@@ -182,6 +180,11 @@ func (noticePersonalService *NoticePersonalService) InformExpectedDividends(info |
|
|
domain.Param01_04_05: strings.Join(informExpectedDividendsCommand.ProductName, ","),
|
|
|
domain.Param01_04_06: informExpectedDividendsCommand.DividendsAmount,
|
|
|
}
|
|
|
noticeContent := settings[0].Content
|
|
|
tpl, err := template.New("InformExpectedDividends").Parse(noticeContent)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "消息模板解析失败"+err.Error())
|
|
|
}
|
|
|
tplResult := bytes.Buffer{}
|
|
|
err = tpl.Execute(&tplResult, data)
|
|
|
if err != nil {
|
...
|
...
|
@@ -221,7 +224,7 @@ func (noticePersonalService *NoticePersonalService) InformExpectedDividends(info |
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return nil, nil
|
|
|
return noticePersonal, nil
|
|
|
}
|
|
|
|
|
|
// 设置消息:共创确认
|
...
|
...
|
@@ -240,7 +243,6 @@ func (noticePersonalService *NoticePersonalService) InformJoinCreationContract(i |
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
//TODO
|
|
|
var noticeSettingRepository domain.NoticeSettingRepository
|
|
|
if value, err := factory.CreateNoticeSettingRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
...
|
...
|
@@ -258,10 +260,13 @@ func (noticePersonalService *NoticePersonalService) InformJoinCreationContract(i |
|
|
}
|
|
|
if len(settings) == 0 {
|
|
|
//未设置消息模板
|
|
|
return nil, nil
|
|
|
return "未设置对应的消息模板", nil
|
|
|
}
|
|
|
if settings[0].IsPush == domain.NoticeSettingIsNotPush {
|
|
|
return "消息是否推送已设为否", nil
|
|
|
}
|
|
|
noticeContent := settings[0].Content
|
|
|
tpl, err := template.New("AgreeJoinCreationProject").Parse(noticeContent)
|
|
|
tpl, err := template.New("InformJoinCreationContract").Parse(noticeContent)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "消息模板解析失败"+err.Error())
|
|
|
}
|
...
|
...
|
@@ -312,7 +317,7 @@ func (noticePersonalService *NoticePersonalService) InformJoinCreationContract(i |
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return nil, nil
|
|
|
return noticePersonal, nil
|
|
|
}
|
|
|
|
|
|
// 设置消息:共创申请审核拒绝
|
...
|
...
|
@@ -331,12 +336,266 @@ func (noticePersonalService *NoticePersonalService) RefuseJoinCreationProject(re |
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
//TODO
|
|
|
var noticeSettingRepository domain.NoticeSettingRepository
|
|
|
if value, err := factory.CreateNoticeSettingRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
noticeSettingRepository = value
|
|
|
}
|
|
|
_, settings, err := noticeSettingRepository.Find(map[string]interface{}{
|
|
|
"orgId": refuseJoinCreationProjectCommand.OrgId,
|
|
|
"moduleAction": domain.Action01_02,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if len(settings) == 0 {
|
|
|
//未设置消息模板
|
|
|
return "未设置对应的消息模板", nil
|
|
|
}
|
|
|
if settings[0].IsPush == domain.NoticeSettingIsNotPush {
|
|
|
return "消息是否推送已设为否", nil
|
|
|
}
|
|
|
// Param01_02_01 = "param01_02_01" //共创申请拒绝-共创项目编号
|
|
|
// Param01_02_02 = "param01_02_02" //共创申请拒绝-共创项目名称
|
|
|
//数据字段映射
|
|
|
data := map[string]string{
|
|
|
domain.Param01_02_01: refuseJoinCreationProjectCommand.CreationProjectNumber,
|
|
|
domain.Param01_02_02: refuseJoinCreationProjectCommand.CreationProjectName,
|
|
|
}
|
|
|
noticeContent := settings[0].Content
|
|
|
tpl, err := template.New("RefuseJoinCreationProject").Parse(noticeContent)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "消息模板解析失败"+err.Error())
|
|
|
}
|
|
|
tplResult := bytes.Buffer{}
|
|
|
err = tpl.Execute(&tplResult, data)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "消息体生成失败"+err.Error())
|
|
|
}
|
|
|
extendData := map[string]interface{}{
|
|
|
"creationProjectId": refuseJoinCreationProjectCommand.CreationProjectId,
|
|
|
}
|
|
|
extendStr, _ := json.Marshal(extendData)
|
|
|
noticePersonal := domain.NoticePersonal{
|
|
|
CreatedAt: time.Now(),
|
|
|
UpdatedAt: time.Now(),
|
|
|
Extend: string(extendStr),
|
|
|
CompanyId: refuseJoinCreationProjectCommand.CompanyId,
|
|
|
Content: tplResult.String(),
|
|
|
IsRead: domain.NoticePersonalIsNotRead,
|
|
|
Module: domain.Action01_01,
|
|
|
ModuleAction: domain.Action01_01,
|
|
|
UserBaseId: refuseJoinCreationProjectCommand.UserBaseId,
|
|
|
OrgId: refuseJoinCreationProjectCommand.OrgId,
|
|
|
UserId: refuseJoinCreationProjectCommand.UserId,
|
|
|
}
|
|
|
var noticePersonalRepository domain.NoticePersonalRepository
|
|
|
if value, err := factory.CreateNoticePersonalRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
noticePersonalRepository = value
|
|
|
}
|
|
|
_, err = noticePersonalRepository.Save(¬icePersonal)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return nil, nil
|
|
|
return noticePersonal, nil
|
|
|
}
|
|
|
|
|
|
// 设置消息:账期结算消息-分红预算
|
|
|
func (noticePersonalService *NoticePersonalService) CreditAccountEstimate(creditAccountEstimateCommand *command.CreditAccountEstimateCommand) (interface{}, error) {
|
|
|
if err := creditAccountEstimateCommand.ValidateCommand(); err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
|
|
}
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
if err := transactionContext.StartTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
var noticeSettingRepository domain.NoticeSettingRepository
|
|
|
if value, err := factory.CreateNoticeSettingRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
noticeSettingRepository = value
|
|
|
}
|
|
|
_, settings, err := noticeSettingRepository.Find(map[string]interface{}{
|
|
|
"orgId": creditAccountEstimateCommand.OrgId,
|
|
|
"moduleAction": domain.Action01_05,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if len(settings) == 0 {
|
|
|
//未设置消息模板
|
|
|
return "未找到对应的消息模板", nil
|
|
|
}
|
|
|
if settings[0].IsPush == domain.NoticeSettingIsNotPush {
|
|
|
return "消息是否推送已设为否", nil
|
|
|
}
|
|
|
// Param01_05_01 = "param01_05_01" //账期结算消息-账期结算单号
|
|
|
// Param01_05_02 = "param01_05_02" //账期结算消息-结算金额
|
|
|
// Param01_05_03 = "param01_05_03" //账期结算消息-分红预算单号
|
|
|
//数据字段映射
|
|
|
data := map[string]string{
|
|
|
domain.Param01_05_01: creditAccountEstimateCommand.CreditAccountOrderNum,
|
|
|
domain.Param01_05_02: creditAccountEstimateCommand.SettlementAmount,
|
|
|
domain.Param01_05_03: creditAccountEstimateCommand.DividendsEstimateOrderNumber,
|
|
|
}
|
|
|
noticeContent := settings[0].Content
|
|
|
tpl, err := template.New("CreditAccountEstimate").Parse(noticeContent)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "消息模板解析失败"+err.Error())
|
|
|
}
|
|
|
tplResult := bytes.Buffer{}
|
|
|
err = tpl.Execute(&tplResult, data)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "消息体生成失败"+err.Error())
|
|
|
}
|
|
|
extendData := map[string]interface{}{
|
|
|
"creditAccountId": creditAccountEstimateCommand.CreditAccountId,
|
|
|
"dividendsEstimateId": creditAccountEstimateCommand.DividendsEstimateId,
|
|
|
}
|
|
|
extendStr, _ := json.Marshal(extendData)
|
|
|
noticePersonal := domain.NoticePersonal{
|
|
|
CreatedAt: time.Now(),
|
|
|
UpdatedAt: time.Now(),
|
|
|
Extend: string(extendStr),
|
|
|
CompanyId: creditAccountEstimateCommand.CompanyId,
|
|
|
Content: tplResult.String(),
|
|
|
IsRead: domain.NoticePersonalIsNotRead,
|
|
|
Module: domain.Action01_01,
|
|
|
ModuleAction: domain.Action01_01,
|
|
|
UserBaseId: creditAccountEstimateCommand.UserBaseId,
|
|
|
OrgId: creditAccountEstimateCommand.OrgId,
|
|
|
UserId: creditAccountEstimateCommand.UserId,
|
|
|
}
|
|
|
var noticePersonalRepository domain.NoticePersonalRepository
|
|
|
if value, err := factory.CreateNoticePersonalRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
noticePersonalRepository = value
|
|
|
}
|
|
|
_, err = noticePersonalRepository.Save(¬icePersonal)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return noticePersonal, nil
|
|
|
}
|
|
|
|
|
|
// 设置消息:账期结算消息-分红预算
|
|
|
func (noticePersonalService *NoticePersonalService) CreditAccountPayment(creditAccountPaymentCommand *command.CreditAccountPaymentCommand) (interface{}, error) {
|
|
|
if err := creditAccountPaymentCommand.ValidateCommand(); err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
|
|
}
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
if err := transactionContext.StartTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
var noticeSettingRepository domain.NoticeSettingRepository
|
|
|
if value, err := factory.CreateNoticeSettingRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
noticeSettingRepository = value
|
|
|
}
|
|
|
_, settings, err := noticeSettingRepository.Find(map[string]interface{}{
|
|
|
"orgId": creditAccountPaymentCommand.OrgId,
|
|
|
"moduleAction": domain.Action01_05,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if len(settings) == 0 {
|
|
|
//未设置消息模板
|
|
|
return "未找到对应的消息模板", nil
|
|
|
}
|
|
|
if settings[0].IsPush == domain.NoticeSettingIsNotPush {
|
|
|
return "消息是否推送已设为否", nil
|
|
|
}
|
|
|
// Param01_06_01 = "param01_06_01" //支付消息-账期结算单号
|
|
|
// Param01_06_02 = "param01_06_02" //支付消息-结算金额
|
|
|
// Param01_06_03 = "param01_06_03" //支付消息-实付金额
|
|
|
//数据字段映射
|
|
|
data := map[string]string{
|
|
|
domain.Param01_06_01: creditAccountPaymentCommand.CreditAccountOrderNum,
|
|
|
domain.Param01_06_02: creditAccountPaymentCommand.SettlementAmount,
|
|
|
domain.Param01_06_03: creditAccountPaymentCommand.ActuallyPaidAmount,
|
|
|
}
|
|
|
noticeContent := settings[0].Content
|
|
|
tpl, err := template.New("CreditAccountPayment").Parse(noticeContent)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "消息模板解析失败"+err.Error())
|
|
|
}
|
|
|
tplResult := bytes.Buffer{}
|
|
|
err = tpl.Execute(&tplResult, data)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "消息体生成失败"+err.Error())
|
|
|
}
|
|
|
extendData := map[string]interface{}{
|
|
|
"creditAccountId": creditAccountPaymentCommand.CreditAccountId,
|
|
|
}
|
|
|
extendStr, _ := json.Marshal(extendData)
|
|
|
noticePersonal := domain.NoticePersonal{
|
|
|
CreatedAt: time.Now(),
|
|
|
UpdatedAt: time.Now(),
|
|
|
Extend: string(extendStr),
|
|
|
CompanyId: creditAccountPaymentCommand.CompanyId,
|
|
|
Content: tplResult.String(),
|
|
|
IsRead: domain.NoticePersonalIsNotRead,
|
|
|
Module: domain.Action01_01,
|
|
|
ModuleAction: domain.Action01_01,
|
|
|
UserBaseId: creditAccountPaymentCommand.UserBaseId,
|
|
|
OrgId: creditAccountPaymentCommand.OrgId,
|
|
|
UserId: creditAccountPaymentCommand.UserId,
|
|
|
}
|
|
|
var noticePersonalRepository domain.NoticePersonalRepository
|
|
|
if value, err := factory.CreateNoticePersonalRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
noticePersonalRepository = value
|
|
|
}
|
|
|
_, err = noticePersonalRepository.Save(¬icePersonal)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return noticePersonal, nil
|
|
|
}
|
|
|
|
|
|
func NewNoticePersonalService(options map[string]interface{}) *NoticePersonalService {
|
...
|
...
|
|