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() {
return
}
queryQB.OrderBy("time").Desc()
queryQB.OrderBy("trade_time").Desc()
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)
//if info.Role == 1 || info.Role == 2 {
......@@ -380,20 +380,24 @@ func (server *FundsController) IncomeAndExpense() {
id, _ := strconv.Atoi(fund.Uid)
username := FindName(users, id)
responseType := models.ResponseFunds{
Id: fund.Id, // int64
Uid: fund.Uid, // int
Amount: float64(amount), // int64
TradeChannel: models.PayMethodType(tradeChannel).String(), // int
ChannelSerial: fund.ChannelSerial, // string
StatusDesc: models.PayStatus(status).String(), // int
Status: status,
TradeTime: fund.TradeTime, // string
TradeFlow: models.TradeFlowType(tradeFlow).String(), // int
TradeType: models.TradeKind(tradeType).String(), // int
Balance: float64(balance), // int64
Remark: fund.Remark, // string
OrderId: fund.OrderId,
UserName: username,
Id: fund.Id, // int64
Uid: fund.Uid, // int
Amount: float64(amount), // int64
TradeChannel: models.PayMethodType(tradeChannel).String(), // int
TradeChannelEn: models.PayMethodType(tradeChannel).EnString(),
ChannelSerial: fund.ChannelSerial, // string
StatusDesc: models.PayStatus(status).String(),
StatusDescEn: models.PayStatus(status).EnString(), // int
Status: status,
TradeTime: fund.TradeTime, // string
TradeFlow: models.TradeFlowType(tradeFlow).String(), // int
TradeFlowEn: models.TradeFlowType(tradeFlow).EnString(),
TradeType: models.TradeKind(tradeType).String(), // int
TradeTypeEn: models.TradeKind(tradeType).EnString(),
Balance: float64(balance), // int64
Remark: fund.Remark, // string
OrderId: fund.OrderId,
UserName: username,
}
responseTypes = append(responseTypes, responseType)
}
......@@ -446,8 +450,21 @@ func (server *FundsController) Enumeration() {
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
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{
Id: int(value),
Desc: value.String(),
......
......@@ -1000,6 +1000,95 @@ func (server *TaskController) UserFeePerDay() {
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() {
info, err := server.Check()
if err != nil {
......@@ -1270,10 +1359,7 @@ func (server *TaskController) AddTasktype() {
server.respond(models.MissingParameter, "模型类型 不能为空")
return
}
if appRequest.TaskTypeIn.ResultFileExpires == 0 {
server.respond(models.MissingParameter, "结果存储时长必须 大于0")
return
}
//if &appRequest.Type.Version == nil {
// server.respond(models.MissingParameter, "版本 不能为空")
// return
......@@ -1297,6 +1383,9 @@ func (server *TaskController) AddTasktype() {
}
//ormer := orm.NewOrm()
if appRequest.TaskTypeIn.ResultFileExpires == 0 {
appRequest.TaskTypeIn.ResultFileExpires = 1800
}
ormer := mysql.GetMysqlInstace().Ormer
//err = ormer.Begin()
......@@ -1437,10 +1526,6 @@ func (server *TaskController) UpdateTaskType() {
server.respond(models.MissingParameter, "模型类型 不能为空")
return
}
if appRequest.TaskTypeIn.ResultFileExpires == 0 {
server.respond(models.MissingParameter, "结果存储时长必须 大于0")
return
}
if &appRequest.TaskTypeIn.BaseModel == nil {
server.respond(models.MissingParameter, "模型名称 不能为空")
return
......@@ -1459,6 +1544,9 @@ func (server *TaskController) UpdateTaskType() {
return
}
}
if appRequest.TaskTypeIn.ResultFileExpires == 0 {
appRequest.TaskTypeIn.ResultFileExpires = 1800
}
//ormer := orm.NewOrm()
......@@ -1694,33 +1782,36 @@ func (server *TaskController) GetTaskTypes() {
}
remodel := models.NewTaskType{
Id: data.Id,
Name: data.Name,
BaseModel: data.BaseModel,
Model: data.Model,
Version: data.Version,
Desc: data.Desc,
Price: float64(data.Price / 1000000),
PublicKey: data.PublicKey,
Complexity: data.Complexity,
Type: models.ModelType(data.Type),
TypeDesc: models.ModelType(data.Type).String(),
Kind: data.Kind,
KindDesc: models.TaskKind(data.Kind).String(),
Category: data.Category,
HardwareRequire: hardwareRequire,
ImageId: data.ImageId,
ImageUrl: data.ImageUrl,
Cmd: cmd,
Workload: data.Workload,
ApiPath: data.ApiPath,
ImageName: data.ImageName,
SignUrl: data.SignUrl,
Username: data.Username,
Password: data.Password,
Examples: examples,
Codes: codes,
Tags: tags,
Id: data.Id,
Name: data.Name,
BaseModel: data.BaseModel,
Model: data.Model,
Version: data.Version,
Desc: data.Desc,
Price: float64(data.Price / 1000000),
PublicKey: data.PublicKey,
Complexity: data.Complexity,
Type: models.ModelType(data.Type),
TypeDesc: models.ModelType(data.Type).String(),
Kind: data.Kind,
KindDesc: models.TaskKind(data.Kind).String(),
Category: data.Category,
HardwareRequire: hardwareRequire,
ImageId: data.ImageId,
ImageUrl: data.ImageUrl,
Cmd: cmd,
Workload: data.Workload,
ApiPath: data.ApiPath,
ImageName: data.ImageName,
SignUrl: data.SignUrl,
Username: data.Username,
Password: data.Password,
Examples: examples,
Codes: codes,
Tags: tags,
PublishStatus: data.PublishStatus,
AccessStatus: data.AccessStatus,
ResultFileExpires: data.ResultFileExpires,
}
remodels = append(remodels, &remodel)
}
......
......@@ -237,20 +237,24 @@ type Funds struct {
}
type ResponseFunds struct {
Id string `json:"id";orm:"column(id)"` // int64
Uid string `json:"uid";orm:"column(uid)"` // int
Amount float64 `json:"amount";orm:"column(amount)"` // int64
TradeChannel string `json:"trade_channel";orm:"column(trade_channel)"` // int
ChannelSerial string `json:"channel_serial";orm:"column(channel_serial)"` // string
Status int `json:"status";orm:"column(status);size(1)"` // int
StatusDesc string `json:"status_desc";orm:"column(status_desc);size(1)"` // int
TradeTime string `json:"trade_time";orm:"column(trade_time);type(datetime)"` // string
TradeFlow string `json:"trade_flow";orm:"column(trade_flow)"` // int
TradeType string `json:"trade_type";orm:"column(trade_type)"` // int
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"`
Id string `json:"id";orm:"column(id)"` // int64
Uid string `json:"uid";orm:"column(uid)"` // int
Amount float64 `json:"amount";orm:"column(amount)"` // int64
TradeChannel string `json:"trade_channel";orm:"column(trade_channel)"`
TradeChannelEn string `json:"trade_channel_en";orm:"column(trade_channel)"` // int
ChannelSerial string `json:"channel_serial";orm:"column(channel_serial)"` // string
Status int `json:"status";orm:"column(status);size(1)"` // int
StatusDesc string `json:"status_desc,omitempty"`
StatusDescEn string `json:"status_desc_en,omitempty"`
TradeTime string `json:"trade_time";orm:"column(trade_time);type(datetime)"` // string
TradeFlow string `json:"trade_flow";orm:"column(trade_flow)"` // int
TradeType string `json:"trade_type";orm:"column(trade_type)"` // int
TradeFlowEn string `json:"trade_flow_en";orm:"column(trade_flow)"` // int
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 {
......
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