|
|
@@ -1,7 +1,7 @@
|
|
|
package oilsupplier
|
|
|
|
|
|
import (
|
|
|
- "dashoo.cn/backend/api/business/msg"
|
|
|
+ msg2 "dashoo.cn/backend/api/business/msg"
|
|
|
"dashoo.cn/backend/api/business/audithistory"
|
|
|
"dashoo.cn/backend/api/business/codecsequence"
|
|
|
"dashoo.cn/backend/api/business/oilsupplier/supplier"
|
|
|
@@ -12,6 +12,7 @@ import (
|
|
|
"fmt"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
+ "supplier_system/src/dashoo.cn/backend/api/business/msg"
|
|
|
"time"
|
|
|
|
|
|
"dashoo.cn/backend/api/business/auditsetting"
|
|
|
@@ -1217,24 +1218,42 @@ func (this *OilSupplierCertController) CreateAccessCardNo() {
|
|
|
// @Success 200 {object} controllers.Request
|
|
|
// @router /updatainflag/ [get]
|
|
|
func (this *OilSupplierCertController) UpdataInFlag() {
|
|
|
+ t := time.Now()
|
|
|
+ session := utils.DBE.NewSession()
|
|
|
var certentitys []suppliercert.OilSupplierCert
|
|
|
- svc := suppliercert.GetOilSupplierCertService(utils.DBE)
|
|
|
- svc.GetEntities(&certentitys, "")
|
|
|
+ svc := suppliercert.GetOilSupplierCertSession(session)
|
|
|
+ defer func() {
|
|
|
+ session.Close()
|
|
|
+ }()
|
|
|
+ err := session.Begin()
|
|
|
+ svc.GetEntities(&certentitys, "InFlag!='3'")
|
|
|
+ currenttime := time.Now()
|
|
|
+ //.Format("2006-01-02")
|
|
|
for i := 0; i < len(certentitys); i++ {
|
|
|
- if time.Now().Format("2006-01-02") == certentitys[i].ApplyTime.Format("2006-01-02") {
|
|
|
+ if currenttime.After(certentitys[i].ApplyTime) && !currenttime.After(certentitys[i].ApplyTime.AddDate(1,0,0)) && certentitys[i].InFlag != "2" {
|
|
|
var certentity suppliercert.OilSupplierCert
|
|
|
certentity.InFlag = "2"
|
|
|
cols := []string{"InFlag"}
|
|
|
- svc.UpdateEntityByIdCols(certentitys[i].Id, &certentity, cols)
|
|
|
+ _,err = svc.UpdateEntityByIdCols(certentitys[i].Id, &certentity, cols)
|
|
|
+ if err != nil {
|
|
|
+ session.Rollback()
|
|
|
+ }
|
|
|
}
|
|
|
- if certentitys[i].ApplyTime.AddDate(1, 0, 0).Format("2006-01-02") == time.Now().Format("2006-01-02") {
|
|
|
- fmt.Println(certentitys[i].ApplyTime.AddDate(1, 0, 0).Format("2006-01-02"), time.Now().Format("2006-01-02"))
|
|
|
+ if currenttime.After(certentitys[i].ApplyTime.AddDate(1, 0, 0)) {
|
|
|
+ fmt.Println(time.Now().Format("2006-01-02"), certentitys[i].ApplyTime.AddDate(1, 0, 0).Format("2006-01-02"))
|
|
|
var certentity suppliercert.OilSupplierCert
|
|
|
certentity.InFlag = "3"
|
|
|
cols := []string{"InFlag"}
|
|
|
- svc.UpdateEntityByIdCols(certentitys[i].Id, &certentity, cols)
|
|
|
+ _,err = svc.UpdateEntityByIdCols(certentitys[i].Id, &certentity, cols)
|
|
|
+ if err != nil {
|
|
|
+ session.Rollback()
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ err = session.Commit()
|
|
|
+ fmt.Println(err)
|
|
|
+ elapsed := time.Since(t)
|
|
|
+ fmt.Println(elapsed, "更新准入标识")
|
|
|
}
|
|
|
|
|
|
// @Title 保存准入编码
|
|
|
@@ -1281,4 +1300,42 @@ func (this *OilSupplierCertController) SaveAccessCardNo() {
|
|
|
this.Data["json"] = &errinfo
|
|
|
this.ServeJSON()
|
|
|
}
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 快到期短信通知
|
|
|
+// @Description 修改准入标识
|
|
|
+// @Success 200 {object} controllers.Request
|
|
|
+// @router /sendingSMS/ [get]
|
|
|
+func (this *OilSupplierCertController) SendingSMS() {
|
|
|
+ t := time.Now()
|
|
|
+ svcsupp := supplier.GetOilSupplierService(utils.DBE)
|
|
|
+ var list []supplier.OilSupplierView
|
|
|
+ where := "b.InFlag = '1'"
|
|
|
+ svcsupp.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, 0, 0, "Id", true, &list, where)
|
|
|
+ currenttime := time.Now()
|
|
|
+
|
|
|
+ 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))
|
|
|
+ }
|
|
|
+ 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))
|
|
|
+ }
|
|
|
+ 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))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ elapsed := time.Since(t)
|
|
|
+ fmt.Println(elapsed, "快到期提醒")
|
|
|
+
|
|
|
+
|
|
|
}
|