fix: fixed data statistic datetime to CST
This commit is contained in:
@@ -147,6 +147,7 @@ func GetStatisticData() (StatisticData, error) {
|
||||
logt := db.NewScope(SendTasksLogs{}).TableName()
|
||||
inst := db.NewScope(SendTasksIns{}).TableName()
|
||||
wayst := db.NewScope(SendWays{}).TableName()
|
||||
currDay := util.GetNowTimeStr()[:10]
|
||||
|
||||
// 今日统计数据
|
||||
query := db.
|
||||
@@ -155,7 +156,7 @@ func GetStatisticData() (StatisticData, error) {
|
||||
COUNT(*) AS today_total_num,
|
||||
SUM(CASE WHEN status = 1 THEN 1 ELSE 0 END) AS today_succ_num,
|
||||
SUM(CASE WHEN status != 1 or status is null THEN 1 ELSE 0 END) AS today_failed_num`).
|
||||
Where("DATE(created_on) = CURDATE()")
|
||||
Where("DATE(created_on) = ?", currDay)
|
||||
query.First(&statistic)
|
||||
|
||||
// 最近30天数据
|
||||
@@ -167,7 +168,7 @@ SUM(CASE WHEN status != 1 or status is null THEN 1 ELSE 0 END) AS today_failed_n
|
||||
SUM(CASE WHEN status = 1 THEN 1 ELSE 0 END) AS day_succ_num,
|
||||
SUM(CASE WHEN status != 1 or status is null THEN 1 ELSE 0 END) AS day_failed_num,
|
||||
COUNT(*) AS num`).
|
||||
Where(" created_on >= CURDATE() - INTERVAL ? DAY", days).
|
||||
Where(" created_on >= DATE(?) - INTERVAL ? DAY", currDay, days).
|
||||
Group("DATE(created_on)").
|
||||
Order("created_on")
|
||||
queryData.Scan(&latestData)
|
||||
|
||||
@@ -75,7 +75,7 @@ var LatestVersion = map[string]string{}
|
||||
//13. 支持更多的api接入示例
|
||||
//`
|
||||
|
||||
var LatestVersionS = "v0.0.9"
|
||||
var LatestVersionS = "v0.1.0"
|
||||
var LatestVersionDesc = `
|
||||
1. 单应用打包
|
||||
2. 支持邮件发送
|
||||
|
||||
@@ -53,3 +53,11 @@ func (t *Time) Scan(v interface{}) error {
|
||||
}
|
||||
return fmt.Errorf("can not convert %v to timestamp", v)
|
||||
}
|
||||
|
||||
// GetNowTimeStr 获取当前的时间字符串
|
||||
func GetNowTimeStr() string {
|
||||
currentTimeUTC := time.Now().UTC()
|
||||
chinaTime := currentTimeUTC.Add(8 * time.Hour)
|
||||
formattedTime := chinaTime.Format("2006-01-02 15:04:05")
|
||||
return formattedTime
|
||||
}
|
||||
|
||||
+16
-10
@@ -20,17 +20,23 @@ class CommonUtils {
|
||||
static formatWayName = (type) => {
|
||||
return CONSTANT.WAYS_DATA_MAP[type].label;
|
||||
}
|
||||
|
||||
|
||||
// 获取东八区时间字符串
|
||||
static getCurrentTimeStr = () => {
|
||||
const currentDate = new Date();
|
||||
const year = currentDate.getFullYear();
|
||||
const month = String(currentDate.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(currentDate.getDate()).padStart(2, '0');
|
||||
const hours = String(currentDate.getHours()).padStart(2, '0');
|
||||
const minutes = String(currentDate.getMinutes()).padStart(2, '0');
|
||||
const seconds = String(currentDate.getSeconds()).padStart(2, '0');
|
||||
const formattedDate = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
||||
return formattedDate;
|
||||
let time = new Date();
|
||||
const timezoneOffset = 8;
|
||||
const utc = time.getTime() + time.getTimezoneOffset() * 60000;
|
||||
const chinaDate = new Date(utc + timezoneOffset * 60 * 60 * 1000);
|
||||
|
||||
const year = chinaDate.getFullYear();
|
||||
const month = String(chinaDate.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(chinaDate.getDate()).padStart(2, '0');
|
||||
const hour = String(chinaDate.getHours()).padStart(2, '0');
|
||||
const minute = String(chinaDate.getMinutes()).padStart(2, '0');
|
||||
const second = String(chinaDate.getSeconds()).padStart(2, '0');
|
||||
|
||||
const formattedDateTime = `${year}-${month}-${day} ${hour}:${minute}:${second}`;
|
||||
return formattedDateTime;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user