Files
kami_boss/internal/service/summary.go
danial c3906e940e refactor(account): 重构账户管理页面布局和样式
-精简HTML结构,优化`account.html`,`apple-card/account.html`,和`t-mall-game/account.html`中iframe的布局。
- 调整CSS样式,以增强用户界面的一致性和可读性。
- 优化`account_history.html`中的表格和搜索栏的样式与对齐。

fix(controller): 修正新增控制器参数顺序

- 修正`addController.go`中的参数顺序,确保交易类型正确传递给服务层。
- 更新数据库插入操作,确保UUID正确分配给新记录,防止SQL错误。
2024-09-04 09:54:18 +08:00

51 lines
970 B
Go

package service
import (
"boss/internal/common"
"boss/internal/models/order"
"math"
"time"
)
type OrderSummary struct {
}
func (s *OrderSummary) GetTodaySummary() (todaySummary order.Summary) {
todaySummary = order.Summary{}
now := time.Now()
// 获取今日零点
todayZero := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.UTC)
orderList, err := order.GetOrderByTime(todayZero.String(), now.String())
if err != nil {
return
}
amount := 0.0
paidNum := 0
paidAmount := 0.0
platformIncome := 0.0
for _, info := range orderList {
amount += info.OrderAmount
// 统计成功订单
if info.Status == common.OrderStatusSuccess {
paidNum += 1
paidAmount += info.OrderAmount
}
}
todaySummary = order.Summary{
TotalNum: len(orderList),
TotalAmount: math.Round(amount*100) / 100,
PaidNum: paidNum,
PaidAmount: math.Round(paidAmount*100) / 100,
PlatformIncome: platformIncome,
}
return
}