本文整理汇总了Golang中github.com/c-darwin/dcoin-go/packages/utils.StrToInt64函数的典型用法代码示例。如果您正苦于以下问题:Golang StrToInt64函数的具体用法?Golang StrToInt64怎么用?Golang StrToInt64使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了StrToInt64函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: VotesExchange
func (c *Controller) VotesExchange() (string, error) {
txType := "VotesExchange"
txTypeId := utils.TypeInt(txType)
timeNow := time.Now().Unix()
eOwner := utils.StrToInt64(c.Parameters["e_owner_id"])
result := utils.StrToInt64(c.Parameters["result"])
signData := fmt.Sprintf("%d,%d,%d,%d,%d", txTypeId, timeNow, c.SessUserId, eOwner, result)
if eOwner == 0 {
signData = ""
}
TemplateStr, err := makeTemplate("votes_exchange", "votesExchange", &VotesExchangePage{
Alert: c.Alert,
Lang: c.Lang,
CountSignArr: c.CountSignArr,
ShowSignData: c.ShowSignData,
UserId: c.SessUserId,
TimeNow: timeNow,
TxType: txType,
TxTypeId: txTypeId,
EOwner: eOwner,
Result: result,
SignData: signData})
if err != nil {
return "", utils.ErrInfo(err)
}
return TemplateStr, nil
}
示例2: CfCatalog
func (c *Controller) CfCatalog() (string, error) {
var err error
log.Debug("CfCatalog")
categoryId := utils.Int64ToStr(int64(utils.StrToFloat64(c.Parameters["category_id"])))
log.Debug("categoryId", categoryId)
var curCategory string
addSql := ""
if categoryId != "0" {
addSql = `AND category_id = ` + categoryId
curCategory = c.Lang["cf_category_"+categoryId]
}
cfUrl := ""
projects := make(map[string]map[string]string)
cfProjects, err := c.GetAll(`
SELECT cf_projects.id, lang_id, blurb_img, country, city, currency_id, end_time, amount
FROM cf_projects
LEFT JOIN cf_projects_data ON cf_projects_data.project_id = cf_projects.id
WHERE del_block_id = 0 AND
end_time > ? AND
lang_id = ?
`+addSql+`
ORDER BY funders DESC
LIMIT 100
`, 100, utils.Time(), c.LangInt)
if err != nil {
return "", utils.ErrInfo(err)
}
for _, data := range cfProjects {
CfProjectData, err := c.GetCfProjectData(utils.StrToInt64(data["id"]), utils.StrToInt64(data["end_time"]), c.LangInt, utils.StrToFloat64(data["amount"]), cfUrl)
if err != nil {
return "", utils.ErrInfo(err)
}
for k, v := range CfProjectData {
data[k] = v
}
projects[data["id"]] = data
}
cfCategory := utils.MakeCfCategories(c.Lang)
TemplateStr, err := makeTemplate("cf_catalog", "cfCatalog", &cfCatalogPage{
Lang: c.Lang,
CfCategory: cfCategory,
CurrencyList: c.CurrencyList,
CurCategory: curCategory,
Projects: projects,
UserId: c.SessUserId,
CategoryId: categoryId,
CfUrl: cfUrl})
if err != nil {
return "", utils.ErrInfo(err)
}
return TemplateStr, nil
}
示例3: ESaveOrder
func (c *Controller) ESaveOrder() (string, error) {
if c.SessUserId == 0 {
return "", errors.New(c.Lang["sign_up_please"])
}
c.r.ParseForm()
sellCurrencyId := utils.StrToInt64(c.r.FormValue("sell_currency_id"))
buyCurrencyId := utils.StrToInt64(c.r.FormValue("buy_currency_id"))
amount := utils.StrToFloat64(c.r.FormValue("amount"))
sellRate := utils.StrToFloat64(c.r.FormValue("sell_rate"))
orderType := c.r.FormValue("type")
// можно ли торговать такими валютами
checkCurrency, err := c.Single("SELECT count(id) FROM e_currency WHERE id IN (?, ?)", sellCurrencyId, buyCurrencyId).Int64()
if err != nil {
return "", utils.ErrInfo(err)
}
if checkCurrency != 2 {
return "", errors.New("Currency error")
}
if orderType != "sell" && orderType != "buy" {
return "", errors.New("Type error")
}
if amount == 0 {
return "", errors.New(c.Lang["amount_error"])
}
if amount < 0.001 && sellCurrencyId < 1000 {
return "", errors.New(strings.Replace(c.Lang["save_order_min_amount"], "[amount]", "0.001", -1))
}
if sellRate < 0.0001 {
return "", errors.New(strings.Replace(c.Lang["save_order_min_price"], "[price]", "0.0001", -1))
}
reductionLock, err := utils.EGetReductionLock()
if err != nil {
return "", utils.ErrInfo(err)
}
if reductionLock > 0 {
return "", errors.New(strings.Replace(c.Lang["creating_orders_unavailable"], "[minutes]", "30", -1))
}
// нужно проверить, есть ли нужная сумма на счету юзера
userAmountAndProfit := utils.EUserAmountAndProfit(c.SessUserId, sellCurrencyId)
if userAmountAndProfit < amount {
return "", errors.New(c.Lang["not_enough_money"] + " (" + utils.Float64ToStr(userAmountAndProfit) + "<" + utils.Float64ToStr(amount) + ")" + strings.Replace(c.Lang["add_funds_link"], "[currency]", "USD", -1))
}
err = NewForexOrder(c.SessUserId, amount, sellRate, sellCurrencyId, buyCurrencyId, orderType, utils.StrToMoney(c.EConfig["commission"]))
if err != nil {
return "", utils.ErrInfo(err)
} else {
return utils.JsonAnswer(c.Lang["order_created"], "success").String(), nil
}
return ``, nil
}
示例4: MyCfProjects
func (c *Controller) MyCfProjects() (string, error) {
var err error
txType := "NewCfProject"
txTypeId := utils.TypeInt(txType)
timeNow := utils.Time()
projectsLang := make(map[string]map[string]string)
projects := make(map[string]map[string]string)
cfProjects, err := c.GetAll(`
SELECT id, category_id, project_currency_name, country, city, currency_id, end_time, amount
FROM cf_projects
WHERE user_id = ? AND del_block_id = 0
`, -1, c.SessUserId)
if err != nil {
return "", utils.ErrInfo(err)
}
for _, data := range cfProjects {
CfProjectData, err := c.GetCfProjectData(utils.StrToInt64(data["id"]), utils.StrToInt64(data["end_time"]), c.LangInt, utils.StrToFloat64(data["amount"]), "")
if err != nil {
return "", utils.ErrInfo(err)
}
for k, v := range CfProjectData {
data[k] = v
}
projects[data["id"]] = data
lang, err := c.GetMap(`SELECT id, lang_id FROM cf_projects_data WHERE project_id = ?`, "id", "lang_id", data["id"])
projectsLang[data["id"]] = lang
}
cfLng, err := c.GetAllCfLng()
TemplateStr, err := makeTemplate("my_cf_projects", "myCfProjects", &MyCfProjectsPage{
Alert: c.Alert,
Lang: c.Lang,
CountSignArr: c.CountSignArr,
ShowSignData: c.ShowSignData,
UserId: c.SessUserId,
TimeNow: timeNow,
TxType: txType,
TxTypeId: txTypeId,
CfLng: cfLng,
CurrencyList: c.CurrencyList,
Projects: projects,
ProjectsLang: projectsLang})
if err != nil {
return "", utils.ErrInfo(err)
}
return TemplateStr, nil
}
示例5: EDelOrder
func (c *Controller) EDelOrder() (string, error) {
c.r.ParseForm()
orderId := utils.StrToInt64(c.r.FormValue("order_id"))
// возвращаем сумму ордера на кошелек + возращаем комиссию.
order, err := utils.DB.OneRow("SELECT amount, sell_currency_id FROM e_orders WHERE id = ? AND user_id = ? AND del_time = 0 AND empty_time = 0", orderId, c.SessUserId).String()
if err != nil {
return "", utils.ErrInfo(err)
}
if len(order) == 0 {
return "", utils.ErrInfo("order_id error")
}
sellCurrencyId := utils.StrToInt64(order["sell_currency_id"])
amount := utils.StrToFloat64(order["amount"])
amountAndCommission := utils.StrToFloat64(order["amount"]) / (1 - c.ECommission/100)
// косиссия биржи
commission := amountAndCommission - amount
err = userLock(c.SessUserId)
if err != nil {
return "", err
}
// отмечаем, что ордер удален
err = utils.DB.ExecSql("UPDATE e_orders SET del_time = ? WHERE id = ? AND user_id = ?", utils.Time(), orderId, c.SessUserId)
if err != nil {
return "", utils.ErrInfo(err)
}
// возвращаем остаток ордера на кошель
userAmount := utils.EUserAmountAndProfit(c.SessUserId, sellCurrencyId)
err = utils.DB.ExecSql("UPDATE e_wallets SET amount = ?, last_update = ? WHERE user_id = ? AND currency_id = ?", userAmount+amountAndCommission, utils.Time(), c.SessUserId, sellCurrencyId)
if err != nil {
return "", utils.ErrInfo(err)
}
// вычитаем комиссию биржи
userAmount = utils.EUserAmountAndProfit(1, sellCurrencyId)
err = utils.DB.ExecSql("UPDATE e_wallets SET amount = ?, last_update = ? WHERE user_id = 1 AND currency_id = ?", userAmount-commission, utils.Time(), sellCurrencyId)
if err != nil {
return "", utils.ErrInfo(err)
}
userUnlock(c.SessUserId)
return ``, nil
}
示例6: main
func main() {
f := tests_utils.InitLog()
defer f.Close()
txType := "DelPromisedAmount"
txTime := "1427383713"
userId := []byte("2")
var blockId int64 = 128008
var txSlice [][]byte
// hash
txSlice = append(txSlice, []byte("1111111111"))
// type
txSlice = append(txSlice, utils.Int64ToByte(utils.TypeInt(txType)))
// time
txSlice = append(txSlice, []byte(txTime))
// user_id
txSlice = append(txSlice, []byte("1"))
// promised_amount_id
txSlice = append(txSlice, []byte("4"))
// sign
txSlice = append(txSlice, []byte("11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"))
blockData := new(utils.BlockData)
blockData.BlockId = blockId
blockData.Time = utils.StrToInt64(txTime)
blockData.UserId = utils.BytesToInt64(userId)
err := tests_utils.MakeTest(txSlice, blockData, txType, "work_and_rollback")
if err != nil {
fmt.Println(err)
}
}
示例7: main
func main() {
f := tests_utils.InitLog()
defer f.Close()
txType := "NewPct"
txTime := "1599278817"
userId := []byte("2")
var blockId int64 = 140015
//data:=`{"currency":{"1":{"miner_pct":"0.0000000617044","user_pct":"0.0000000439591"},"72":{"miner_pct":"0.0000000617044","user_pct":"0.0000000439591"}},"referral":{"first":10,"second":0,"third":0}}`
data := `{"currency":{"1":{"miner_pct":"0.0000000617044","user_pct":"0.0000000435602"},"72":{"miner_pct":"0.0000000760368","user_pct":"0.0000000562834"}},"referral":{"first":30,"second":20,"third":5}}`
var txSlice [][]byte
// hash
txSlice = append(txSlice, []byte("22cb812e53e22ee539af4a1d39b4596d"))
// type
txSlice = append(txSlice, utils.Int64ToByte(utils.TypeInt(txType)))
// time
txSlice = append(txSlice, []byte(txTime))
// user_id
txSlice = append(txSlice, userId)
// promised_amount_id
txSlice = append(txSlice, []byte(data))
dataForSign := fmt.Sprintf("%v,%v,%s,%s", utils.TypeInt(txType), txTime, userId, data)
err := tests_utils.MakeFrontTest(txSlice, utils.StrToInt64(txTime), dataForSign, txType, utils.BytesToInt64(userId), "", blockId)
if err != nil {
fmt.Println(err)
}
}
示例8: main
func main() {
f := tests_utils.InitLog()
defer f.Close()
txType := "Abuses"
txTime := "1427383713"
userId := []byte("2")
var blockId int64 = 128008
var txSlice [][]byte
// hash
txSlice = append(txSlice, []byte("1111111111"))
// type
txSlice = append(txSlice, utils.Int64ToByte(utils.TypeInt(txType)))
// time
txSlice = append(txSlice, []byte(txTime))
// user_id
txSlice = append(txSlice, []byte("1"))
// message
txSlice = append(txSlice, []byte(`{"1":"fdfdsfdd", "2":"fsdfkj43 43 34"}`))
// sign
txSlice = append(txSlice, []byte("11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"))
blockData := new(utils.BlockData)
blockData.BlockId = blockId
blockData.Time = utils.StrToInt64(txTime)
blockData.UserId = utils.BytesToInt64(userId)
err := tests_utils.MakeTest(txSlice, blockData, txType, "work_and_rollback")
if err != nil {
fmt.Println(err)
}
}
示例9: ERedirect
func (c *Controller) ERedirect() (string, error) {
c.r.ParseForm()
token := c.r.FormValue("FormToken")
amount := c.r.FormValue("FormExAmount")
buyCurrencyId := utils.StrToInt64(c.r.FormValue("FormDC"))
if !utils.CheckInputData(token, "string") {
return "", errors.New("incorrect data")
}
// order_id занесем когда поуступят деньги в платежной системе
err := c.ExecSql(`UPDATE e_tokens SET buy_currency_id = ?, amount_fiat = ? WHERE token = ?`, buyCurrencyId, utils.StrToFloat64(c.r.FormValue("FormExAmount")), token)
if err != nil {
return "", utils.ErrInfo(err)
}
tokenId, err := c.Single(`SELECT id FROM e_tokens WHERE token = ?`, token).String()
if err != nil {
return "", utils.ErrInfo(err)
}
TemplateStr, err := makeTemplate("e_redirect", "eRedirect", &ERedirectPage{
Lang: c.Lang,
EConfig: c.EConfig,
TokenId: tokenId,
EURL: c.EURL,
MDesc: base64.StdEncoding.EncodeToString([]byte("token-" + tokenId)),
Amount: amount})
if err != nil {
return "", utils.ErrInfo(err)
}
return TemplateStr, nil
}
示例10: main
func main() {
f := tests_utils.InitLog()
defer f.Close()
txType := "NewUser"
txTime := "1427383713"
userId := []byte("2")
var blockId int64 = 128008
var txSlice [][]byte
// hash
txSlice = append(txSlice, []byte("1111111111"))
// type
txSlice = append(txSlice, utils.Int64ToByte(utils.TypeInt(txType)))
// time
txSlice = append(txSlice, []byte(txTime))
// user_id
txSlice = append(txSlice, []byte("1"))
// public_key
txSlice = append(txSlice, utils.HexToBin([]byte("30820122300d06092a864886f70d01010105000382010f003082010a0282010100ae7797b5c16358862f083bb26cde86b233ba97c48087df44eaaf88efccfe554bf51df8dc7e99072cbe433933f1b87aa9ef62bd5d49dc40e75fe398426c727b0773ea9e4d88184d64c1aa561b1cdf78abe07ca5d23711c403f58abf30d41f4b96161649a91a95818d9d482e8fa3f91829abce3d80f6fc3708ce23f6841bb4a8bae301b23745fce5134420fec0519a081f162d16e4dd0da2e8869b5b67122a1fb7e9bcdb8b2512d1edabdb271bee190563b36a66f5498f50d2fc7202ad2f43b90f860428d5ecd67973900d9997475d4e1a1e4c56b44411cc4b5e9c660fe23fdcd5ab956a834fa05a4ecac9d815143d84993c9424d86379b6f76e3be9aeaaff48fb0203010001)")))
// sign
txSlice = append(txSlice, []byte("11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"))
blockData := new(utils.BlockData)
blockData.BlockId = blockId
blockData.Time = utils.StrToInt64(txTime)
blockData.UserId = utils.BytesToInt64(userId)
err := tests_utils.MakeTest(txSlice, blockData, txType, "work_and_rollback")
if err != nil {
fmt.Println(err)
}
}
示例11: main
func main() {
f := tests_utils.InitLog()
defer f.Close()
txType := "ChangeHost"
txTime := "1399278817"
userId := []byte("2")
var blockId int64 = 1415
host := "http://fdfdfd.ru/"
var txSlice [][]byte
// hash
txSlice = append(txSlice, []byte("22cb812e53e22ee539af4a1d39b4596d"))
// type
txSlice = append(txSlice, utils.Int64ToByte(utils.TypeInt(txType)))
// time
txSlice = append(txSlice, []byte(txTime))
// user_id
txSlice = append(txSlice, userId)
// promised_amount_id
txSlice = append(txSlice, []byte(host))
dataForSign := fmt.Sprintf("%v,%v,%s,%s", utils.TypeInt(txType), txTime, userId, host)
err := tests_utils.MakeFrontTest(txSlice, utils.StrToInt64(txTime), dataForSign, txType, utils.BytesToInt64(userId), "", blockId)
if err != nil {
fmt.Println(err)
}
}
示例12: EData
func (c *Controller) EData() (string, error) {
c.w.Header().Set("Access-Control-Allow-Origin", "*")
// сколько всего продается DC
eOrders, err := c.GetAll(`SELECT sell_currency_id, sum(amount) as amount FROM e_orders WHERE sell_currency_id < 1000 AND empty_time = 0 GROUP BY sell_currency_id`, 100)
if err != nil {
return "", utils.ErrInfo(err)
}
values := ""
for _, data := range eOrders {
values += utils.ClearNull(data["amount"], 0) + ` d` + c.CurrencyList[utils.StrToInt64(data["sell_currency_id"])] + `, `
}
if len(values) > 0 {
values = values[:len(values)-2]
}
ps, err := c.Single(`SELECT value FROM e_config WHERE name = 'ps'`).String()
if err != nil {
return "", utils.ErrInfo(err)
}
jsonData, err := json.Marshal(map[string]string{"values": values, "ps": ps})
if err != nil {
return "", utils.ErrInfo(err)
}
return string(jsonData), nil
}
示例13: makeVcomplex
func makeVcomplex(json_data []byte) (*vComplex, error) {
vComplex := new(vComplex)
err := json.Unmarshal(json_data, &vComplex)
if err != nil {
vComplex_ := new(vComplex_)
err = json.Unmarshal(json_data, &vComplex_)
if err != nil {
vComplex__ := new(vComplex__)
err = json.Unmarshal(json_data, &vComplex__)
if err != nil {
return vComplex, err
}
vComplex.Referral = vComplex__.Referral
vComplex.Currency = vComplex__.Currency
vComplex.Admin = utils.StrToInt64(vComplex__.Admin)
} else {
vComplex.Referral = make(map[string]string)
for k, v := range vComplex_.Referral {
vComplex.Referral[k] = utils.Int64ToStr(v)
}
vComplex.Currency = vComplex_.Currency
vComplex.Admin = vComplex_.Admin
}
}
return vComplex, nil
}
示例14: main
func main() {
f := tests_utils.InitLog()
defer f.Close()
txType := "NewMaxOtherCurrencies"
txTime := "1427383713"
userId := []byte("2")
var blockId int64 = 128008
var txSlice [][]byte
// hash
txSlice = append(txSlice, []byte("1111111111"))
// type
txSlice = append(txSlice, utils.Int64ToByte(utils.TypeInt(txType)))
// time
txSlice = append(txSlice, []byte(txTime))
// user_id
txSlice = append(txSlice, []byte("1"))
// json data
txSlice = append(txSlice, []byte(`{"1":"1000", "72":500}`))
// sign
txSlice = append(txSlice, []byte("11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"))
blockData := new(utils.BlockData)
blockData.BlockId = blockId
blockData.Time = utils.StrToInt64(txTime)
blockData.UserId = utils.BytesToInt64(userId)
err := tests_utils.MakeTest(txSlice, blockData, txType, "work_and_rollback")
if err != nil {
fmt.Println(err)
}
}
示例15: checkHosts
func checkHosts(hosts []map[string]string, countOk *int) []map[string]string {
ch := make(chan *answerType)
for _, host := range hosts {
userId := utils.StrToInt64(host["user_id"])
go func(userId int64, host string) {
ch_ := make(chan *answerType, 1)
go func() {
log.Debug("host: %v / userId: %v", host, userId)
ch_ <- check(host, userId)
}()
select {
case reachable := <-ch_:
ch <- reachable
case <-time.After(consts.WAIT_CONFIRMED_NODES * time.Second):
ch <- &answerType{userId: userId, answer: 0}
}
}(userId, host["host"])
}
log.Debug("%v", "hosts", hosts)
var newHosts []map[string]string
// если нода не отвечает, то удалем её из таблы nodes_connection
for i := 0; i < len(hosts); i++ {
result := <-ch
if result.answer == 0 {
log.Info("delete %v", result.userId)
err = utils.DB.ExecSql("DELETE FROM nodes_connection WHERE user_id = ?", result.userId)
if err != nil {
log.Error("%v", err)
}
/*for _, data := range hosts {
if utils.StrToInt64(data["user_id"]) != result.userId {
newHosts = append(newHosts, data)
}
}*/
} else {
for _, data := range hosts {
if utils.StrToInt64(data["user_id"]) == result.userId {
newHosts = append(newHosts, data)
}
}
*countOk++
}
log.Info("answer: %v", result)
}
return newHosts
}