本文整理汇总了Golang中github.com/c-darwin/dcoin-go/packages/utils.StrToFloat64函数的典型用法代码示例。如果您正苦于以下问题:Golang StrToFloat64函数的具体用法?Golang StrToFloat64怎么用?Golang StrToFloat64使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了StrToFloat64函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: ChangeMoneyBackTime
func (c *Controller) ChangeMoneyBackTime() (string, error) {
txType := "ChangeMoneyBackTime"
txTypeId := utils.TypeInt(txType)
timeNow := utils.Time()
orderId := int64(utils.StrToFloat64(c.Parameters["order_id"]))
days := int64(utils.StrToFloat64(c.Parameters["days"]))
TemplateStr, err := makeTemplate("change_money_back_time", "changeMoneyBackTime", &changeMoneyBackTimePage{
Alert: c.Alert,
Lang: c.Lang,
ShowSignData: c.ShowSignData,
SignData: "",
UserId: c.SessUserId,
OrderId: orderId,
Days: days,
CountSignArr: c.CountSignArr,
TimeNow: timeNow,
TxType: txType,
TxTypeId: txTypeId})
if err != nil {
return "", utils.ErrInfo(err)
}
return TemplateStr, nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:26,代码来源:change_money_back_time.go
示例2: 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
示例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: SaveRaceCountry
func (c *Controller) SaveRaceCountry() (string, error) {
if c.SessRestricted != 0 {
return "", utils.ErrInfo(errors.New("Permission denied"))
}
c.r.ParseForm()
race := int(utils.StrToFloat64(c.r.FormValue("race")))
country := int(utils.StrToFloat64(c.r.FormValue("country")))
err := c.ExecSql("UPDATE "+c.MyPrefix+"my_table SET race = ?, country = ?", race, country)
if err != nil {
return "", utils.ErrInfo(err)
}
return `{"error":"0"}`, nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:15,代码来源:save_race_country.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: DelCfProject
func (c *Controller) DelCfProject() (string, error) {
var err error
txType := "DelCfProject"
txTypeId := utils.TypeInt(txType)
timeNow := utils.Time()
delId := int64(utils.StrToFloat64(c.Parameters["del_id"]))
projectCurrencyName, err := c.Single("SELECT project_currency_name FROM cf_projects WHERE id = ?", delId).String()
if err != nil {
return "", utils.ErrInfo(err)
}
TemplateStr, err := makeTemplate("del_cf_project", "delCfProject", &DelCfProjectPage{
Alert: c.Alert,
Lang: c.Lang,
CountSignArr: c.CountSignArr,
ShowSignData: c.ShowSignData,
SignData: fmt.Sprintf(`%d,%d,%d,%d`, txTypeId, timeNow, c.SessUserId, delId),
UserId: c.SessUserId,
TimeNow: timeNow,
TxType: txType,
TxTypeId: txTypeId,
DelId: delId,
ProjectCurrencyName: projectCurrencyName})
if err != nil {
return "", utils.ErrInfo(err)
}
return TemplateStr, nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:31,代码来源:del_cf_project.go
示例7: RepaymentCredit
func (c *Controller) RepaymentCredit() (string, error) {
txType := "RepaymentCredit"
txTypeId := utils.TypeInt(txType)
timeNow := time.Now().Unix()
creditId := utils.Round(utils.StrToFloat64(c.Parameters["credit_id"]), 0)
TemplateStr, err := makeTemplate("repayment_credit", "repaymentCredit", &repaymentCreditPage{
Alert: c.Alert,
Lang: c.Lang,
CountSignArr: c.CountSignArr,
ShowSignData: c.ShowSignData,
UserId: c.SessUserId,
TimeNow: timeNow,
TxType: txType,
TxTypeId: txTypeId,
SignData: "",
CreditId: creditId,
CurrencyList: c.CurrencyList})
if err != nil {
return "", utils.ErrInfo(err)
}
return TemplateStr, nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:25,代码来源:repayment_credit.go
示例8: ChangeCreditor
func (c *Controller) ChangeCreditor() (string, error) {
txType := "ChangeCreditor"
txTypeId := utils.TypeInt(txType)
timeNow := time.Now().Unix()
creditId := utils.Round(utils.StrToFloat64(c.Parameters["credit_id"]), 0)
log.Debug("creditId", creditId)
TemplateStr, err := makeTemplate("change_creditor", "changeCreditor", &changeCreditorPage{
Alert: c.Alert,
Lang: c.Lang,
CountSignArr: c.CountSignArr,
ShowSignData: c.ShowSignData,
UserId: c.SessUserId,
TimeNow: timeNow,
TxType: txType,
TxTypeId: txTypeId,
SignData: "",
CreditId: creditId})
if err != nil {
return "", utils.ErrInfo(err)
}
return TemplateStr, nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:25,代码来源:change_creditor.go
示例9: MoneyBackRequest
func (c *Controller) MoneyBackRequest() (string, error) {
txType := "MoneyBackRequest"
txTypeId := utils.TypeInt(txType)
timeNow := utils.Time()
orderId := int64(utils.StrToFloat64(c.Parameters["order_id"]))
order, err := c.OneRow("SELECT * FROM orders WHERE id = ?", orderId).String()
if err != nil {
return "", utils.ErrInfo(err)
}
TemplateStr, err := makeTemplate("money_back_request", "moneyBackRequest", &moneyBackRequestPage{
Alert: c.Alert,
Lang: c.Lang,
ShowSignData: c.ShowSignData,
SignData: "",
UserId: c.SessUserId,
OrderId: orderId,
Order: order,
CountSignArr: c.CountSignArr,
TimeNow: timeNow,
TxType: txType,
TxTypeId: txTypeId})
if err != nil {
return "", utils.ErrInfo(err)
}
return TemplateStr, nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:29,代码来源:money_back_request.go
示例10: DelCfFunding
func (c *Controller) DelCfFunding() (string, error) {
var err error
txType := "DelCfFunding"
txTypeId := utils.TypeInt(txType)
timeNow := utils.Time()
delId := int64(utils.StrToFloat64(c.Parameters["del_id"]))
TemplateStr, err := makeTemplate("del_cf_funding", "delCfFunding", &DelCfFundingPage{
Alert: c.Alert,
Lang: c.Lang,
CountSignArr: c.CountSignArr,
ShowSignData: c.ShowSignData,
SignData: fmt.Sprintf(`%d,%d,%d,%d`, txTypeId, timeNow, c.SessUserId, delId),
UserId: c.SessUserId,
TimeNow: timeNow,
TxType: txType,
TxTypeId: txTypeId,
DelId: delId})
if err != nil {
return "", utils.ErrInfo(err)
}
return TemplateStr, nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:26,代码来源:del_cf_funding.go
示例11: MiningPromisedAmount
func (c *Controller) MiningPromisedAmount() (string, error) {
txType := "Mining"
txTypeId := utils.TypeInt(txType)
timeNow := time.Now().Unix()
amount := utils.StrToMoney(c.Parameters["amount"])
amount = math.Floor(amount*100) / 100
promisedAmountId := int64(utils.StrToFloat64(c.Parameters["promised_amount_id"]))
log.Debug("c.Parameters[promised_amount_id]):", c.Parameters["promised_amount_id"])
log.Debug("promisedAmountId:", promisedAmountId)
TemplateStr, err := makeTemplate("mining_promised_amount", "miningPromisedAmount", &miningPromisedAmountPage{
Alert: c.Alert,
Lang: c.Lang,
CountSignArr: c.CountSignArr,
ShowSignData: c.ShowSignData,
UserId: c.SessUserId,
TimeNow: timeNow,
TxType: txType,
TxTypeId: txTypeId,
SignData: fmt.Sprintf("%v,%v,%v,%v,%v", txTypeId, timeNow, c.SessUserId, promisedAmountId, amount),
Amount: amount,
PromisedAmountId: promisedAmountId})
if err != nil {
return "", utils.ErrInfo(err)
}
return TemplateStr, nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:27,代码来源:mining_promised_amount.go
示例12: ChangePromisedAmount
func (c *Controller) ChangePromisedAmount() (string, error) {
txType := "ChangePromisedAmount"
txTypeId := utils.TypeInt(txType)
timeNow := time.Now().Unix()
promisedAmountId := int64(utils.StrToFloat64(c.Parameters["promised_amount_id"]))
amount := c.Parameters["amount"]
TemplateStr, err := makeTemplate("change_promised_amount", "changePromisedAmount", &changePromisedAmountPage{
Alert: c.Alert,
Lang: c.Lang,
CountSignArr: c.CountSignArr,
ShowSignData: c.ShowSignData,
UserId: c.SessUserId,
TimeNow: timeNow,
TxType: txType,
TxTypeId: txTypeId,
SignData: fmt.Sprintf("%v,%v,%v,%v,%v", txTypeId, timeNow, c.SessUserId, promisedAmountId, amount),
PromisedAmountId: promisedAmountId,
Amount: amount})
if err != nil {
return "", utils.ErrInfo(err)
}
return TemplateStr, nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:25,代码来源:change_promised_amount.go
示例13: NewPhoto
func (c *Controller) NewPhoto() (string, error) {
c.r.ParseForm()
userId := int64(utils.StrToFloat64(c.r.FormValue("user_id")))
data, err := c.OneRow("SELECT photo_block_id, photo_max_miner_id, miners_keepers FROM miners_data WHERE user_id = ?", userId).String()
if err != nil {
return "", utils.ErrInfo(err)
}
// получим ID майнеров, у которых лежат фото нужного нам юзера
minersIds := utils.GetMinersKeepers(data["photo_block_id"], data["photo_max_miner_id"], data["miners_keepers"], true)
// берем 1 случайный из 10-и ID майнеров
k := utils.RandInt(0, len(minersIds))
minerId := minersIds[k]
host, err := c.Single("SELECT http_host FROM miners_data WHERE miner_id = ?", minerId).String()
if err != nil {
return "", utils.ErrInfo(err)
}
result, err := json.Marshal(map[string]string{"face": host + "public/face_" + utils.Int64ToStr(userId) + ".jpg", "profile": host + "public/profile_" + utils.Int64ToStr(userId) + ".jpg"})
if err != nil {
return "", utils.ErrInfo(err)
}
return string(result), nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:28,代码来源:new_photo.go
示例14: AddCfProjectData
func (c *Controller) AddCfProjectData() (string, error) {
var err error
txType := "CfProjectData"
txTypeId := utils.TypeInt(txType)
timeNow := utils.Time()
projectId := int64(utils.StrToFloat64(c.Parameters["projectId"]))
id := int64(utils.StrToFloat64(c.Parameters["id"]))
cfData := make(map[string]string)
if id > 0 {
log.Debug("id:", id)
cfData, err = c.OneRow("SELECT * FROM cf_projects_data WHERE id = ?", id).String()
if err != nil {
return "", utils.ErrInfo(err)
}
projectId = utils.StrToInt64(cfData["project_id"])
}
cfCurrencyName, err := c.Single("SELECT project_currency_name FROM cf_projects WHERE id = ?", projectId).String()
if err != nil {
return "", utils.ErrInfo(err)
}
CfLng, err := c.GetAllCfLng()
log.Debug("CfData", cfData)
TemplateStr, err := makeTemplate("add_cf_project_data", "addCfProjectData", &AddCfProjectDataPage{
Alert: c.Alert,
Lang: c.Lang,
CountSignArr: c.CountSignArr,
ShowSignData: c.ShowSignData,
UserId: c.SessUserId,
TimeNow: timeNow,
TxType: txType,
TxTypeId: txTypeId,
ProjectId: projectId,
Id: id,
CfData: cfData,
CfCurrencyName: cfCurrencyName,
CfLng: CfLng})
if err != nil {
return "", utils.ErrInfo(err)
}
return TemplateStr, nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:46,代码来源:add_cf_project_data.go
示例15: 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
示例16: 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
示例17: SaveGeolocation
func (c *Controller) SaveGeolocation() (string, error) {
if c.SessRestricted != 0 {
return "", utils.ErrInfo(errors.New("Permission denied"))
}
c.r.ParseForm()
geolocation := c.r.FormValue("geolocation")
if len(geolocation) > 0 {
x := strings.Split(geolocation, ", ")
if len(x) == 2 {
geolocationLat := utils.Round(utils.StrToFloat64(x[0]), 5)
geolocationLon := utils.Round(utils.StrToFloat64(x[1]), 5)
err := c.ExecSql("UPDATE "+c.MyPrefix+"my_table SET geolocation = ?", utils.Float64ToStrGeo(geolocationLat)+", "+utils.Float64ToStrGeo(geolocationLon))
if err != nil {
return "", utils.ErrInfo(err)
}
}
}
return `{"error":"0"}`, nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:21,代码来源:save_geolocation.go
示例18: MoneyBack
func (c *Controller) MoneyBack() (string, error) {
txType := "MoneyBack"
txTypeId := utils.TypeInt(txType)
timeNow := utils.Time()
orderId := int64(utils.StrToFloat64(c.Parameters["order_id"]))
amount := utils.StrToFloat64(c.Parameters["amount"])
arbitrator := int64(utils.StrToFloat64(c.Parameters["arbitrator"]))
var li, redirect string
if arbitrator > 0 {
li = `<li><a href="#arbitrationArbitrator">` + c.Lang["i_arbitrator"] + `</a></li>`
redirect = `arbitrationArbitrator`
} else {
li = `<li><a href="#arbitrationArbitrator">` + c.Lang["i_seller"] + `</a></li>`
redirect = `arbitrationSeller`
}
TemplateStr, err := makeTemplate("money_back", "moneyBack", &moneyBackPage{
Alert: c.Alert,
Lang: c.Lang,
ShowSignData: c.ShowSignData,
SignData: "",
UserId: c.SessUserId,
OrderId: orderId,
Amount: amount,
Arbitrator: arbitrator,
Li: li,
Redirect: redirect,
CountSignArr: c.CountSignArr,
TimeNow: timeNow,
TxType: txType,
TxTypeId: txTypeId})
if err != nil {
return "", utils.ErrInfo(err)
}
return TemplateStr, nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:38,代码来源:money_back.go
示例19: EGatePayeer
func (c *Controller) EGatePayeer() (string, error) {
c.r.ParseForm()
fmt.Println(c.r.Form)
if utils.IPwoPort(c.r.RemoteAddr) != "37.59.221.23" {
return "", errors.New("Incorrect RemoteAddr " + utils.IPwoPort(c.r.RemoteAddr))
}
if len(c.r.FormValue("m_operation_id")) > 0 && len(c.r.FormValue("m_sign")) > 0 {
sign := strings.ToUpper(string(utils.Sha256(c.r.FormValue("m_operation_id") + ":" + c.r.FormValue("m_operation_ps") + ":" + c.r.FormValue("m_operation_date") + ":" + c.r.FormValue("m_operation_pay_date") + ":" + c.r.FormValue("m_shop") + ":" + c.r.FormValue("m_orderid") + ":" + c.r.FormValue("m_amount") + ":" + c.r.FormValue("m_curr") + ":" + base64.StdEncoding.EncodeToString([]byte(c.r.FormValue("m_desc"))) + ":" + c.r.FormValue("m_status") + ":" + c.EConfig["payeer_s_key"])))
if c.r.FormValue("m_sign") == sign && c.r.FormValue("m_status") == "success" {
txTime := utils.Time()
currencyId := int64(0)
if c.r.FormValue("m_curr") == "USD" {
currencyId = 1001
}
if currencyId == 0 {
return c.r.FormValue("m_orderid") + "|success", nil
}
amount := utils.StrToFloat64(c.r.FormValue("m_amount"))
pmId := utils.StrToInt64(c.r.FormValue("m_operation_id"))
// проверим, не зачисляли ли мы уже это платеж
existsId, err := c.Single(`SELECT id FROM e_adding_funds_payeer WHERE id = ?`, pmId).Int64()
if err != nil {
return c.r.FormValue("m_orderid") + "|success", nil
}
if existsId != 0 {
return c.r.FormValue("m_orderid") + "|success", nil
}
paymentInfo := c.r.FormValue("m_desc")
EPayment(paymentInfo, currencyId, txTime, amount, pmId, "payeer", c.ECommission)
return c.r.FormValue("m_orderid") + "|success", nil
}
}
return c.r.FormValue("m_orderid") + "|error", nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:44,代码来源:e_gate_payeer.go
示例20: Profile
func (c *Controller) Profile() (string, error) {
c.r.ParseForm()
userId := int64(utils.StrToFloat64(c.r.FormValue("user_id")))
// получаем кол-во TDC на обещанных суммах
rows, err := c.Query(c.FormatQuery(`
SELECT from_user_id, time, comment
FROM abuses
WHERE user_id = ?
`), userId)
if err != nil {
return "", utils.ErrInfo(err)
}
abuses := ""
defer rows.Close()
for rows.Next() {
var from_user_id, abusestime int64
var comment string
err = rows.Scan(&from_user_id, &abusestime, &comment)
if err != nil {
return "", utils.ErrInfo(err)
}
t := time.Unix(abusestime, 0)
abuses += fmt.Sprintf("from_user_id: %d; time: %s; comment: %s<br>", from_user_id, t.Format(c.TimeFormat), comment)
}
if len(abuses) == 0 {
abuses = "No"
}
regTime, err := c.Single("SELECT reg_time FROM miners_data WHERE user_id = ?", userId).Int64()
if err != nil {
return "", utils.ErrInfo(err)
}
t := time.Unix(regTime, 0)
result, err := json.Marshal(map[string]string{"abuses": abuses, "reg_time": t.Format(c.TimeFormat)})
if err != nil {
return "", utils.ErrInfo(err)
}
return string(result), nil
}
开发者ID:dzyk,项目名称:dcoin-go,代码行数:42,代码来源:profile.go
注:本文中的github.com/c-darwin/dcoin-go/packages/utils.StrToFloat64函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论