Пример #1
0
func main() {

	flag.Parse() // Scan the arguments list

	if *quantFlag > 0 && *daysFlag > 0 {

		quant := strconv.Itoa(*quantFlag)
		days := strconv.Itoa(*daysFlag)

		golog, config = startones.Start("config.toml")
		confstr := config.Database.User + ":" + config.Database.Passwd + "@/" + config.Database.Database + "?parseTime=true"
		db, err := sql.Open("mysql", confstr)
		if err != nil {
			golog.Err(err.Error())
		}
		defer db.Close()

		time.Now()

		beginningOfMonth := now.BeginningOfMonth().Format("2006-01-02")

		sqlstr := "select phones.number,phones.provider_id,advertisements.atext from advertisements,phones where journal_id=42 and fromday >= '" + beginningOfMonth + "' and phones.id = advertisements.phone_id and phones.provider_id > 1 order by phones.number"

		//		fmt.Println(sqlstr)

		telmaimosarr := sql2.GetSqlMainosTel(golog, *db, sqlstr)

		sqlstr = "select phone,nmake from aclients where block = 0 and sulje = 0 and ennu = 0 and opcode in (50,54,56,49,79,'na') and nupdate_make <=adddate(now(), -" + days + ") order by id desc limit " + quant

		//		sqlstr = "select phone,nmake from aclients where  phone='0451142458'"
		telmaimosarr_from_aclients := sql2.GetSqlMainosTel(golog, *db, sqlstr)

		smsmainosmaker.CreateSmsOut(golog, *db, telmaimosarr, telmaimosarr_from_aclients)

	} else {

		fmt.Println("try -h")
		//		fmt.Println("try -h ")

	}

}
Пример #2
0
func GetLastMainos() {

	var golog syslog.Writer
	var config domains.Config

	confstr := config.Database.User + ":" + config.Database.Passwd + "@/" + config.Database.Database + "?parseTime=true"

	db, err := sql.Open("mysql", confstr)
	if err != nil {
		golog.Err(err.Error())
	}
	defer db.Close()

	sql2.GetSqlMainosTel(golog, *db, "select count(*) from calls where cdate>=curdate()")

}