Commit 72a10b61 authored by brent's avatar brent

modify debit

parent a8d691ab
...@@ -69,7 +69,7 @@ func (server *FundsController) Recharge() { ...@@ -69,7 +69,7 @@ func (server *FundsController) Recharge() {
// return // return
//} //}
tradeTime := fmt.Sprintf(time.Now().Format(format)) tradeTime := fmt.Sprintf(time.Now().UTC().Format(format))
//fundsData := models.Funds{ //fundsData := models.Funds{
// Id: max + 1, // Id: max + 1,
// Uid: info.UserID, // Uid: info.UserID,
...@@ -250,36 +250,6 @@ func (server *FundsController) IncomeAndExpense() { ...@@ -250,36 +250,6 @@ func (server *FundsController) IncomeAndExpense() {
return return
} }
//qs := postgres.GetOrmer().QueryTable("funds")
//infoQs := qs.Filter("id", 1)
timeCondition := ""
if appRequest.StartTime != "" && appRequest.EndTime != "" {
temp, _ := time.Parse(layout, appRequest.StartTime)
startTime := fmt.Sprintf(temp.Format(format))
temp, _ = time.Parse(layout, appRequest.EndTime)
endTime := fmt.Sprintf(temp.Format(format))
timeCondition = fmt.Sprintf("time >= '%s' and time <= '%s'", startTime, endTime)
// //infoQs = qs.Filter("trade_time__gte", startTime).Filter("trade_time__lte", endTime)
}
if appRequest.TradeType != 0 {
if timeCondition != "" {
timeCondition = timeCondition + " and"
}
timeCondition = fmt.Sprintf("%s trade_type = %d", timeCondition, appRequest.TradeType)
}
if appRequest.TradeFlow != 0 {
if timeCondition != "" {
timeCondition = timeCondition + " and"
}
timeCondition = fmt.Sprintf("%s trade_flow = %d", timeCondition, appRequest.TradeFlow)
}
if appRequest.TradeChannel != 0 {
if timeCondition != "" {
timeCondition = timeCondition + " and"
}
timeCondition = fmt.Sprintf("%s trade_channel = %d", timeCondition, appRequest.TradeChannel)
}
countQB, _ := orm.NewQueryBuilder("mysql") countQB, _ := orm.NewQueryBuilder("mysql")
countQB.Select("count(*)"). countQB.Select("count(*)").
From("funds").Where("uid != '0'") From("funds").Where("uid != '0'")
...@@ -294,12 +264,16 @@ func (server *FundsController) IncomeAndExpense() { ...@@ -294,12 +264,16 @@ func (server *FundsController) IncomeAndExpense() {
} }
if appRequest.StartTime != "" && appRequest.EndTime != "" { if appRequest.StartTime != "" && appRequest.EndTime != "" {
temp, _ := time.Parse(layout, appRequest.StartTime) start, _ := time.Parse(layout, appRequest.StartTime)
startTime := fmt.Sprintf(temp.Format(format)) startTime := fmt.Sprintf(start.Format(format))
temp, _ = time.Parse(layout, appRequest.EndTime) end, _ := time.Parse(layout, appRequest.EndTime)
endTime := fmt.Sprintf(temp.Format(format)) endTime := fmt.Sprintf(end.Format(format))
countQB.And(fmt.Sprintf("time >= '%s'", startTime)).And(fmt.Sprintf("time <= '%s'", endTime)) if end.Before(start) {
queryQB.And(fmt.Sprintf("time >= '%s'", startTime)).And(fmt.Sprintf("time <= '%s'", endTime)) server.respond(models.BusinessFailed, "起始时间不能大于结束时间")
return
}
countQB.And(fmt.Sprintf("trade_time >= '%s'", startTime)).And(fmt.Sprintf("trade_time <= '%s'", endTime))
queryQB.And(fmt.Sprintf("trade_time >= '%s'", startTime)).And(fmt.Sprintf("trade_time <= '%s'", endTime))
} }
if appRequest.TradeType != 0 { if appRequest.TradeType != 0 {
countQB.And(fmt.Sprintf("trade_type = %d", appRequest.TradeType)) countQB.And(fmt.Sprintf("trade_type = %d", appRequest.TradeType))
......
This diff is collapsed.
...@@ -22,3 +22,16 @@ func SplitDate(beginDate, endDate, format string) []string { ...@@ -22,3 +22,16 @@ func SplitDate(beginDate, endDate, format string) []string {
dlist = append(dlist, endDate) dlist = append(dlist, endDate)
return dlist return dlist
} }
func YearMonthRange(start, end time.Time, format string) []string {
// 创建年月数组
start = time.Date(start.Year(), start.Month(), 1, 0, 0, 0, 0, start.Location())
yms := make([]string, 0)
// 遍历每个月
for t := start; t.Before(end); t = t.AddDate(0, 1, 0) {
yms = append(yms, t.Format(format))
}
return yms
}
...@@ -60,6 +60,27 @@ func main() { ...@@ -60,6 +60,27 @@ func main() {
//dates := utils.SplitDate(startTimeStr, endTimeStr, "2006-01-02T15:04:05.000000Z") //dates := utils.SplitDate(startTimeStr, endTimeStr, "2006-01-02T15:04:05.000000Z")
//logs.Debug("dates = ", dates) //logs.Debug("dates = ", dates)
//currentTime := time.Now()
////start := time.Date(2023, 4, 1, 0, 0, 0, 0, currentTime.Location())
//end := time.Date(2024, 4, 1, 0, 0, 0, 0, currentTime.Location())
//
////currentTime := time.Now()
////end := time.Date(currentTime.Year(), currentTime.Month(), currentTime.Day(), 23, 59, 59, 0, time.UTC)
//temp := fmt.Sprintf("-%dh", 24*365)
//m, _ := time.ParseDuration(temp)
//tempTime := end.Add(m)
//if tempTime.Day() != 1 {
// tempTime = tempTime.AddDate(0, 1, 0)
//}
//tempTime = time.Date(tempTime.Year(), tempTime.Month(), tempTime.Day(), 0, 0, 0, 0, time.UTC)
////endDateIn := time.Date(end.Year(), end.Month(), end.Day(), 0, 0, 0, 0, time.UTC)
////endDate := fmt.Sprintf(endDateIn.Format("2006-01-02T15:04:05.000000Z"))
//
//months := yearMonthRange(tempTime, end)
//for _, month := range months {
// fmt.Println(month)
//}
cronjob.Start() cronjob.Start()
mysql.GetMysqlInstace() mysql.GetMysqlInstace()
//postgres.Query("") //postgres.Query("")
...@@ -77,3 +98,44 @@ func main() { ...@@ -77,3 +98,44 @@ func main() {
//} //}
//logs.Debug("id = ", id) //logs.Debug("id = ", id)
} }
func yearMonthRange(start, end time.Time) []string {
// 创建年月数组
start = time.Date(start.Year(), start.Month(), 1, 0, 0, 0, 0, start.Location())
//end = time.Date(end.Year(), end.Month(), 1, 0, 0, 0, 0, end.Location())
yms := make([]string, 0)
// 遍历每个月
temp := end.AddDate(0, 1, 0)
for t := start; t.Compare(end) <= 0; t = t.AddDate(0, 1, 0) {
temp = end.AddDate(0, 1, 0)
yms = append(yms, t.Format("2006-01-02T15:04:05.000000Z"))
}
fmt.Println(temp)
return yms
}
func dayRange(start, end time.Time) []time.Time {
// 创建天数组
days := make([]time.Time, 0)
// 遍历每一天
for t := start; t.Before(end.AddDate(0, 0, 1)); t = t.AddDate(0, 0, 1) {
days = append(days, t)
}
return days
}
func monthRange(start, end time.Time) []time.Month {
// 创建月份数组
months := make([]time.Month, 0)
// 遍历每个月
for t := start; t.Before(end.AddDate(0, 1, 0)); t = t.AddDate(0, 1, 0) {
months = append(months, t.Month())
}
return months
}
...@@ -63,6 +63,9 @@ type AppRequest struct { ...@@ -63,6 +63,9 @@ type AppRequest struct {
//显卡列表 //显卡列表
Type int `json:"type,omitempty"` Type int `json:"type,omitempty"`
//任务柱状图
Period int `json:"period,omitempty"`
} }
type EnumType struct { type EnumType 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