浏览代码

Merge branch 'pool_353' into debug

ziwen 2 年之前
父节点
当前提交
3d65557907
共有 3 个文件被更改,包括 20 次插入4 次删除
  1. 12 2
      models/eta_trial.go
  2. 6 2
      services/eta_trial.go
  3. 2 0
      utils/config.go

+ 12 - 2
models/eta_trial.go

@@ -3,6 +3,7 @@ package models
 import (
 	"github.com/beego/beego/v2/client/orm"
 	"hongze/hongze_task/utils"
+	"time"
 )
 
 type ETATrialListRespItem struct {
@@ -35,7 +36,16 @@ func GetETATrialDisableList(endDate string) (items []*ETATrialListRespItem, err
 
 func UpdateETATrialDisable(disableIds []int) (err error) {
 	o := orm.NewOrm()
-	sql := `UPDATE eta_trial SET enabled = 0 WHERE eta_trial_id IN (` + utils.GetOrmInReplace(len(disableIds)) + `) `
-	_, err = o.Raw(sql, disableIds).Exec()
+	expTime := time.Now().AddDate(0,0,-14)
+	sql := `UPDATE eta_trial SET enabled = 0, modify_time = ? WHERE eta_trial_id IN (` + utils.GetOrmInReplace(len(disableIds)) + `) `
+	_, err = o.Raw(sql, expTime, disableIds, ).Exec()
+	return
+}
+
+func UpdateETATrialAdminDisable(disableMobiles []string) (err error) {
+	o := orm.NewOrmUsingDB("weekly_trial")
+	expTime := time.Now().AddDate(0,0,-14)
+	sql := `UPDATE admin SET enabled = 0, modify_time = ? WHERE mobile IN (` + utils.GetOrmInReplace(len(disableMobiles)) + `) `
+	_, err = o.Raw(sql, expTime, disableMobiles).Exec()
 	return
 }

+ 6 - 2
services/eta_trial.go

@@ -25,9 +25,10 @@ func ETATrialDisabled(cont context.Context) (err error) {
 		return
 	}
 	disableIds := make([]int, 0)
+	disableMobiles := make([]string, 0)
 	for _, v := range items {
-		fmt.Println(v.Mobile)
 		disableIds = append(disableIds, v.EtaTrialId)
+		disableMobiles = append(disableMobiles, "`" + v.Mobile + "`")
 	}
 
 	if len(disableIds) > 0 {
@@ -35,8 +36,11 @@ func ETATrialDisabled(cont context.Context) (err error) {
 		if err != nil {
 			return err
 		}
+		err = models.UpdateETATrialAdminDisable(disableMobiles)
+		if err != nil {
+			return err
+		}
 	}
 
-
 	return
 }

+ 2 - 0
utils/config.go

@@ -13,6 +13,7 @@ var (
 	MYSQL_URL_EDB  string
 	MYSQL_URL_DATA string
 	MYSQL_URL_GL   string
+	MYSQL_URL_WEEKLY_TRIAL       string // ETA试用
 )
 
 var (
@@ -104,6 +105,7 @@ func init() {
 	MYSQL_URL_EDB = config["mysql_url_edb"]
 	MYSQL_URL_DATA = config["mysql_url_data"]
 	MYSQL_URL_GL = config["mysql_url_gl"]
+	MYSQL_URL_WEEKLY_TRIAL = config["mysql_url_weekly_trial"]
 
 	//同花顺公钥
 	THS_PubKey = `-----BEGIN PUBLIC KEY-----