Commit 92abd034 authored by brent's avatar brent

modify task type

parent 275fe091
No preview for this file type
...@@ -343,7 +343,7 @@ func (server *FundsController) IncomeAndExpense() { ...@@ -343,7 +343,7 @@ func (server *FundsController) IncomeAndExpense() {
return return
} }
queryQB.OrderBy("time").Desc() queryQB.OrderBy("trade_time").Desc()
sql = fmt.Sprintf("%s LIMIT %d,%d;", queryQB.String(), offset, size) sql = fmt.Sprintf("%s LIMIT %d,%d;", queryQB.String(), offset, size)
//sql = fmt.Sprintf("SELECT * FROM funds WHERE uid = %d %s LIMIT %d,%d;", info.UserID, timeCondition, offset, size) //sql = fmt.Sprintf("SELECT * FROM funds WHERE uid = %d %s LIMIT %d,%d;", info.UserID, timeCondition, offset, size)
//if info.Role == 1 || info.Role == 2 { //if info.Role == 1 || info.Role == 2 {
...@@ -380,20 +380,24 @@ func (server *FundsController) IncomeAndExpense() { ...@@ -380,20 +380,24 @@ func (server *FundsController) IncomeAndExpense() {
id, _ := strconv.Atoi(fund.Uid) id, _ := strconv.Atoi(fund.Uid)
username := FindName(users, id) username := FindName(users, id)
responseType := models.ResponseFunds{ responseType := models.ResponseFunds{
Id: fund.Id, // int64 Id: fund.Id, // int64
Uid: fund.Uid, // int Uid: fund.Uid, // int
Amount: float64(amount), // int64 Amount: float64(amount), // int64
TradeChannel: models.PayMethodType(tradeChannel).String(), // int TradeChannel: models.PayMethodType(tradeChannel).String(), // int
ChannelSerial: fund.ChannelSerial, // string TradeChannelEn: models.PayMethodType(tradeChannel).EnString(),
StatusDesc: models.PayStatus(status).String(), // int ChannelSerial: fund.ChannelSerial, // string
Status: status, StatusDesc: models.PayStatus(status).String(),
TradeTime: fund.TradeTime, // string StatusDescEn: models.PayStatus(status).EnString(), // int
TradeFlow: models.TradeFlowType(tradeFlow).String(), // int Status: status,
TradeType: models.TradeKind(tradeType).String(), // int TradeTime: fund.TradeTime, // string
Balance: float64(balance), // int64 TradeFlow: models.TradeFlowType(tradeFlow).String(), // int
Remark: fund.Remark, // string TradeFlowEn: models.TradeFlowType(tradeFlow).EnString(),
OrderId: fund.OrderId, TradeType: models.TradeKind(tradeType).String(), // int
UserName: username, TradeTypeEn: models.TradeKind(tradeType).EnString(),
Balance: float64(balance), // int64
Remark: fund.Remark, // string
OrderId: fund.OrderId,
UserName: username,
} }
responseTypes = append(responseTypes, responseType) responseTypes = append(responseTypes, responseType)
} }
...@@ -446,8 +450,21 @@ func (server *FundsController) Enumeration() { ...@@ -446,8 +450,21 @@ func (server *FundsController) Enumeration() {
flows = append(flows, &typeData) flows = append(flows, &typeData)
} }
var statuss []*models.EnumType
for _, value := range [...]models.PayStatus{models.PendingPay, models.InitiatePay, models.SuccessPay, models.FinishCharge, models.Billed, models.InitiateWithdrawal,
models.PendingAudit, models.ApprovedAudit, models.RejectedAudit, models.PendingTransfer, models.SuccessTransfer, models.SuccessWithdrawal,
models.FailurePay, models.FailureTransfer} {
typeData := models.EnumType{
Id: int(value),
Desc: value.String(),
EnDesc: value.EnString(),
}
statuss = append(statuss, &typeData)
}
var channels []*models.EnumType var channels []*models.EnumType
for _, value := range [...]models.PayMethodType{models.WeixinPay, models.AliPay, models.UnionPay, models.PayPal, models.ApplePay, models.ManualPay} { for _, value := range [...]models.PayMethodType{models.WeixinPay, models.AliPay, models.UnionPay,
models.PayPal, models.ApplePay, models.ManualPay} {
typeData := models.EnumType{ typeData := models.EnumType{
Id: int(value), Id: int(value),
Desc: value.String(), Desc: value.String(),
......
...@@ -1000,6 +1000,95 @@ func (server *TaskController) UserFeePerDay() { ...@@ -1000,6 +1000,95 @@ func (server *TaskController) UserFeePerDay() {
server.respond(http.StatusOK, "", counts) server.respond(http.StatusOK, "", counts)
} }
func (server *TaskController) UserFee() {
info, err := server.Check()
if err != nil {
server.respond(http.StatusUnauthorized, err.Error())
return
}
body := server.Ctx.Input.RequestBody
appRequest := models.AppRequest{}
err = json.Unmarshal(body, &appRequest) //解析body中数据
logs.Debug("appRequest", appRequest)
//if err != nil {
// server.respond(models.NoRequestBody, err.Error())
// return
//}
//if appRequest.StartTime == "" && appRequest.EndTime != "" {
// server.respond(models.MissingParameter, "缺少开始时间")
// return
//}
//if appRequest.StartTime != "" && appRequest.EndTime == "" {
// server.respond(models.MissingParameter, "缺少结束时间")
// return
//}
//tempLayout := layout
//if appRequest.EndTime == "" && appRequest.StartTime == "" {
// tempLayout = format
//}
//currentTime := time.Now()
//if appRequest.EndTime == "" {
// endTime := time.Date(currentTime.Year(), currentTime.Month(), currentTime.Day(), 23, 59, 59, 0, currentTime.Location())
// appRequest.EndTime = fmt.Sprintf(endTime.Format(format))
//}
//if appRequest.StartTime == "" {
// temp := fmt.Sprintf("-%dh", 24*7)
// m, _ := time.ParseDuration(temp)
// tempTime := currentTime.Add(m)
// tempTime = time.Date(tempTime.Year(), tempTime.Month(), tempTime.Day(), 0, 0, 0, 0, tempTime.Location())
// appRequest.StartTime = fmt.Sprintf(tempTime.Format(format))
//}
//startTimeIn, _ := time.Parse(tempLayout, appRequest.StartTime)
//endTimeIn, _ := time.Parse(tempLayout, appRequest.EndTime)
//
//if endTimeIn.Before(startTimeIn) {
// server.respond(models.BusinessFailed, "起始时间不能大于结束时间")
// return
//}
//
//startTime := fmt.Sprintf(startTimeIn.Format(format))
//endTime := fmt.Sprintf(endTimeIn.Format(format))
countQB, _ := orm.NewQueryBuilder("mysql")
countQB.Select("sum(fee) AS fee").
From("bills")
if info.Role != 1 && info.Role != 2 {
countQB.Where(fmt.Sprintf("uid = %d", info.UserID))
}
//sql := fmt.Sprintf("%s SAMPLE BY 1d ALIGN TO CALENDAR;", countQB.String())
sql := countQB.String()
//endDateIn := time.Date(endTimeIn.Year(), endTimeIn.Month(), endTimeIn.Day(), 0, 0, 0, 0, endTimeIn.Location())
//endDate := fmt.Sprintf(endDateIn.Format(format))
//dates := utils.SplitDate(startTime, endDate, format)
//sql := fmt.Sprintf("SELECT time,sum(fee) AS fee FROM bills WHERE uid='%d' and time >= '%s' and time <= '%s' SAMPLE BY 1d ALIGN TO CALENDAR;", info.UserID, startTime, endTime)
//if info.Role == 1 || info.Role == 2 {
// sql = fmt.Sprintf("SELECT time,sum(fee) AS fee FROM bills WHERE time >= '%s' and time <= '%s' SAMPLE BY 1d ALIGN TO CALENDAR;", startTime, endTime)
//}
counts, err := postgres.CountTasks(sql)
if err != nil {
server.respond(models.BusinessFailed, err.Error())
return
}
//for _, value := range dates {
// tempDate := findTime(counts, value)
// if tempDate != nil {
// reTask := models.TaskCount{
// Type: "0",
// Time: *tempDate,
// Count: "0",
// ApiPath: "",
// }
// counts = append(counts, reTask)
// }
//}
//sort.Slice(counts, func(i, j int) bool {
// return counts[i].Time.Before(counts[j].Time)
//})
server.respond(http.StatusOK, "", counts)
}
func (server *TaskController) UserTaskTypeFeePerDay() { func (server *TaskController) UserTaskTypeFeePerDay() {
info, err := server.Check() info, err := server.Check()
if err != nil { if err != nil {
...@@ -1270,10 +1359,7 @@ func (server *TaskController) AddTasktype() { ...@@ -1270,10 +1359,7 @@ func (server *TaskController) AddTasktype() {
server.respond(models.MissingParameter, "模型类型 不能为空") server.respond(models.MissingParameter, "模型类型 不能为空")
return return
} }
if appRequest.TaskTypeIn.ResultFileExpires == 0 {
server.respond(models.MissingParameter, "结果存储时长必须 大于0")
return
}
//if &appRequest.Type.Version == nil { //if &appRequest.Type.Version == nil {
// server.respond(models.MissingParameter, "版本 不能为空") // server.respond(models.MissingParameter, "版本 不能为空")
// return // return
...@@ -1297,6 +1383,9 @@ func (server *TaskController) AddTasktype() { ...@@ -1297,6 +1383,9 @@ func (server *TaskController) AddTasktype() {
} }
//ormer := orm.NewOrm() //ormer := orm.NewOrm()
if appRequest.TaskTypeIn.ResultFileExpires == 0 {
appRequest.TaskTypeIn.ResultFileExpires = 1800
}
ormer := mysql.GetMysqlInstace().Ormer ormer := mysql.GetMysqlInstace().Ormer
//err = ormer.Begin() //err = ormer.Begin()
...@@ -1437,10 +1526,6 @@ func (server *TaskController) UpdateTaskType() { ...@@ -1437,10 +1526,6 @@ func (server *TaskController) UpdateTaskType() {
server.respond(models.MissingParameter, "模型类型 不能为空") server.respond(models.MissingParameter, "模型类型 不能为空")
return return
} }
if appRequest.TaskTypeIn.ResultFileExpires == 0 {
server.respond(models.MissingParameter, "结果存储时长必须 大于0")
return
}
if &appRequest.TaskTypeIn.BaseModel == nil { if &appRequest.TaskTypeIn.BaseModel == nil {
server.respond(models.MissingParameter, "模型名称 不能为空") server.respond(models.MissingParameter, "模型名称 不能为空")
return return
...@@ -1459,6 +1544,9 @@ func (server *TaskController) UpdateTaskType() { ...@@ -1459,6 +1544,9 @@ func (server *TaskController) UpdateTaskType() {
return return
} }
} }
if appRequest.TaskTypeIn.ResultFileExpires == 0 {
appRequest.TaskTypeIn.ResultFileExpires = 1800
}
//ormer := orm.NewOrm() //ormer := orm.NewOrm()
...@@ -1694,33 +1782,36 @@ func (server *TaskController) GetTaskTypes() { ...@@ -1694,33 +1782,36 @@ func (server *TaskController) GetTaskTypes() {
} }
remodel := models.NewTaskType{ remodel := models.NewTaskType{
Id: data.Id, Id: data.Id,
Name: data.Name, Name: data.Name,
BaseModel: data.BaseModel, BaseModel: data.BaseModel,
Model: data.Model, Model: data.Model,
Version: data.Version, Version: data.Version,
Desc: data.Desc, Desc: data.Desc,
Price: float64(data.Price / 1000000), Price: float64(data.Price / 1000000),
PublicKey: data.PublicKey, PublicKey: data.PublicKey,
Complexity: data.Complexity, Complexity: data.Complexity,
Type: models.ModelType(data.Type), Type: models.ModelType(data.Type),
TypeDesc: models.ModelType(data.Type).String(), TypeDesc: models.ModelType(data.Type).String(),
Kind: data.Kind, Kind: data.Kind,
KindDesc: models.TaskKind(data.Kind).String(), KindDesc: models.TaskKind(data.Kind).String(),
Category: data.Category, Category: data.Category,
HardwareRequire: hardwareRequire, HardwareRequire: hardwareRequire,
ImageId: data.ImageId, ImageId: data.ImageId,
ImageUrl: data.ImageUrl, ImageUrl: data.ImageUrl,
Cmd: cmd, Cmd: cmd,
Workload: data.Workload, Workload: data.Workload,
ApiPath: data.ApiPath, ApiPath: data.ApiPath,
ImageName: data.ImageName, ImageName: data.ImageName,
SignUrl: data.SignUrl, SignUrl: data.SignUrl,
Username: data.Username, Username: data.Username,
Password: data.Password, Password: data.Password,
Examples: examples, Examples: examples,
Codes: codes, Codes: codes,
Tags: tags, Tags: tags,
PublishStatus: data.PublishStatus,
AccessStatus: data.AccessStatus,
ResultFileExpires: data.ResultFileExpires,
} }
remodels = append(remodels, &remodel) remodels = append(remodels, &remodel)
} }
......
...@@ -237,20 +237,24 @@ type Funds struct { ...@@ -237,20 +237,24 @@ type Funds struct {
} }
type ResponseFunds struct { type ResponseFunds struct {
Id string `json:"id";orm:"column(id)"` // int64 Id string `json:"id";orm:"column(id)"` // int64
Uid string `json:"uid";orm:"column(uid)"` // int Uid string `json:"uid";orm:"column(uid)"` // int
Amount float64 `json:"amount";orm:"column(amount)"` // int64 Amount float64 `json:"amount";orm:"column(amount)"` // int64
TradeChannel string `json:"trade_channel";orm:"column(trade_channel)"` // int TradeChannel string `json:"trade_channel";orm:"column(trade_channel)"`
ChannelSerial string `json:"channel_serial";orm:"column(channel_serial)"` // string TradeChannelEn string `json:"trade_channel_en";orm:"column(trade_channel)"` // int
Status int `json:"status";orm:"column(status);size(1)"` // int ChannelSerial string `json:"channel_serial";orm:"column(channel_serial)"` // string
StatusDesc string `json:"status_desc";orm:"column(status_desc);size(1)"` // int Status int `json:"status";orm:"column(status);size(1)"` // int
TradeTime string `json:"trade_time";orm:"column(trade_time);type(datetime)"` // string StatusDesc string `json:"status_desc,omitempty"`
TradeFlow string `json:"trade_flow";orm:"column(trade_flow)"` // int StatusDescEn string `json:"status_desc_en,omitempty"`
TradeType string `json:"trade_type";orm:"column(trade_type)"` // int TradeTime string `json:"trade_time";orm:"column(trade_time);type(datetime)"` // string
Balance float64 `json:"balance";orm:"column(balance)"` // int64 TradeFlow string `json:"trade_flow";orm:"column(trade_flow)"` // int
Remark string `json:"remark";orm:"column(remark)"` // string TradeType string `json:"trade_type";orm:"column(trade_type)"` // int
OrderId string `json:"order_id";orm:"column(order_id)"` // string TradeFlowEn string `json:"trade_flow_en";orm:"column(trade_flow)"` // int
UserName string `json:"username,omitempty"` TradeTypeEn string `json:"trade_type_en";orm:"column(trade_type)"`
Balance float64 `json:"balance";orm:"column(balance)"` // int64
Remark string `json:"remark";orm:"column(remark)"` // string
OrderId string `json:"order_id";orm:"column(order_id)"` // string
UserName string `json:"username,omitempty"`
} }
type IncomeAndExpenseRsponse struct { type IncomeAndExpenseRsponse 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