123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- package services
- import (
- "context"
- "fmt"
- "hongze/hongze_task/models"
- "hongze/hongze_task/utils"
- "time"
- )
- //ETA试用客户 启用->禁用
- func ETATrialDisabled(cont context.Context) (err error) {
- defer func() {
- if err != nil {
- go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "ETA试用客户 启用->禁用 ErrMsg:"+err.Error(), utils.EmailSendToUsers)
- }
- }()
- expiredTime := time.Now().AddDate(0, 0, -14).Format(utils.FormatDate)
- items, err := models.GetETATrialDisableList(expiredTime)
- if err != nil && err.Error() != utils.ErrNoRow() {
- fmt.Println("GetETATrialDisableList Err:" + err.Error())
- utils.FileLog.Info("GetETATrialDisableList Err:%s" + err.Error())
- return
- }
- disableIds := make([]int, 0)
- disableMobiles := make([]string, 0)
- for _, v := range items {
- disableIds = append(disableIds, v.EtaTrialId)
- disableMobiles = append(disableMobiles, v.Mobile )
- }
- if len(disableIds) > 0 {
- err = models.UpdateETATrialDisable(disableIds)
- if err != nil {
- return err
- }
- }
- if len(disableMobiles) > 0 {
- err = models.UpdateETATrialAdminDisable(disableMobiles)
- if err != nil {
- return err
- }
- }
- return
- }
|