本文整理汇总了Golang中github.com/c-darwin/dcoin-go/packages/utils.StrToInt64函数的典型用法代码示例。如果您正苦于以下问题:Golang StrToInt64函数的具体用法?Golang StrToInt64怎么用?Golang StrToInt64使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了StrToInt64函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:30,代码来源:votes_exchange.go
示例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
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:58,代码来源:cf_catalog.go
示例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
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:54,代码来源:e_save_order.go
示例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
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:51,代码来源:my_cf_projects.go
示例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
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:48,代码来源:e_del_order.go
示例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)
}
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:35,代码来源:del_promised_amount.go
示例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)
}
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:32,代码来源:new_pct_front.go
示例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)
}
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:35,代码来源:abuses.go
示例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
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:34,代码来源:e_redirect.go
示例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)
}
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:34,代码来源:new_user.go
示例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)
}
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:30,代码来源:change_host_front.go
示例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
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:28,代码来源:e_data.go
示例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
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:26,代码来源:votes_complex.go
示例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)
}
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:35,代码来源:new_max_other_currencies.go
示例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
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:47,代码来源:connector.go
示例16: Interface
func (c *Controller) Interface() (string, error) {
if c.SessRestricted != 0 {
return "", utils.ErrInfo(errors.New("Permission denied"))
}
var err error
name := ""
if len(c.Parameters["show_map"]) > 0 {
name = "show_map"
} else if len(c.Parameters["show_sign_data"]) > 0 {
name = "show_sign_data"
} else if len(c.Parameters["show_progress_bar"]) > 0 {
name = "show_progress_bar"
}
alert := ""
if len(name) > 0 {
err = c.ExecSql("UPDATE "+c.MyPrefix+"my_table SET "+name+" = ?", utils.StrToInt64(c.Parameters[name]))
if err != nil {
return "", utils.ErrInfo(err)
}
alert = c.Lang["done"]
}
data, err := c.OneRow("SELECT * FROM " + c.MyPrefix + "my_table").Int64()
if err != nil {
return "", utils.ErrInfo(err)
}
show_sign_data := data["show_sign_data"]
show_map := data["show_map"]
show_progress_bar := data["show_progress_bar"]
param_show_progress_bar := utils.StrToInt64(c.Parameters["show_progress_bar"])
TemplateStr, err := makeTemplate("interface", "interface", &InterfacePage{
Lang: c.Lang,
Show_sign_data: show_sign_data,
Show_map: show_map,
Show_progress_bar: show_progress_bar,
Param_show_progress_bar: param_show_progress_bar,
Alert: alert})
if err != nil {
return "", utils.ErrInfo(err)
}
return TemplateStr, nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:46,代码来源:interface.go
示例17: main
func main() {
f := tests_utils.InitLog()
defer f.Close()
txType := "NewMiner."
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("91573"))
//race
txSlice = append(txSlice, []byte("1"))
//country
txSlice = append(txSlice, []byte("1"))
//latitude
txSlice = append(txSlice, []byte("55"))
//longitude
txSlice = append(txSlice, []byte("55"))
//host
txSlice = append(txSlice, []byte("http://55.55.55.55/"))
//face_coords
txSlice = append(txSlice, []byte("[[118,275],[241,274],[39,274],[316,276],[180,364],[182,430],[181,490],[93,441],[259,433]]"))
//profile_coords
txSlice = append(txSlice, []byte("[[289,224],[148,216],[172,304],[123,239],[328,261],[305,349]]"))
//face_hash
txSlice = append(txSlice, []byte("face_hash"))
//profile_hash
txSlice = append(txSlice, []byte("profile_hash"))
//video_type
txSlice = append(txSlice, []byte("youtube"))
//video_url_id
txSlice = append(txSlice, []byte("video_url_id"))
//node_public_key
txSlice = append(txSlice, []byte("node_public_key"))
// 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)
}
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:57,代码来源:new_miner.go
示例18: EWithdraw
func (c *Controller) EWithdraw() (string, error) {
if c.SessUserId == 0 {
return "", errors.New(c.Lang["sign_up_please"])
}
c.r.ParseForm()
currencyId := utils.StrToInt64(c.r.FormValue("currency_id"))
if !utils.CheckInputData(c.r.FormValue("amount"), "amount") {
return "", fmt.Errorf("incorrect amount")
}
method := c.r.FormValue("method")
if !utils.CheckInputData(method, "method") {
return "", fmt.Errorf("incorrect method")
}
account := c.r.FormValue("account")
if !utils.CheckInputData(account, "account") {
return "", fmt.Errorf("incorrect account")
}
amount := utils.StrToFloat64(c.r.FormValue("amount"))
curTime := utils.Time()
// нужно проверить, есть ли нужная сумма на счету юзера
userAmount := utils.EUserAmountAndProfit(c.SessUserId, currencyId)
if userAmount < amount {
return "", fmt.Errorf("%s (%f<%f)", c.Lang["not_enough_money"], userAmount, amount)
}
if method != "Dcoin" && currencyId < 1000 {
return "", fmt.Errorf("incorrect method")
}
err := userLock(c.SessUserId)
if err != nil {
return "", utils.ErrInfo(err)
}
err = c.ExecSql(`UPDATE e_wallets SET amount = ?, last_update = ? WHERE user_id = ? AND currency_id = ?`, userAmount-amount, curTime, c.SessUserId, currencyId)
if err != nil {
return "", utils.ErrInfo(err)
}
var commission float64
if method == "Dcoin" {
commission = utils.StrToFloat64(c.EConfig["dc_commission"])
} else if method == "Perfect-money" {
commission = utils.StrToFloat64(c.EConfig["pm_commission"])
}
wdAmount := utils.ClearNull(utils.Float64ToStr(amount*(1-commission/100)), 2)
err = c.ExecSql(`INSERT INTO e_withdraw (open_time, user_id, currency_id, account, amount, wd_amount, method) VALUES (?, ?, ?, ?, ?, ?, ?)`, curTime, c.SessUserId, currencyId, account, amount, wdAmount, method)
if err != nil {
return "", utils.ErrInfo(err)
}
userUnlock(c.SessUserId)
return utils.JsonAnswer(c.Lang["request_is_created"], "success").String(), nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:56,代码来源:e_withdraw.go
示例19: main
func main() {
f := tests_utils.InitLog()
defer f.Close()
txType := "CfProjectData"
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("4"))
//project_id
txSlice = append(txSlice, []byte("1"))
//lang_id
txSlice = append(txSlice, []byte("45"))
//blurb_img
txSlice = append(txSlice, []byte("http://i.imgur.com/YRCoVnc.jpg"))
//head_img
txSlice = append(txSlice, []byte("http://i.imgur.com/YRCoVnc.jpg"))
//description_img
txSlice = append(txSlice, []byte("http://i.imgur.com/YRCoVnc.jpg"))
//picture
txSlice = append(txSlice, []byte("http://i.imgur.com/YRCoVnc.jpg"))
//video_type
txSlice = append(txSlice, []byte("youtube"))
//video_url_id
txSlice = append(txSlice, []byte("X-_fg47G5yf-_f"))
//news_img
txSlice = append(txSlice, []byte("http://i.imgur.com/YRCoVnc.jpg"))
//links
txSlice = append(txSlice, []byte(`[["http:\/\/goo.gl\/fnfh1Dg",1,532,234,0],["http:\/\/goo.gl\/28Fh4h",1355,1344,2222,66]]`))
//hide
txSlice = append(txSlice, []byte("1"))
// 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)
}
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:55,代码来源:cf_project_data.go
示例20: EGateIk
func (c *Controller) EGateIk() (string, error) {
c.r.ParseForm()
fmt.Println(c.r.Form)
var ikNames []string
for name, _ := range c.r.Form {
if name[:2] == "ik" && name != "ik_sign" {
ikNames = append(ikNames, name)
}
}
sort.Strings(ikNames)
fmt.Println(ikNames)
var ikValues []string
for _, names := range ikNames {
ikValues = append(ikValues, c.r.FormValue(names))
}
ikValues = append(ikValues, c.EConfig["ik_s_key"])
fmt.Println(ikValues)
sign := strings.Join(ikValues, ":")
fmt.Println(sign)
sign = base64.StdEncoding.EncodeToString(utils.HexToBin(utils.Md5(sign)))
fmt.Println(sign)
if sign != c.r.FormValue("ik_sign") {
return "", errors.New("Incorrect signature")
}
currencyId := int64(0)
if c.r.FormValue("ik_cur") == "USD" {
currencyId = 1001
}
if currencyId == 0 {
return "", errors.New("Incorrect currencyId")
}
amount := utils.StrToFloat64(c.r.FormValue("ik_am"))
pmId := utils.StrToInt64(c.r.FormValue("ik_inv_id"))
// проверим, не зачисляли ли мы уже это платеж
existsId, err := c.Single(`SELECT id FROM e_adding_funds_ik WHERE id = ?`, pmId).Int64()
if err != nil {
return "", utils.ErrInfo(err)
}
if existsId != 0 {
return "", errors.New("Incorrect ik_inv_id")
}
paymentInfo := c.r.FormValue("ik_desc")
txTime := utils.Time()
err = EPayment(paymentInfo, currencyId, txTime, amount, pmId, "ik", c.ECommission)
if err != nil {
return "", utils.ErrInfo(err)
}
return ``, nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:55,代码来源:e_gate_ik.go
注:本文中的github.com/c-darwin/dcoin-go/packages/utils.StrToInt64函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论