func RequestFromIpPaymentSystems(c web.C, w http.ResponseWriter, r *http.Request) { startOnce.Do(func() { golog, config = startones.Start("config.toml") }) confstr := config.Database.User + ":" + config.Database.Passwd + "@/" + config.Database.Database + "?parseTime=true" // golog.Info(confstr) db, err := sql.Open("mysql", confstr) if err != nil { golog.Err(err.Error()) } defer db.Close() msisdn := r.URL.Query()["msisdn"][0] if msisdn != "" { clid := sql2.GetMobileClientId(golog, *db, "select id from aclients where phone="+strings.Replace(msisdn, "358", "0", 1)) if clid == 0 { golog.Info("Not exist " + msisdn) phone := strings.Replace(msisdn, "358", "0", 1) sqlstr := "insert into aclients (phone,cdate,created_at,updated_at,serv) values('" + phone + "',now(),now(),now(),100)" sql2.InsertMobileClient(golog, *db, sqlstr) } else { golog.Info("Aclient exist " + msisdn) } query := r.URL.Query() for k, v := range query { golog.Info("Query " + k + " ----> " + v[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 ") } }
func main() { flag.Parse() // Scan the arguments list if *versionFlag { fmt.Println("Version:", APP_VERSION) } if *lostPerFlag > 0 { 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() callsCurdaysnum := sql2.GetSqlInt(golog, *db, "select count(*) from calls where cdate>=curdate()") abandonCurdaysnum := sql2.GetSqlInt(golog, *db, "select count(*) from queuemetrics.queuelogs where verb='ABANDON' and data1<>0 and cdate>=curdate()") calls7daysnum := sql2.GetSqlInt(golog, *db, "select count(*) from calls where cdate>=curdate() - INTERVAL 7 day") abandon7daysnum := sql2.GetSqlInt(golog, *db, "select count(*) from queuemetrics.queuelogs where verb='ABANDON' and data1<>0 and cdate>=curdate() - INTERVAL 7 day ") if callsCurdaysnum > 0 && abandonCurdaysnum > 0 && calls7daysnum > 0 && abandon7daysnum > 0 { var oneperfloat = float32(callsCurdaysnum) / float32(100) var perfloat = float32(abandonCurdaysnum) / oneperfloat var per int = int(perfloat) var sevenperfloat = float32(calls7daysnum) / float32(100) var perfloat7 = float32(abandon7daysnum) / sevenperfloat var per7 int = int(perfloat7) if per > *lostPerFlag { if _, err := os.Stat(VIZERFILE); os.IsNotExist(err) { golog.Info("/tmp/vizer.csv Not Exist " + time.Now().Format("2006/01/02")) controlvizer := []byte(time.Now().Format("2006/01/02") + "," + strconv.Itoa(per)) err := ioutil.WriteFile(VIZERFILE, controlvizer, 0644) if err != nil { golog.Err(err.Error()) } } else { content, err := ioutil.ReadFile(VIZERFILE) if err != nil { golog.Err(err.Error()) } else { parameters := strings.Split(string(content), ",") if parameter1Int, err := strconv.Atoi(strings.TrimSpace(parameters[1])); err != nil { golog.Err(err.Error()) } else { if per > parameter1Int { golog.Info("Send sms now " + strconv.Itoa(per) + " was " + parameters[1]) messagetext := time.Now().Format(time.RFC850) + " Current Calls " + strconv.Itoa(callsCurdaysnum) + " ABANDON " + strconv.Itoa(abandonCurdaysnum) + " lost " + strconv.Itoa(per) + "% Last 7 days Calls " + strconv.Itoa(calls7daysnum) + " ABANDON " + strconv.Itoa(abandon7daysnum) + " lost " + strconv.Itoa(per7) + "%" golog.Info(messagetext) send_vizer_message.Send(golog, "+358451202801", "+35870095943", messagetext) send_vizer_message.Send(golog, "+358451142458", "+35870095943", messagetext) } else { golog.Info("Don't send sms now " + strconv.Itoa(per) + " was " + parameters[1]) } } controlvizer := []byte(time.Now().Format("2006/01/02") + "," + strconv.Itoa(per)) err := ioutil.WriteFile(VIZERFILE, controlvizer, 0644) if err != nil { golog.Err(err.Error()) } } } } } else { golog.Info("Check stat probably somewhere '0'") } } else { golog.Err("per % not set??") fmt.Println("per % not set??") } }