作者 tangxvhui

更新 短信提醒

@@ -4,7 +4,6 @@ import ( @@ -4,7 +4,6 @@ import (
4 "time" 4 "time"
5 5
6 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" 6 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
7 - "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/constant"  
8 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" 7 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
9 ) 8 )
10 9
@@ -23,9 +22,9 @@ func (notices notifyStaffAssess) makeNotify(param *domain.StaffAssess) *domain.L @@ -23,9 +22,9 @@ func (notices notifyStaffAssess) makeNotify(param *domain.StaffAssess) *domain.L
23 year, month, dayNumber := param.BeginTime.Local().Date() 22 year, month, dayNumber := param.BeginTime.Local().Date()
24 23
25 // 限制只有 在每月的15号进行每日评估填报时,才进行短信消息提醒 24 // 限制只有 在每月的15号进行每日评估填报时,才进行短信消息提醒
26 - if dayNumber != 15 {  
27 - return nil  
28 - } 25 + // if dayNumber != 15 {
  26 + // return nil
  27 + // }
29 // 每月15日的每日评估必做,未填写的在晚上10点下发短信提醒 28 // 每月15日的每日评估必做,未填写的在晚上10点下发短信提醒
30 dayTime := time.Date(year, month, dayNumber, 22, 0, 0, 0, time.Local) 29 dayTime := time.Date(year, month, dayNumber, 22, 0, 0, 0, time.Local)
31 newSms := domain.LogSms{ 30 newSms := domain.LogSms{
@@ -49,9 +48,9 @@ func (notices notifyStaffAssess) makeNotify(param *domain.StaffAssess) *domain.L @@ -49,9 +48,9 @@ func (notices notifyStaffAssess) makeNotify(param *domain.StaffAssess) *domain.L
49 48
50 // ifSend 确认是否发送通知 49 // ifSend 确认是否发送通知
51 func (notices notifyStaffAssess) ifSend(index int) (bool, error) { 50 func (notices notifyStaffAssess) ifSend(index int) (bool, error) {
52 - if constant.Env != "prd" {  
53 - return false, nil  
54 - } 51 + // if constant.Env != "prd" {
  52 + // return false, nil
  53 + // }
55 54
56 transactionContext, err := factory.CreateTransactionContext(nil) 55 transactionContext, err := factory.CreateTransactionContext(nil)
57 if err != nil { 56 if err != nil {
@@ -98,9 +97,9 @@ func (notices notifyStaffAssess2) makeNotify(param *domain.StaffAssess) *domain. @@ -98,9 +97,9 @@ func (notices notifyStaffAssess2) makeNotify(param *domain.StaffAssess) *domain.
98 year, month, dayNumber := param.BeginTime.Local().Date() 97 year, month, dayNumber := param.BeginTime.Local().Date()
99 98
100 // 限制只有 在每月的15号进行每日评估填报时,才进行短信消息提醒 99 // 限制只有 在每月的15号进行每日评估填报时,才进行短信消息提醒
101 - if dayNumber != 15 {  
102 - return nil  
103 - } 100 + // if dayNumber != 15 {
  101 + // return nil
  102 + // }
104 // 每月15日的每日评估必做,15日上午9点 发送短信提醒 103 // 每月15日的每日评估必做,15日上午9点 发送短信提醒
105 dayTime := time.Date(year, month, dayNumber, 9, 0, 0, 0, time.Local) 104 dayTime := time.Date(year, month, dayNumber, 9, 0, 0, 0, time.Local)
106 newSms := domain.LogSms{ 105 newSms := domain.LogSms{
@@ -124,9 +123,31 @@ func (notices notifyStaffAssess2) makeNotify(param *domain.StaffAssess) *domain. @@ -124,9 +123,31 @@ func (notices notifyStaffAssess2) makeNotify(param *domain.StaffAssess) *domain.
124 123
125 // ifSend 确认是否发送通知 124 // ifSend 确认是否发送通知
126 func (notices notifyStaffAssess2) ifSend(index int) (bool, error) { 125 func (notices notifyStaffAssess2) ifSend(index int) (bool, error) {
127 - if constant.Env != "prd" { 126 + // if constant.Env != "prd" {
  127 + // return false, nil
  128 + // }
  129 + transactionContext, err := factory.CreateTransactionContext(nil)
  130 + if err != nil {
  131 + return false, err
  132 + }
  133 + if err := transactionContext.StartTransaction(); err != nil {
  134 + return false, err
  135 + }
  136 + defer func() {
  137 + _ = transactionContext.RollbackTransaction()
  138 + }()
  139 + staffAssessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{"transactionContext": transactionContext})
  140 + assessData, err := staffAssessRepo.FindOne(map[string]interface{}{"id": index})
  141 + if err != nil {
  142 + return false, err
  143 + }
  144 + _, _, dayNumber := assessData.BeginTime.Local().Date()
  145 + // 限制只有 在每月的15号进行每日评估填报时,才进行短信消息提醒
  146 + if dayNumber != 15 {
128 return false, nil 147 return false, nil
129 } 148 }
130 - 149 + if err := transactionContext.CommitTransaction(); err != nil {
  150 + return false, err
  151 + }
131 return true, nil 152 return true, nil
132 } 153 }