Ver código fonte

定时任务bug

lining 6 anos atrás
pai
commit
c074f0718d

+ 0 - 2
src/dashoo.cn/backend/api/business/msg/msgService.go

@@ -4,7 +4,6 @@ import (
 	"dashoo.cn/backend/api/business/oilrtx"
 	. "dashoo.cn/backend/api/mydb"
 	"dashoo.cn/utils"
-	. "dashoo.cn/utils/db"
 	"encoding/json"
 	"fmt"
 	"github.com/go-xorm/xorm"
@@ -15,7 +14,6 @@ import (
 )
 
 type MsgService struct {
-	ServiceBase
 	MyServiceBase
 }
 

+ 1 - 1
src/dashoo.cn/backend/api/business/oilsupplier/supplier/oilsupplier.go

@@ -332,7 +332,7 @@ type ExpireFile struct {
 	Id            int
 	SupplierName  string
 	Mobile        string
-	ExpireAllFile string
+	NeedAllFile   string
 	CreateBy      string
 	ContactName   string
 	CreateUserId  int

+ 21 - 6
src/dashoo.cn/backend/api/controllers/oilsupplier/suppliercert.go

@@ -21,6 +21,7 @@ import (
 	"strconv"
 	"strings"
 	"time"
+	"unicode/utf8"
 
 	"dashoo.cn/backend/api/business/auditsetting"
 
@@ -1639,25 +1640,28 @@ func (this *OilSupplierCertController) SendingSMS() {
 	where := "b.InFlag = '1'"
 	svcsupp.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, 0, 0, "Id", true, &list, where)
 	currenttime := time.Now()
-
+    loginName := "TimingTask"
+	if this.User != nil {
+		loginName = this.User.Username
+	}
 	for _, item := range list {
 		if currenttime.AddDate(0, 3, 0).Format("2006-01-02") == (item.ApplyTime.Format("2006-01-02")) {
 			toMobile := item.Mobile
 			msg := "您的" + item.SupplierTypeName + "准入还有3个月到期"
 			msgService := msg2.GetMsgService(utils.DBE)
-			msgService.HandleMsg(toMobile, msg, "1-1", item.CreateBy, item.ContactName, strconv.Itoa(item.CreateUserId), this.User.Username)
+			msgService.HandleMsg(toMobile, msg, "1-1", item.CreateBy, item.ContactName, strconv.Itoa(item.CreateUserId), loginName)
 		}
 		if currenttime.AddDate(0, 2, 0).Format("2006-01-02") == (item.ApplyTime.Format("2006-01-02")) {
 			toMobile := item.Mobile
 			msg := "您的" + item.SupplierTypeName + "准入还有2个月到期"
 			msgService := msg2.GetMsgService(utils.DBE)
-			msgService.HandleMsg(toMobile, msg, "1-1", item.CreateBy, item.ContactName, strconv.Itoa(item.CreateUserId), this.User.Username)
+			msgService.HandleMsg(toMobile, msg, "1-1", item.CreateBy, item.ContactName, strconv.Itoa(item.CreateUserId), loginName)
 		}
 		if currenttime.AddDate(0, 1, 0).Format("2006-01-02") == (item.ApplyTime.Format("2006-01-02")) {
 			toMobile := item.Mobile
 			msg := "您的" + item.SupplierTypeName + "准入还有1个月到期"
 			msgService := msg2.GetMsgService(utils.DBE)
-			msgService.HandleMsg(toMobile, msg, "1-1", item.CreateBy, item.ContactName, strconv.Itoa(item.CreateUserId), this.User.Username)
+			msgService.HandleMsg(toMobile, msg, "1-1", item.CreateBy, item.ContactName, strconv.Itoa(item.CreateUserId), loginName)
 		}
 	}
 	elapsed := time.Since(t)
@@ -1678,10 +1682,21 @@ func (this *OilSupplierCertController) SendingSMSSupplierFile() {
 
 	if err == nil {
 		for _, item := range expireFile {
+			fileName := ""
+			if utf8.RuneCountInString(item.NeedAllFile) > 50 {
+				fileName = item.NeedAllFile[0: 120]
+				fileName = fileName[0: strings.LastIndex(fileName, ";")] + "等资质"
+			} else {
+				fileName = item.NeedAllFile
+			}
 			toMobile := item.Mobile
-			msg := "您的" + item.ExpireAllFile + "还有1个月到期"
+			msg := "您的" + fileName + "还有1个月到期"
 			msgService := msg2.GetMsgService(utils.DBE)
-			msgService.HandleMsg(toMobile, msg, "1-1", item.CreateBy, item.ContactName, strconv.Itoa(item.CreateUserId), this.User.Username)
+			loginName := "TimingTask"
+			if this.User != nil {
+				loginName = this.User.Username
+			}
+			msgService.HandleMsg(toMobile, msg, "1-1", item.CreateBy, item.ContactName, strconv.Itoa(item.CreateUserId), loginName)
 		}
 	}
 	elapsed := time.Since(t)