Commit 43238bda authored by brent's avatar brent

add credit quota

parent 19e87199
...@@ -68,7 +68,13 @@ func (server *FundsController) Recharge() { ...@@ -68,7 +68,13 @@ func (server *FundsController) Recharge() {
//mysql.GetMysqlInstace().Ormer.Insert(&charge) //mysql.GetMysqlInstace().Ormer.Insert(&charge)
balance := int64((float64(checkUser.Balance/1000000) + chargeRequest.Amount) * 1000000) balance, err := odysseus.GetUserBalance(int64(checkUser.Id))
if err != nil {
server.respond(models.BusinessFailed, "failed")
return
}
balance = int64((float64(balance/1000000) + chargeRequest.Amount) * 1000000)
//sql := "SELECT Max(id) AS count FROM funds;" //sql := "SELECT Max(id) AS count FROM funds;"
max, _ := snowflake.NextId() max, _ := snowflake.NextId()
...@@ -96,6 +102,8 @@ func (server *FundsController) Recharge() { ...@@ -96,6 +102,8 @@ func (server *FundsController) Recharge() {
// OrderId: "", // OrderId: "",
//} //}
//flag, err := postgres.InsertFunds(&fundsData) //flag, err := postgres.InsertFunds(&fundsData)
//todo 如果是三方支付,待支付成功,再更新余额
sql := fmt.Sprintf("INSERT INTO funds ("+ sql := fmt.Sprintf("INSERT INTO funds ("+
"channel_serial,"+ "channel_serial,"+
"order_id,"+ "order_id,"+
......
...@@ -2151,7 +2151,7 @@ func (server *TaskController) Examples() { ...@@ -2151,7 +2151,7 @@ func (server *TaskController) Examples() {
return return
} }
sql = fmt.Sprintf("SELECT id, `name` AS tit,type,`desc` AS content, tags ,price,examples,codes,base_model,model,api_path,version,category,form,access_status,publish_status FROM task_type WHERE deleted = 0 %s order by codes desc LIMIT %d,%d;", where, offset, size) sql = fmt.Sprintf("SELECT id, `name` AS tit,type,`desc` AS content, tags ,price,unit,examples,codes,base_model,model,api_path,version,category,form,access_status,publish_status FROM task_type WHERE deleted = 0 %s order by codes desc LIMIT %d,%d;", where, offset, size)
mysql.GetMysqlInstace().Ormer.Raw(sql).QueryRows(&types) mysql.GetMysqlInstace().Ormer.Raw(sql).QueryRows(&types)
var remodels []*models.ResonseModel var remodels []*models.ResonseModel
for _, data := range types { for _, data := range types {
...@@ -2198,6 +2198,7 @@ func (server *TaskController) Examples() { ...@@ -2198,6 +2198,7 @@ func (server *TaskController) Examples() {
AccessStatus: data.AccessStatus, AccessStatus: data.AccessStatus,
PublishStatus: data.PublishStatus, PublishStatus: data.PublishStatus,
Price: float64(data.Price / 1000000), Price: float64(data.Price / 1000000),
Uint: data.Uint,
} }
remodels = append(remodels, &remodel) remodels = append(remodels, &remodel)
} }
...@@ -2212,14 +2213,14 @@ func (server *TaskController) Examples() { ...@@ -2212,14 +2213,14 @@ func (server *TaskController) Examples() {
} }
func (server *TaskController) RunCount() { func (server *TaskController) RunCount() {
//_, err := server.Check() _, err := server.Check()
//if err != nil { if err != nil {
// server.respond(http.StatusUnauthorized, err.Error()) server.respond(http.StatusUnauthorized, err.Error())
// return return
//} }
body := server.Ctx.Input.RequestBody body := server.Ctx.Input.RequestBody
appRequest := models.AppRequest{} appRequest := models.AppRequest{}
err := json.Unmarshal(body, &appRequest) //解析body中数据 err = json.Unmarshal(body, &appRequest) //解析body中数据
logs.Debug("appRequest", appRequest) logs.Debug("appRequest", appRequest)
if err != nil { if err != nil {
server.respond(models.NoRequestBody, err.Error()) server.respond(models.NoRequestBody, err.Error())
......
...@@ -88,6 +88,7 @@ type TaskType struct { ...@@ -88,6 +88,7 @@ type TaskType struct {
ResultFileExpires int `json:"result_file_expires";orm:"column(result_file_expires)"` ResultFileExpires int `json:"result_file_expires";orm:"column(result_file_expires)"`
AccessStatus int `json:"access_status,omitempty"` AccessStatus int `json:"access_status,omitempty"`
PublishStatus int `json:"publish_status,omitempty"` PublishStatus int `json:"publish_status,omitempty"`
Uint string `json:"unit";orm:"column(unit)"`
CreatedTime time.Time `json:"created_time";orm:"column(created_time);type(datetime)"` CreatedTime time.Time `json:"created_time";orm:"column(created_time);type(datetime)"`
UpdatedTime time.Time `json:"updated_time";orm:"column(updated_time);type(datetime)"` UpdatedTime time.Time `json:"updated_time";orm:"column(updated_time);type(datetime)"`
Deleted int `json:"deleted";orm:"column(deleted);size(1)"` Deleted int `json:"deleted";orm:"column(deleted);size(1)"`
...@@ -128,6 +129,7 @@ type NewTaskType struct { ...@@ -128,6 +129,7 @@ type NewTaskType struct {
ResultFileExpires int `json:"result_file_expires";orm:"column(result_file_expires)"` ResultFileExpires int `json:"result_file_expires";orm:"column(result_file_expires)"`
AccessStatus int `json:"access_status,omitempty"` AccessStatus int `json:"access_status,omitempty"`
PublishStatus int `json:"publish_status,omitempty"` PublishStatus int `json:"publish_status,omitempty"`
Uint string `json:"unit";orm:"column(unit)"`
CreatedTime time.Time `json:"created_time";orm:"column(created_time);type(datetime)"` CreatedTime time.Time `json:"created_time";orm:"column(created_time);type(datetime)"`
UpdatedTime time.Time `json:"updated_time";orm:"column(updated_time);type(datetime)"` UpdatedTime time.Time `json:"updated_time";orm:"column(updated_time);type(datetime)"`
Deleted int `json:"deleted";orm:"column(deleted);size(1)"` Deleted int `json:"deleted";orm:"column(deleted);size(1)"`
...@@ -153,6 +155,7 @@ type Model struct { ...@@ -153,6 +155,7 @@ type Model struct {
AccessStatus int `json:"access_status,omitempty"` AccessStatus int `json:"access_status,omitempty"`
PublishStatus int `json:"publish_status,omitempty"` PublishStatus int `json:"publish_status,omitempty"`
Price int64 `json:"price";orm:"column(price)"` Price int64 `json:"price";orm:"column(price)"`
Uint string `json:"unit";orm:"column(unit)"`
} }
type ResonseModel struct { type ResonseModel struct {
...@@ -175,6 +178,7 @@ type ResonseModel struct { ...@@ -175,6 +178,7 @@ type ResonseModel struct {
AccessStatus int `json:"access_status,omitempty"` AccessStatus int `json:"access_status,omitempty"`
PublishStatus int `json:"publish_status,omitempty"` PublishStatus int `json:"publish_status,omitempty"`
Price float64 `json:"price";orm:"column(price)"` Price float64 `json:"price";orm:"column(price)"`
Uint string `json:"unit";orm:"column(unit)"`
} }
type Bills struct { type Bills struct {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment