...
|
...
|
@@ -3,6 +3,7 @@ package notify |
|
|
import (
|
|
|
"time"
|
|
|
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
|
|
|
)
|
|
|
|
...
|
...
|
@@ -21,8 +22,8 @@ func (notices notifyConfirmEvaluationScore) makeNotify(param *domain.SummaryEval |
|
|
newSms := domain.LogSms{
|
|
|
Id: 0,
|
|
|
Phone: param.Executor.Account,
|
|
|
TemplateId: 5475050,
|
|
|
Template: "您好,#name#,#periodName#成绩已出,请前往绩效系统PC端进行确认哦,逾期未确认可能会影响当月绩效工资哦~ ",
|
|
|
TemplateId: 5634326,
|
|
|
Template: "您好,#name#,#periodName#成绩已出,请前往绩效系统PC端进行确认哦,超时未确认可能会影响当月绩效工资哦~ ",
|
|
|
Value: map[string]string{
|
|
|
"name": param.Executor.UserName,
|
|
|
"periodName": param.CycleName,
|
...
|
...
|
@@ -37,12 +38,53 @@ func (notices notifyConfirmEvaluationScore) makeNotify(param *domain.SummaryEval |
|
|
return &newSms
|
|
|
}
|
|
|
|
|
|
// 适配规则:上级提交评估后 到10号晚23:59前,可以发送
|
|
|
// 适配规则 对未确认的被评估人每隔6个小时进行提醒(23:00-7:00期间不提醒),直到确认
|
|
|
func (notices notifyConfirmEvaluationScore) ifSend(index int) (bool, error) {
|
|
|
|
|
|
//检查时间
|
|
|
//适配规则:上级提交评估后 到10号晚23:59前,可以发送
|
|
|
//
|
|
|
nowTime := time.Now()
|
|
|
if nowTime.Day() > 10 {
|
|
|
return false, nil
|
|
|
}
|
|
|
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return false, err
|
|
|
}
|
|
|
if err := transactionContext.StartTransaction(); err != nil {
|
|
|
return false, err
|
|
|
}
|
|
|
defer func() {
|
|
|
_ = transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
summaryEvaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
summaryEvaluationData, err := summaryEvaluationRepo.FindOne(map[string]interface{}{"id": index})
|
|
|
if err != nil {
|
|
|
return false, err
|
|
|
}
|
|
|
if summaryEvaluationData.Types == domain.EvaluationFinish {
|
|
|
return false, nil
|
|
|
}
|
|
|
//已确认 成绩,不在发送成绩
|
|
|
if summaryEvaluationData.CheckResult == domain.EvaluationCheckCompleted {
|
|
|
return false, nil
|
|
|
}
|
|
|
|
|
|
//检查数据 SummaryEvaluation ,types=5,并添加短信数据
|
|
|
//适配规则 对未确认的被评估人每隔6个小时进行提醒(23:00-7:00期间不提醒),直到确认
|
|
|
//计算下一条短信
|
|
|
smsMessage := notices.makeNotify(summaryEvaluationData)
|
|
|
nextTime := nowTime.Add(6 * time.Hour)
|
|
|
smsMessage.ExecuteAt = notices.getTimeExecuteAt(nextTime)
|
|
|
logSmsRepo := factory.CreateLogSmsRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
err = logSmsRepo.Save(smsMessage)
|
|
|
if err != nil {
|
|
|
return true, err
|
|
|
}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return false, err
|
|
|
}
|
|
|
|
|
|
return true, nil
|
|
|
}
|
...
|
...
|
|